repo_name
stringclasses
6 values
pr_number
int64
512
78.9k
pr_title
stringlengths
3
144
pr_description
stringlengths
0
30.3k
author
stringlengths
2
21
date_created
timestamp[ns, tz=UTC]
date_merged
timestamp[ns, tz=UTC]
previous_commit
stringlengths
40
40
pr_commit
stringlengths
40
40
query
stringlengths
17
30.4k
filepath
stringlengths
9
210
before_content
stringlengths
0
112M
after_content
stringlengths
0
112M
label
int64
-1
1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeIdentifierAttribute.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Runtime.InteropServices { [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Struct | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] public sealed class TypeIdentifierAttribute : Attribute { public TypeIdentifierAttribute() { } public TypeIdentifierAttribute(string? scope, string? identifier) { Scope = scope; Identifier = identifier; } public string? Scope { get; } public string? Identifier { get; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Runtime.InteropServices { [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Struct | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] public sealed class TypeIdentifierAttribute : Attribute { public TypeIdentifierAttribute() { } public TypeIdentifierAttribute(string? scope, string? identifier) { Scope = scope; Identifier = identifier; } public string? Scope { get; } public string? Identifier { get; } } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/MetadataFixupKind.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace Internal.Runtime.TypeLoader { public enum MetadataFixupKind { // Metadata fixups that apply to type tokens TypeHandle = 0x0, GcStaticData = 0x1, NonGcStaticData = 0x2, UnwrapNullableType = 0x3, TypeSize = 0x4, AllocateObject = 0x5, DefaultConstructor = 0x6, // unused = 0x7, // unused = 0x8, IsInst = 0x9, CastClass = 0xa, AllocateArray = 0xb, CheckArrayElementType = 0xc, ArrayOfTypeHandle = 0xd, DirectGcStaticData = 0xe, DirectNonGcStaticData = 0xf, // Insert new fixups applying to type tokens by creating a new block of fixups which apply to type tokens EndTypeTokenFixups, // Metadata fixups that apply to method tokens VirtualCallDispatch = 0x10, MethodDictionary = 0x11, MethodLdToken = 0x12, Method = 0x13, UnboxingStubMethod = 0x14, CallableMethod = 0x15, // Insert new fixups applying to method tokens before this point EndMethodTokenFixups, // Metadata fixups that apply to a type/method token pair NonGenericDirectConstrainedMethod = 0x20, NonGenericConstrainedMethod = 0x21, GenericConstrainedMethod = 0x22, // Insert new fixups applying to type/method token pairs before this point EndConstraintMethodFixups, // Metadata fixups that apply to a field token FieldLdToken = 0x30, FieldOffset = 0x31, // Insert new fixups applying to field tokens before this point EndFieldTokenFixups, // Metadata fixups that apply to a signature token CallingConventionConverter_NoInstantiatingParam = 0x40, CallingConventionConverter_HasInstantiatingParam = 0x41, CallingConventionConverter_MaybeInstantiatingParam = 0x42, // Insert new fixups applying to signature tokens before this point EndSignatureTokenFixups, } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace Internal.Runtime.TypeLoader { public enum MetadataFixupKind { // Metadata fixups that apply to type tokens TypeHandle = 0x0, GcStaticData = 0x1, NonGcStaticData = 0x2, UnwrapNullableType = 0x3, TypeSize = 0x4, AllocateObject = 0x5, DefaultConstructor = 0x6, // unused = 0x7, // unused = 0x8, IsInst = 0x9, CastClass = 0xa, AllocateArray = 0xb, CheckArrayElementType = 0xc, ArrayOfTypeHandle = 0xd, DirectGcStaticData = 0xe, DirectNonGcStaticData = 0xf, // Insert new fixups applying to type tokens by creating a new block of fixups which apply to type tokens EndTypeTokenFixups, // Metadata fixups that apply to method tokens VirtualCallDispatch = 0x10, MethodDictionary = 0x11, MethodLdToken = 0x12, Method = 0x13, UnboxingStubMethod = 0x14, CallableMethod = 0x15, // Insert new fixups applying to method tokens before this point EndMethodTokenFixups, // Metadata fixups that apply to a type/method token pair NonGenericDirectConstrainedMethod = 0x20, NonGenericConstrainedMethod = 0x21, GenericConstrainedMethod = 0x22, // Insert new fixups applying to type/method token pairs before this point EndConstraintMethodFixups, // Metadata fixups that apply to a field token FieldLdToken = 0x30, FieldOffset = 0x31, // Insert new fixups applying to field tokens before this point EndFieldTokenFixups, // Metadata fixups that apply to a signature token CallingConventionConverter_NoInstantiatingParam = 0x40, CallingConventionConverter_HasInstantiatingParam = 0x41, CallingConventionConverter_MaybeInstantiatingParam = 0x42, // Insert new fixups applying to signature tokens before this point EndSignatureTokenFixups, } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerHelpers/TypedReferenceHelpers.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; namespace Internal.Runtime.CompilerHelpers { /// <summary> /// These methods are used to implement TypedReference-related instructions. /// </summary> internal static class TypedReferenceHelpers { public static Type TypeHandleToRuntimeTypeMaybeNull(RuntimeTypeHandle typeHandle) { if (typeHandle.IsNull) return null; return Type.GetTypeFromHandle(typeHandle); } public static RuntimeTypeHandle TypeHandleToRuntimeTypeHandleMaybeNull(RuntimeTypeHandle typeHandle) { return typeHandle; } public static ref byte GetRefAny(RuntimeTypeHandle type, TypedReference typedRef) { if (!TypedReference.RawTargetTypeToken(typedRef).Equals(type)) { throw new InvalidCastException(); } return ref typedRef.Value; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; namespace Internal.Runtime.CompilerHelpers { /// <summary> /// These methods are used to implement TypedReference-related instructions. /// </summary> internal static class TypedReferenceHelpers { public static Type TypeHandleToRuntimeTypeMaybeNull(RuntimeTypeHandle typeHandle) { if (typeHandle.IsNull) return null; return Type.GetTypeFromHandle(typeHandle); } public static RuntimeTypeHandle TypeHandleToRuntimeTypeHandleMaybeNull(RuntimeTypeHandle typeHandle) { return typeHandle; } public static ref byte GetRefAny(RuntimeTypeHandle type, TypedReference typedRef) { if (!TypedReference.RawTargetTypeToken(typedRef).Equals(type)) { throw new InvalidCastException(); } return ref typedRef.Value; } } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/libraries/Common/src/Interop/Windows/OleAut32/Interop.SysAllocStringLen.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Runtime.InteropServices; internal static partial class Interop { internal static partial class OleAut32 { [LibraryImport(Libraries.OleAut32, StringMarshalling = StringMarshalling.Utf16)] internal static partial IntPtr SysAllocStringLen(IntPtr src, uint len); [LibraryImport(Libraries.OleAut32, StringMarshalling = StringMarshalling.Utf16)] internal static partial IntPtr SysAllocStringLen(string src, uint len); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Runtime.InteropServices; internal static partial class Interop { internal static partial class OleAut32 { [LibraryImport(Libraries.OleAut32, StringMarshalling = StringMarshalling.Utf16)] internal static partial IntPtr SysAllocStringLen(IntPtr src, uint len); [LibraryImport(Libraries.OleAut32, StringMarshalling = StringMarshalling.Utf16)] internal static partial IntPtr SysAllocStringLen(string src, uint len); } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Scheduling/QueryTaskGroupState.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // // QueryTaskGroupState.cs // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using System.Diagnostics; namespace System.Linq.Parallel { /// <summary> /// A collection of tasks used by a single query instance. This type also offers some /// convenient methods for tracing significant ETW events, waiting on tasks, propagating /// exceptions, and performing cancellation activities. /// </summary> internal sealed class QueryTaskGroupState { private Task? _rootTask; // The task under which all query tasks root. private int _alreadyEnded; // Whether the tasks have been waited on already. private readonly CancellationState _cancellationState; // The cancellation state. private readonly int _queryId; // Id of this query execution. //----------------------------------------------------------------------------------- // Creates a new shared bit of state among tasks. // internal QueryTaskGroupState(CancellationState cancellationState, int queryId) { _cancellationState = cancellationState; _queryId = queryId; } //----------------------------------------------------------------------------------- // Whether this query has ended or not. // internal bool IsAlreadyEnded { get { return _alreadyEnded == 1; } } //----------------------------------------------------------------------------------- // Cancellation state, used to tear down tasks cooperatively when necessary. // internal CancellationState CancellationState { get { return _cancellationState; } } //----------------------------------------------------------------------------------- // Id of this query execution. // internal int QueryId { get { return _queryId; } } //----------------------------------------------------------------------------------- // Marks the beginning of a query's execution. // internal void QueryBegin(Task rootTask) { Debug.Assert(rootTask != null, "Expected a non-null task"); Debug.Assert(_rootTask == null, "Cannot begin a query more than once"); _rootTask = rootTask; } //----------------------------------------------------------------------------------- // Marks the end of a query's execution, waiting for all tasks to finish and // propagating any relevant exceptions. Note that the full set of tasks must have // been initialized (with SetTask) before calling this. // internal void QueryEnd(bool userInitiatedDispose) { Debug.Assert(_rootTask != null); //Debug.Assert(Task.Current == null || (Task.Current != _rootTask && Task.Current.Parent != _rootTask)); if (Interlocked.Exchange(ref _alreadyEnded, 1) == 0) { // There are four cases: // Case #1: Wait produced an exception that is not OCE(ct), or an AggregateException which is not full of OCE(ct) ==> We rethrow. // Case #2: External cancellation has been requested ==> we'll manually throw OCE(externalToken). // Case #3a: We are servicing a call to Dispose() (and possibly also external cancellation has been requested).. simply return. // Case #3b: The enumerator has already been disposed (and possibly also external cancellation was requested). Throw an ODE. // Case #4: No exceptions or explicit call to Dispose() by this caller ==> we just return. // See also "InlinedAggregationOperator" which duplicates some of this logic for the aggregators. // See also "QueryOpeningEnumerator" which duplicates some of this logic. // See also "ExceptionAggregator" which duplicates some of this logic. try { // Wait for all the tasks to complete // If any of the tasks ended in the Faulted stated, an AggregateException will be thrown. _rootTask.Wait(); } catch (AggregateException ae) { AggregateException flattenedAE = ae.Flatten(); bool allOCEsOnTrackedExternalCancellationToken = true; for (int i = 0; i < flattenedAE.InnerExceptions.Count; i++) { OperationCanceledException? oce = flattenedAE.InnerExceptions[i] as OperationCanceledException; // we only let it pass through iff: // it is not null, not default, and matches the exact token we were given as being the external token // and the external Token is actually canceled (i.e. not a spoof OCE(extCT) for a non-canceled extCT) if (oce == null || !oce.CancellationToken.IsCancellationRequested || oce.CancellationToken != _cancellationState.ExternalCancellationToken) { allOCEsOnTrackedExternalCancellationToken = false; break; } } // if all the exceptions were OCE(externalToken), then we will propagate only a single OCE(externalToken) below // otherwise, we flatten the aggregate (because the WaitAll above already aggregated) and rethrow. if (!allOCEsOnTrackedExternalCancellationToken || flattenedAE.InnerExceptions.Count == 0) throw flattenedAE; // Case #1 } finally { //_rootTask don't support Dispose on some platforms IDisposable disposable = _rootTask as IDisposable; if (disposable != null) disposable.Dispose(); } if (_cancellationState.MergedCancellationToken.IsCancellationRequested) { // cancellation has occurred but no user-delegate exceptions were detected // NOTE: it is important that we see other state variables correctly here, and that // read-reordering hasn't played havoc. // This is OK because // 1. all the state writes (e,g. in the Initiate* methods) are volatile writes (standard .NET MM) // 2. tokenCancellationRequested is backed by a volatile field, hence the reads below // won't get reordered about the read of token.IsCancellationRequested. // If the query has already been disposed, we don't want to throw an OCE if (!_cancellationState.TopLevelDisposedFlag.Value) { CancellationState.ThrowWithStandardMessageIfCanceled(_cancellationState.ExternalCancellationToken); // Case #2 } //otherwise, given that there were no user-delegate exceptions (they would have been rethrown above), //the only remaining situation is user-initiated dispose. Debug.Assert(_cancellationState.TopLevelDisposedFlag.Value); // If we aren't actively disposing, that means somebody else previously disposed // of the enumerator. We must throw an ObjectDisposedException. if (!userInitiatedDispose) { throw new ObjectDisposedException("enumerator", SR.PLINQ_DisposeRequested); // Case #3 } } // Case #4. nothing to do. } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // // QueryTaskGroupState.cs // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using System.Diagnostics; namespace System.Linq.Parallel { /// <summary> /// A collection of tasks used by a single query instance. This type also offers some /// convenient methods for tracing significant ETW events, waiting on tasks, propagating /// exceptions, and performing cancellation activities. /// </summary> internal sealed class QueryTaskGroupState { private Task? _rootTask; // The task under which all query tasks root. private int _alreadyEnded; // Whether the tasks have been waited on already. private readonly CancellationState _cancellationState; // The cancellation state. private readonly int _queryId; // Id of this query execution. //----------------------------------------------------------------------------------- // Creates a new shared bit of state among tasks. // internal QueryTaskGroupState(CancellationState cancellationState, int queryId) { _cancellationState = cancellationState; _queryId = queryId; } //----------------------------------------------------------------------------------- // Whether this query has ended or not. // internal bool IsAlreadyEnded { get { return _alreadyEnded == 1; } } //----------------------------------------------------------------------------------- // Cancellation state, used to tear down tasks cooperatively when necessary. // internal CancellationState CancellationState { get { return _cancellationState; } } //----------------------------------------------------------------------------------- // Id of this query execution. // internal int QueryId { get { return _queryId; } } //----------------------------------------------------------------------------------- // Marks the beginning of a query's execution. // internal void QueryBegin(Task rootTask) { Debug.Assert(rootTask != null, "Expected a non-null task"); Debug.Assert(_rootTask == null, "Cannot begin a query more than once"); _rootTask = rootTask; } //----------------------------------------------------------------------------------- // Marks the end of a query's execution, waiting for all tasks to finish and // propagating any relevant exceptions. Note that the full set of tasks must have // been initialized (with SetTask) before calling this. // internal void QueryEnd(bool userInitiatedDispose) { Debug.Assert(_rootTask != null); //Debug.Assert(Task.Current == null || (Task.Current != _rootTask && Task.Current.Parent != _rootTask)); if (Interlocked.Exchange(ref _alreadyEnded, 1) == 0) { // There are four cases: // Case #1: Wait produced an exception that is not OCE(ct), or an AggregateException which is not full of OCE(ct) ==> We rethrow. // Case #2: External cancellation has been requested ==> we'll manually throw OCE(externalToken). // Case #3a: We are servicing a call to Dispose() (and possibly also external cancellation has been requested).. simply return. // Case #3b: The enumerator has already been disposed (and possibly also external cancellation was requested). Throw an ODE. // Case #4: No exceptions or explicit call to Dispose() by this caller ==> we just return. // See also "InlinedAggregationOperator" which duplicates some of this logic for the aggregators. // See also "QueryOpeningEnumerator" which duplicates some of this logic. // See also "ExceptionAggregator" which duplicates some of this logic. try { // Wait for all the tasks to complete // If any of the tasks ended in the Faulted stated, an AggregateException will be thrown. _rootTask.Wait(); } catch (AggregateException ae) { AggregateException flattenedAE = ae.Flatten(); bool allOCEsOnTrackedExternalCancellationToken = true; for (int i = 0; i < flattenedAE.InnerExceptions.Count; i++) { OperationCanceledException? oce = flattenedAE.InnerExceptions[i] as OperationCanceledException; // we only let it pass through iff: // it is not null, not default, and matches the exact token we were given as being the external token // and the external Token is actually canceled (i.e. not a spoof OCE(extCT) for a non-canceled extCT) if (oce == null || !oce.CancellationToken.IsCancellationRequested || oce.CancellationToken != _cancellationState.ExternalCancellationToken) { allOCEsOnTrackedExternalCancellationToken = false; break; } } // if all the exceptions were OCE(externalToken), then we will propagate only a single OCE(externalToken) below // otherwise, we flatten the aggregate (because the WaitAll above already aggregated) and rethrow. if (!allOCEsOnTrackedExternalCancellationToken || flattenedAE.InnerExceptions.Count == 0) throw flattenedAE; // Case #1 } finally { //_rootTask don't support Dispose on some platforms IDisposable disposable = _rootTask as IDisposable; if (disposable != null) disposable.Dispose(); } if (_cancellationState.MergedCancellationToken.IsCancellationRequested) { // cancellation has occurred but no user-delegate exceptions were detected // NOTE: it is important that we see other state variables correctly here, and that // read-reordering hasn't played havoc. // This is OK because // 1. all the state writes (e,g. in the Initiate* methods) are volatile writes (standard .NET MM) // 2. tokenCancellationRequested is backed by a volatile field, hence the reads below // won't get reordered about the read of token.IsCancellationRequested. // If the query has already been disposed, we don't want to throw an OCE if (!_cancellationState.TopLevelDisposedFlag.Value) { CancellationState.ThrowWithStandardMessageIfCanceled(_cancellationState.ExternalCancellationToken); // Case #2 } //otherwise, given that there were no user-delegate exceptions (they would have been rethrown above), //the only remaining situation is user-initiated dispose. Debug.Assert(_cancellationState.TopLevelDisposedFlag.Value); // If we aren't actively disposing, that means somebody else previously disposed // of the enumerator. We must throw an ObjectDisposedException. if (!userInitiatedDispose) { throw new ObjectDisposedException("enumerator", SR.PLINQ_DisposeRequested); // Case #3 } } // Case #4. nothing to do. } } } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/libraries/Common/src/Interop/Unix/Interop.Errors.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Runtime.InteropServices; internal static partial class Interop { /// <summary>Common Unix errno error codes.</summary> internal enum Error { // These values were defined in src/Native/System.Native/fxerrno.h // // They compare against values obtained via Interop.Sys.GetLastError() not Marshal.GetLastWin32Error() // which obtains the raw errno that varies between unixes. The strong typing as an enum is meant to // prevent confusing the two. Casting to or from int is suspect. Use GetLastErrorInfo() if you need to // correlate these to the underlying platform values or obtain the corresponding error message. // SUCCESS = 0, E2BIG = 0x10001, // Argument list too long. EACCES = 0x10002, // Permission denied. EADDRINUSE = 0x10003, // Address in use. EADDRNOTAVAIL = 0x10004, // Address not available. EAFNOSUPPORT = 0x10005, // Address family not supported. EAGAIN = 0x10006, // Resource unavailable, try again (same value as EWOULDBLOCK), EALREADY = 0x10007, // Connection already in progress. EBADF = 0x10008, // Bad file descriptor. EBADMSG = 0x10009, // Bad message. EBUSY = 0x1000A, // Device or resource busy. ECANCELED = 0x1000B, // Operation canceled. ECHILD = 0x1000C, // No child processes. ECONNABORTED = 0x1000D, // Connection aborted. ECONNREFUSED = 0x1000E, // Connection refused. ECONNRESET = 0x1000F, // Connection reset. EDEADLK = 0x10010, // Resource deadlock would occur. EDESTADDRREQ = 0x10011, // Destination address required. EDOM = 0x10012, // Mathematics argument out of domain of function. EDQUOT = 0x10013, // Reserved. EEXIST = 0x10014, // File exists. EFAULT = 0x10015, // Bad address. EFBIG = 0x10016, // File too large. EHOSTUNREACH = 0x10017, // Host is unreachable. EIDRM = 0x10018, // Identifier removed. EILSEQ = 0x10019, // Illegal byte sequence. EINPROGRESS = 0x1001A, // Operation in progress. EINTR = 0x1001B, // Interrupted function. EINVAL = 0x1001C, // Invalid argument. EIO = 0x1001D, // I/O error. EISCONN = 0x1001E, // Socket is connected. EISDIR = 0x1001F, // Is a directory. ELOOP = 0x10020, // Too many levels of symbolic links. EMFILE = 0x10021, // File descriptor value too large. EMLINK = 0x10022, // Too many links. EMSGSIZE = 0x10023, // Message too large. EMULTIHOP = 0x10024, // Reserved. ENAMETOOLONG = 0x10025, // Filename too long. ENETDOWN = 0x10026, // Network is down. ENETRESET = 0x10027, // Connection aborted by network. ENETUNREACH = 0x10028, // Network unreachable. ENFILE = 0x10029, // Too many files open in system. ENOBUFS = 0x1002A, // No buffer space available. ENODEV = 0x1002C, // No such device. ENOENT = 0x1002D, // No such file or directory. ENOEXEC = 0x1002E, // Executable file format error. ENOLCK = 0x1002F, // No locks available. ENOLINK = 0x10030, // Reserved. ENOMEM = 0x10031, // Not enough space. ENOMSG = 0x10032, // No message of the desired type. ENOPROTOOPT = 0x10033, // Protocol not available. ENOSPC = 0x10034, // No space left on device. ENOSYS = 0x10037, // Function not supported. ENOTCONN = 0x10038, // The socket is not connected. ENOTDIR = 0x10039, // Not a directory or a symbolic link to a directory. ENOTEMPTY = 0x1003A, // Directory not empty. ENOTRECOVERABLE = 0x1003B, // State not recoverable. ENOTSOCK = 0x1003C, // Not a socket. ENOTSUP = 0x1003D, // Not supported (same value as EOPNOTSUP). ENOTTY = 0x1003E, // Inappropriate I/O control operation. ENXIO = 0x1003F, // No such device or address. EOVERFLOW = 0x10040, // Value too large to be stored in data type. EOWNERDEAD = 0x10041, // Previous owner died. EPERM = 0x10042, // Operation not permitted. EPIPE = 0x10043, // Broken pipe. EPROTO = 0x10044, // Protocol error. EPROTONOSUPPORT = 0x10045, // Protocol not supported. EPROTOTYPE = 0x10046, // Protocol wrong type for socket. ERANGE = 0x10047, // Result too large. EROFS = 0x10048, // Read-only file system. ESPIPE = 0x10049, // Invalid seek. ESRCH = 0x1004A, // No such process. ESTALE = 0x1004B, // Reserved. ETIMEDOUT = 0x1004D, // Connection timed out. ETXTBSY = 0x1004E, // Text file busy. EXDEV = 0x1004F, // Cross-device link. ESOCKTNOSUPPORT = 0x1005E, // Socket type not supported. EPFNOSUPPORT = 0x10060, // Protocol family not supported. ESHUTDOWN = 0x1006C, // Socket shutdown. EHOSTDOWN = 0x10070, // Host is down. ENODATA = 0x10071, // No data available. // Custom Error codes to track errors beyond kernel interface. EHOSTNOTFOUND = 0x20001, // Name lookup failed ESOCKETERROR = 0x20002, // Unspecified socket error // POSIX permits these to have the same value and we make them always equal so // that we do not introduce a dependency on distinguishing between them that // would not work on all platforms. EOPNOTSUPP = ENOTSUP, // Operation not supported on socket. EWOULDBLOCK = EAGAIN, // Operation would block. } // Represents a platform-agnostic Error and underlying platform-specific errno internal struct ErrorInfo { private readonly Error _error; private int _rawErrno; internal ErrorInfo(int errno) { _error = Interop.Sys.ConvertErrorPlatformToPal(errno); _rawErrno = errno; } internal ErrorInfo(Error error) { _error = error; _rawErrno = -1; } internal Error Error { get { return _error; } } internal int RawErrno { get { return _rawErrno == -1 ? (_rawErrno = Interop.Sys.ConvertErrorPalToPlatform(_error)) : _rawErrno; } } internal string GetErrorMessage() { return Interop.Sys.StrError(RawErrno); } public override string ToString() { return $"RawErrno: {RawErrno} Error: {Error} GetErrorMessage: {GetErrorMessage()}"; // No localization required; text is member names used for debugging purposes } } internal static partial class Sys { internal static Error GetLastError() { return ConvertErrorPlatformToPal(Marshal.GetLastWin32Error()); } internal static ErrorInfo GetLastErrorInfo() { return new ErrorInfo(Marshal.GetLastWin32Error()); } internal static unsafe string StrError(int platformErrno) { int maxBufferLength = 1024; // should be long enough for most any UNIX error byte* buffer = stackalloc byte[maxBufferLength]; byte* message = StrErrorR(platformErrno, buffer, maxBufferLength); if (message == null) { // This means the buffer was not large enough, but still contains // as much of the error message as possible and is guaranteed to // be null-terminated. We're not currently resizing/retrying because // maxBufferLength is large enough in practice, but we could do // so here in the future if necessary. message = buffer; } return Marshal.PtrToStringAnsi((IntPtr)message)!; } #if SERIAL_PORTS [LibraryImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_ConvertErrorPlatformToPal")] internal static partial Error ConvertErrorPlatformToPal(int platformErrno); [LibraryImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_ConvertErrorPalToPlatform")] internal static partial int ConvertErrorPalToPlatform(Error error); [LibraryImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_StrErrorR")] private static unsafe partial byte* StrErrorR(int platformErrno, byte* buffer, int bufferSize); #else [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_ConvertErrorPlatformToPal")] [SuppressGCTransition] internal static partial Error ConvertErrorPlatformToPal(int platformErrno); [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_ConvertErrorPalToPlatform")] [SuppressGCTransition] internal static partial int ConvertErrorPalToPlatform(Error error); [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_StrErrorR")] private static unsafe partial byte* StrErrorR(int platformErrno, byte* buffer, int bufferSize); #endif } } // NOTE: extension method can't be nested inside Interop class. internal static class InteropErrorExtensions { // Intended usage is e.g. Interop.Error.EFAIL.Info() for brevity // vs. new Interop.ErrorInfo(Interop.Error.EFAIL) for synthesizing // errors. Errors originated from the system should be obtained // via GetLastErrorInfo(), not GetLastError().Info() as that will // convert twice, which is not only inefficient but also lossy if // we ever encounter a raw errno that no equivalent in the Error // enum. public static Interop.ErrorInfo Info(this Interop.Error error) { return new Interop.ErrorInfo(error); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Runtime.InteropServices; internal static partial class Interop { /// <summary>Common Unix errno error codes.</summary> internal enum Error { // These values were defined in src/Native/System.Native/fxerrno.h // // They compare against values obtained via Interop.Sys.GetLastError() not Marshal.GetLastWin32Error() // which obtains the raw errno that varies between unixes. The strong typing as an enum is meant to // prevent confusing the two. Casting to or from int is suspect. Use GetLastErrorInfo() if you need to // correlate these to the underlying platform values or obtain the corresponding error message. // SUCCESS = 0, E2BIG = 0x10001, // Argument list too long. EACCES = 0x10002, // Permission denied. EADDRINUSE = 0x10003, // Address in use. EADDRNOTAVAIL = 0x10004, // Address not available. EAFNOSUPPORT = 0x10005, // Address family not supported. EAGAIN = 0x10006, // Resource unavailable, try again (same value as EWOULDBLOCK), EALREADY = 0x10007, // Connection already in progress. EBADF = 0x10008, // Bad file descriptor. EBADMSG = 0x10009, // Bad message. EBUSY = 0x1000A, // Device or resource busy. ECANCELED = 0x1000B, // Operation canceled. ECHILD = 0x1000C, // No child processes. ECONNABORTED = 0x1000D, // Connection aborted. ECONNREFUSED = 0x1000E, // Connection refused. ECONNRESET = 0x1000F, // Connection reset. EDEADLK = 0x10010, // Resource deadlock would occur. EDESTADDRREQ = 0x10011, // Destination address required. EDOM = 0x10012, // Mathematics argument out of domain of function. EDQUOT = 0x10013, // Reserved. EEXIST = 0x10014, // File exists. EFAULT = 0x10015, // Bad address. EFBIG = 0x10016, // File too large. EHOSTUNREACH = 0x10017, // Host is unreachable. EIDRM = 0x10018, // Identifier removed. EILSEQ = 0x10019, // Illegal byte sequence. EINPROGRESS = 0x1001A, // Operation in progress. EINTR = 0x1001B, // Interrupted function. EINVAL = 0x1001C, // Invalid argument. EIO = 0x1001D, // I/O error. EISCONN = 0x1001E, // Socket is connected. EISDIR = 0x1001F, // Is a directory. ELOOP = 0x10020, // Too many levels of symbolic links. EMFILE = 0x10021, // File descriptor value too large. EMLINK = 0x10022, // Too many links. EMSGSIZE = 0x10023, // Message too large. EMULTIHOP = 0x10024, // Reserved. ENAMETOOLONG = 0x10025, // Filename too long. ENETDOWN = 0x10026, // Network is down. ENETRESET = 0x10027, // Connection aborted by network. ENETUNREACH = 0x10028, // Network unreachable. ENFILE = 0x10029, // Too many files open in system. ENOBUFS = 0x1002A, // No buffer space available. ENODEV = 0x1002C, // No such device. ENOENT = 0x1002D, // No such file or directory. ENOEXEC = 0x1002E, // Executable file format error. ENOLCK = 0x1002F, // No locks available. ENOLINK = 0x10030, // Reserved. ENOMEM = 0x10031, // Not enough space. ENOMSG = 0x10032, // No message of the desired type. ENOPROTOOPT = 0x10033, // Protocol not available. ENOSPC = 0x10034, // No space left on device. ENOSYS = 0x10037, // Function not supported. ENOTCONN = 0x10038, // The socket is not connected. ENOTDIR = 0x10039, // Not a directory or a symbolic link to a directory. ENOTEMPTY = 0x1003A, // Directory not empty. ENOTRECOVERABLE = 0x1003B, // State not recoverable. ENOTSOCK = 0x1003C, // Not a socket. ENOTSUP = 0x1003D, // Not supported (same value as EOPNOTSUP). ENOTTY = 0x1003E, // Inappropriate I/O control operation. ENXIO = 0x1003F, // No such device or address. EOVERFLOW = 0x10040, // Value too large to be stored in data type. EOWNERDEAD = 0x10041, // Previous owner died. EPERM = 0x10042, // Operation not permitted. EPIPE = 0x10043, // Broken pipe. EPROTO = 0x10044, // Protocol error. EPROTONOSUPPORT = 0x10045, // Protocol not supported. EPROTOTYPE = 0x10046, // Protocol wrong type for socket. ERANGE = 0x10047, // Result too large. EROFS = 0x10048, // Read-only file system. ESPIPE = 0x10049, // Invalid seek. ESRCH = 0x1004A, // No such process. ESTALE = 0x1004B, // Reserved. ETIMEDOUT = 0x1004D, // Connection timed out. ETXTBSY = 0x1004E, // Text file busy. EXDEV = 0x1004F, // Cross-device link. ESOCKTNOSUPPORT = 0x1005E, // Socket type not supported. EPFNOSUPPORT = 0x10060, // Protocol family not supported. ESHUTDOWN = 0x1006C, // Socket shutdown. EHOSTDOWN = 0x10070, // Host is down. ENODATA = 0x10071, // No data available. // Custom Error codes to track errors beyond kernel interface. EHOSTNOTFOUND = 0x20001, // Name lookup failed ESOCKETERROR = 0x20002, // Unspecified socket error // POSIX permits these to have the same value and we make them always equal so // that we do not introduce a dependency on distinguishing between them that // would not work on all platforms. EOPNOTSUPP = ENOTSUP, // Operation not supported on socket. EWOULDBLOCK = EAGAIN, // Operation would block. } // Represents a platform-agnostic Error and underlying platform-specific errno internal struct ErrorInfo { private readonly Error _error; private int _rawErrno; internal ErrorInfo(int errno) { _error = Interop.Sys.ConvertErrorPlatformToPal(errno); _rawErrno = errno; } internal ErrorInfo(Error error) { _error = error; _rawErrno = -1; } internal Error Error { get { return _error; } } internal int RawErrno { get { return _rawErrno == -1 ? (_rawErrno = Interop.Sys.ConvertErrorPalToPlatform(_error)) : _rawErrno; } } internal string GetErrorMessage() { return Interop.Sys.StrError(RawErrno); } public override string ToString() { return $"RawErrno: {RawErrno} Error: {Error} GetErrorMessage: {GetErrorMessage()}"; // No localization required; text is member names used for debugging purposes } } internal static partial class Sys { internal static Error GetLastError() { return ConvertErrorPlatformToPal(Marshal.GetLastWin32Error()); } internal static ErrorInfo GetLastErrorInfo() { return new ErrorInfo(Marshal.GetLastWin32Error()); } internal static unsafe string StrError(int platformErrno) { int maxBufferLength = 1024; // should be long enough for most any UNIX error byte* buffer = stackalloc byte[maxBufferLength]; byte* message = StrErrorR(platformErrno, buffer, maxBufferLength); if (message == null) { // This means the buffer was not large enough, but still contains // as much of the error message as possible and is guaranteed to // be null-terminated. We're not currently resizing/retrying because // maxBufferLength is large enough in practice, but we could do // so here in the future if necessary. message = buffer; } return Marshal.PtrToStringAnsi((IntPtr)message)!; } #if SERIAL_PORTS [LibraryImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_ConvertErrorPlatformToPal")] internal static partial Error ConvertErrorPlatformToPal(int platformErrno); [LibraryImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_ConvertErrorPalToPlatform")] internal static partial int ConvertErrorPalToPlatform(Error error); [LibraryImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_StrErrorR")] private static unsafe partial byte* StrErrorR(int platformErrno, byte* buffer, int bufferSize); #else [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_ConvertErrorPlatformToPal")] [SuppressGCTransition] internal static partial Error ConvertErrorPlatformToPal(int platformErrno); [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_ConvertErrorPalToPlatform")] [SuppressGCTransition] internal static partial int ConvertErrorPalToPlatform(Error error); [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_StrErrorR")] private static unsafe partial byte* StrErrorR(int platformErrno, byte* buffer, int bufferSize); #endif } } // NOTE: extension method can't be nested inside Interop class. internal static class InteropErrorExtensions { // Intended usage is e.g. Interop.Error.EFAIL.Info() for brevity // vs. new Interop.ErrorInfo(Interop.Error.EFAIL) for synthesizing // errors. Errors originated from the system should be obtained // via GetLastErrorInfo(), not GetLastError().Info() as that will // convert twice, which is not only inefficient but also lossy if // we ever encounter a raw errno that no equivalent in the Error // enum. public static Interop.ErrorInfo Info(this Interop.Error error) { return new Interop.ErrorInfo(error); } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventBookmark.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Diagnostics.Eventing.Reader { // // NOTE: This class must be generic enough to be used across // eventing base implementations. Cannot add anything // that ties it to one particular implementation. // /// <summary> /// Represents an opaque Event Bookmark obtained from an EventRecord. /// The bookmark denotes a unique identifier for the event instance as /// well as marks the location in the result set of the EventReader /// that the event instance was obtained from. /// </summary> public class EventBookmark { internal EventBookmark(string bookmarkText!!) { BookmarkText = bookmarkText; } internal string BookmarkText { get; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Diagnostics.Eventing.Reader { // // NOTE: This class must be generic enough to be used across // eventing base implementations. Cannot add anything // that ties it to one particular implementation. // /// <summary> /// Represents an opaque Event Bookmark obtained from an EventRecord. /// The bookmark denotes a unique identifier for the event instance as /// well as marks the location in the result set of the EventReader /// that the event instance was obtained from. /// </summary> public class EventBookmark { internal EventBookmark(string bookmarkText!!) { BookmarkText = bookmarkText; } internal string BookmarkText { get; } } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/libraries/System.IO.Ports/tests/SerialStream/BeginWrite.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; using System.IO.PortsTests; using System.Text; using System.Threading; using Legacy.Support; using Xunit; namespace System.IO.Ports.Tests { public class SerialStream_BeginWrite : PortsTest { // The string size used for large byte array testing private const int LARGE_BUFFER_SIZE = 2048; // When we test Write and do not care about actually writing anything we must still // create an byte array to pass into the method the following is the size of the // byte array used in this situation private const int DEFAULT_BUFFER_SIZE = 1; private const int DEFAULT_BUFFER_OFFSET = 0; private const int DEFAULT_BUFFER_COUNT = 1; // The maximum buffer size when an exception occurs private const int MAX_BUFFER_SIZE_FOR_EXCEPTION = 255; // The maximum buffer size when an exception is not expected private const int MAX_BUFFER_SIZE = 8; // The default number of times the write method is called when verifying write private const int DEFAULT_NUM_WRITES = 3; // The default number of bytes to write private const int DEFAULT_NUM_BYTES_TO_WRITE = 128; // Maximum time to wait for processing the read command to complete private const int MAX_WAIT_WRITE_COMPLETE = 1000; #region Test Cases [ConditionalFact(nameof(HasOneSerialPort))] public void Buffer_Null() { VerifyWriteException(null, 0, 1, typeof(ArgumentNullException)); } [ConditionalFact(nameof(HasOneSerialPort))] public void Offset_NEG1() { VerifyWriteException(new byte[DEFAULT_BUFFER_SIZE], -1, DEFAULT_BUFFER_COUNT, typeof(ArgumentOutOfRangeException)); } [ConditionalFact(nameof(HasOneSerialPort))] public void Offset_NEGRND() { Random rndGen = new Random(-55); VerifyWriteException(new byte[DEFAULT_BUFFER_SIZE], rndGen.Next(int.MinValue, 0), DEFAULT_BUFFER_COUNT, typeof(ArgumentOutOfRangeException)); } [ConditionalFact(nameof(HasOneSerialPort))] public void Offset_MinInt() { VerifyWriteException(new byte[DEFAULT_BUFFER_SIZE], int.MinValue, DEFAULT_BUFFER_COUNT, typeof(ArgumentOutOfRangeException)); } [ConditionalFact(nameof(HasOneSerialPort))] public void Count_NEG1() { VerifyWriteException(new byte[DEFAULT_BUFFER_SIZE], DEFAULT_BUFFER_OFFSET, -1, typeof(ArgumentOutOfRangeException)); } [ConditionalFact(nameof(HasOneSerialPort))] public void Count_NEGRND() { Random rndGen = new Random(-55); VerifyWriteException(new byte[DEFAULT_BUFFER_SIZE], DEFAULT_BUFFER_OFFSET, rndGen.Next(int.MinValue, 0), typeof(ArgumentOutOfRangeException)); } [ConditionalFact(nameof(HasOneSerialPort))] public void Count_MinInt() { VerifyWriteException(new byte[DEFAULT_BUFFER_SIZE], DEFAULT_BUFFER_OFFSET, int.MinValue, typeof(ArgumentOutOfRangeException)); } [ConditionalFact(nameof(HasOneSerialPort))] public void OffsetCount_EQ_Length_Plus_1() { Random rndGen = new Random(-55); int bufferLength = rndGen.Next(1, MAX_BUFFER_SIZE_FOR_EXCEPTION); int offset = rndGen.Next(0, bufferLength); int count = bufferLength + 1 - offset; Type expectedException = typeof(ArgumentException); VerifyWriteException(new byte[bufferLength], offset, count, expectedException); } [ConditionalFact(nameof(HasOneSerialPort))] public void OffsetCount_GT_Length() { Random rndGen = new Random(-55); int bufferLength = rndGen.Next(1, MAX_BUFFER_SIZE_FOR_EXCEPTION); int offset = rndGen.Next(0, bufferLength); int count = rndGen.Next(bufferLength + 1 - offset, int.MaxValue); Type expectedException = typeof(ArgumentException); VerifyWriteException(new byte[bufferLength], offset, count, expectedException); } [ConditionalFact(nameof(HasOneSerialPort))] public void Offset_GT_Length() { Random rndGen = new Random(-55); int bufferLength = rndGen.Next(1, MAX_BUFFER_SIZE_FOR_EXCEPTION); int offset = rndGen.Next(bufferLength, int.MaxValue); int count = DEFAULT_BUFFER_COUNT; Type expectedException = typeof(ArgumentException); VerifyWriteException(new byte[bufferLength], offset, count, expectedException); } [ConditionalFact(nameof(HasOneSerialPort))] public void Count_GT_Length() { Random rndGen = new Random(-55); int bufferLength = rndGen.Next(1, MAX_BUFFER_SIZE_FOR_EXCEPTION); int offset = DEFAULT_BUFFER_OFFSET; int count = rndGen.Next(bufferLength + 1, int.MaxValue); Type expectedException = typeof(ArgumentException); VerifyWriteException(new byte[bufferLength], offset, count, expectedException); } [ConditionalFact(nameof(HasNullModem))] public void OffsetCount_EQ_Length() { Random rndGen = new Random(-55); int bufferLength = rndGen.Next(1, MAX_BUFFER_SIZE); int offset = rndGen.Next(0, bufferLength - 1); int count = bufferLength - offset; VerifyWrite(new byte[bufferLength], offset, count); } [ConditionalFact(nameof(HasNullModem))] public void Offset_EQ_Length_Minus_1() { Random rndGen = new Random(-55); int bufferLength = rndGen.Next(1, MAX_BUFFER_SIZE); int offset = bufferLength - 1; int count = 1; VerifyWrite(new byte[bufferLength], offset, count); } [ConditionalFact(nameof(HasNullModem))] public void Count_EQ_Length() { Random rndGen = new Random(-55); int bufferLength = rndGen.Next(1, MAX_BUFFER_SIZE); int offset = 0; int count = bufferLength; VerifyWrite(new byte[bufferLength], offset, count); } [ConditionalFact(nameof(HasNullModem))] public void ASCIIEncoding() { Random rndGen = new Random(-55); int bufferLength = rndGen.Next(1, MAX_BUFFER_SIZE); int offset = rndGen.Next(0, bufferLength - 1); int count = rndGen.Next(1, bufferLength - offset); VerifyWrite(new byte[bufferLength], offset, count, new ASCIIEncoding()); } [ConditionalFact(nameof(HasNullModem))] public void UTF8Encoding() { Random rndGen = new Random(-55); int bufferLength = rndGen.Next(1, MAX_BUFFER_SIZE); int offset = rndGen.Next(0, bufferLength - 1); int count = rndGen.Next(1, bufferLength - offset); VerifyWrite(new byte[bufferLength], offset, count, new UTF8Encoding()); } [ConditionalFact(nameof(HasNullModem))] public void UTF32Encoding() { Random rndGen = new Random(-55); int bufferLength = rndGen.Next(1, MAX_BUFFER_SIZE); int offset = rndGen.Next(0, bufferLength - 1); int count = rndGen.Next(1, bufferLength - offset); VerifyWrite(new byte[bufferLength], offset, count, new UTF32Encoding()); } [ConditionalFact(nameof(HasNullModem))] public void UnicodeEncoding() { Random rndGen = new Random(-55); int bufferLength = rndGen.Next(1, MAX_BUFFER_SIZE); int offset = rndGen.Next(0, bufferLength - 1); int count = rndGen.Next(1, bufferLength - offset); VerifyWrite(new byte[bufferLength], offset, count, new UnicodeEncoding()); } [ConditionalFact(nameof(HasNullModem), nameof(HasHardwareFlowControl))] public void LargeBuffer() { int bufferLength = LARGE_BUFFER_SIZE; int offset = 0; int count = bufferLength; VerifyWrite(new byte[bufferLength], offset, count, 1); } [ConditionalFact(nameof(HasNullModem))] public void Callback() { using (SerialPort com1 = new SerialPort(TCSupport.LocalMachineSerialInfo.FirstAvailablePortName)) using (SerialPort com2 = new SerialPort(TCSupport.LocalMachineSerialInfo.SecondAvailablePortName)) { CallbackHandler callbackHandler = new CallbackHandler(); Debug.WriteLine("Verifying BeginWrite with a callback specified"); com1.Handshake = Handshake.RequestToSend; com2.ReadTimeout = 300; com1.Open(); com2.Open(); // RTS allows us to control when driver sends the data but does not // guarantee that data will not be consumed by driver // we can check if data was received on the other side though Action read = () => { com2.BaseStream.Read(new byte[DEFAULT_NUM_BYTES_TO_WRITE], 0, DEFAULT_NUM_BYTES_TO_WRITE); }; IAsyncResult writeAsyncResult = com1.BaseStream.BeginWrite(new byte[DEFAULT_NUM_BYTES_TO_WRITE], 0, DEFAULT_NUM_BYTES_TO_WRITE, callbackHandler.Callback, this); callbackHandler.BeginWriteAysncResult = writeAsyncResult; Assert.Equal(this, writeAsyncResult.AsyncState); Thread.Sleep(100); Assert.Throws<TimeoutException>(read); com2.RtsEnable = true; read(); // callbackHandler.WriteAysncResult guarantees that the callback has been called however it does not gauarentee that // the code calling the callback has finished it's processing IAsyncResult callbackWriteAsyncResult = callbackHandler.WriteAysncResult; // No we have to wait for the callbackHandler to complete int elapsedTime = 0; while (!callbackWriteAsyncResult.IsCompleted && elapsedTime < MAX_WAIT_WRITE_COMPLETE) { Thread.Sleep(10); elapsedTime += 10; } Assert.Equal(this, callbackWriteAsyncResult.AsyncState); Assert.False(callbackWriteAsyncResult.CompletedSynchronously, "Should not have completed sync (cback)"); Assert.True(callbackWriteAsyncResult.IsCompleted, "Should have completed (cback)"); Assert.Equal(this, writeAsyncResult.AsyncState); Assert.False(writeAsyncResult.CompletedSynchronously, "Should not have completed sync (write)"); Assert.True(writeAsyncResult.IsCompleted, "Should have completed (write)"); } } [ConditionalFact(nameof(HasNullModem), nameof(HasHardwareFlowControl))] public void Callback_State() { using (SerialPort com1 = new SerialPort(TCSupport.LocalMachineSerialInfo.FirstAvailablePortName)) using (SerialPort com2 = new SerialPort(TCSupport.LocalMachineSerialInfo.SecondAvailablePortName)) { CallbackHandler callbackHandler = new CallbackHandler(); Debug.WriteLine("Verifying BeginWrite with a callback and state specified"); com1.Open(); com2.Open(); Action read = () => { com2.BaseStream.Read(new byte[DEFAULT_NUM_BYTES_TO_WRITE], 0, DEFAULT_NUM_BYTES_TO_WRITE); }; IAsyncResult writeAsyncResult = com1.BaseStream.BeginWrite(new byte[DEFAULT_NUM_BYTES_TO_WRITE], 0, DEFAULT_NUM_BYTES_TO_WRITE, callbackHandler.Callback, this); callbackHandler.BeginWriteAysncResult = writeAsyncResult; Assert.Throws<TimeoutException>(read); com2.RtsEnable = true; read(); // callbackHandler.WriteAysncResult guarantees that the callback has been called however it does not gauarentee that // the code calling the callback has finished it's processing IAsyncResult callbackWriteAsyncResult = callbackHandler.WriteAysncResult; // No we have to wait for the callbackHandler to complete int elapsedTime = 0; while (!callbackWriteAsyncResult.IsCompleted && elapsedTime < MAX_WAIT_WRITE_COMPLETE) { Thread.Sleep(10); elapsedTime += 10; } Assert.Equal(this, callbackWriteAsyncResult.AsyncState); Assert.False(writeAsyncResult.CompletedSynchronously, "Should not have completed sync (cback)"); Assert.True(callbackWriteAsyncResult.IsCompleted, "Should have completed (cback)"); Assert.Equal(this, writeAsyncResult.AsyncState); Assert.False(writeAsyncResult.CompletedSynchronously, "Should not have completed sync (write)"); Assert.True(writeAsyncResult.IsCompleted, "Should have completed (write)"); } } [ConditionalFact(nameof(HasOneSerialPort))] public void InBreak() { using (SerialPort com1 = new SerialPort(TCSupport.LocalMachineSerialInfo.FirstAvailablePortName)) { Debug.WriteLine("Verifying BeginWrite throws InvalidOperationException while in a Break"); com1.Open(); com1.BreakState = true; Assert.Throws<InvalidOperationException>(() => com1.BaseStream.BeginWrite(new byte[8], 0, 8, null, null)); } } #endregion #region Verification for Test Cases private void VerifyWriteException(byte[] buffer, int offset, int count, Type expectedException) { using (SerialPort com = new SerialPort(TCSupport.LocalMachineSerialInfo.FirstAvailablePortName)) { int bufferLength = null == buffer ? 0 : buffer.Length; Debug.WriteLine("Verifying write method throws {0} buffer.Lenght={1}, offset={2}, count={3}", expectedException, bufferLength, offset, count); com.Open(); Assert.Throws(expectedException, () => com.BaseStream.BeginWrite(buffer, offset, count, null, null)); } } private void VerifyWrite(byte[] buffer, int offset, int count) { VerifyWrite(buffer, offset, count, new ASCIIEncoding()); } private void VerifyWrite(byte[] buffer, int offset, int count, int numWrites) { VerifyWrite(buffer, offset, count, new ASCIIEncoding(), numWrites); } private void VerifyWrite(byte[] buffer, int offset, int count, Encoding encoding) { VerifyWrite(buffer, offset, count, encoding, DEFAULT_NUM_WRITES); } private void VerifyWrite(byte[] buffer, int offset, int count, Encoding encoding, int numWrites) { using (SerialPort com1 = new SerialPort(TCSupport.LocalMachineSerialInfo.FirstAvailablePortName)) using (SerialPort com2 = new SerialPort(TCSupport.LocalMachineSerialInfo.SecondAvailablePortName)) { Random rndGen = new Random(-55); Debug.WriteLine("Verifying write method buffer.Lenght={0}, offset={1}, count={2}, endocing={3}", buffer.Length, offset, count, encoding.EncodingName); com1.Encoding = encoding; com2.Encoding = encoding; com1.Open(); com2.Open(); for (int i = 0; i < buffer.Length; i++) { buffer[i] = (byte)rndGen.Next(0, 256); } VerifyWriteByteArray(buffer, offset, count, com1, com2, numWrites); } } private void VerifyWriteByteArray(byte[] buffer, int offset, int count, SerialPort com1, SerialPort com2, int numWrites) { int index = 0; CallbackHandler callbackHandler = new CallbackHandler(); var oldBuffer = (byte[])buffer.Clone(); var expectedBytes = new byte[count]; var actualBytes = new byte[expectedBytes.Length * numWrites]; for (int i = 0; i < count; i++) { expectedBytes[i] = buffer[i + offset]; } for (int i = 0; i < numWrites; i++) { IAsyncResult writeAsyncResult = com1.BaseStream.BeginWrite(buffer, offset, count, callbackHandler.Callback, this); com1.BaseStream.EndWrite(writeAsyncResult); callbackHandler.BeginWriteAysncResult = writeAsyncResult; IAsyncResult callbackWriteAsyncResult = callbackHandler.WriteAysncResult; Assert.Equal(this, callbackWriteAsyncResult.AsyncState); Assert.False(callbackWriteAsyncResult.CompletedSynchronously, "Should not have completed sync (cback)"); Assert.True(callbackWriteAsyncResult.IsCompleted, "Should have completed (cback)"); Assert.Equal(this, writeAsyncResult.AsyncState); Assert.False(writeAsyncResult.CompletedSynchronously, "Should not have completed sync (write)"); Assert.True(writeAsyncResult.IsCompleted, "Should have completed (write)"); } com2.ReadTimeout = 500; Thread.Sleep((int)(((expectedBytes.Length * numWrites * 10.0) / com1.BaudRate) * 1000) + 250); // Make sure buffer was not altered during the write call for (int i = 0; i < buffer.Length; i++) { if (buffer[i] != oldBuffer[i]) { Fail("ERROR!!!: The contents of the buffer were changed from {0} to {1} at {2}", oldBuffer[i], buffer[i], i); } } while (true) { int byteRead; try { byteRead = com2.ReadByte(); } catch (TimeoutException) { break; } if (actualBytes.Length <= index) { // If we have read in more bytes then we expect Fail("ERROR!!!: We have received more bytes then were sent"); break; } actualBytes[index] = (byte)byteRead; index++; if (actualBytes.Length - index != com2.BytesToRead) { Fail("ERROR!!!: Expected BytesToRead={0} actual={1}", actualBytes.Length - index, com2.BytesToRead); } } // Compare the bytes that were read with the ones we expected to read for (int j = 0; j < numWrites; j++) { for (int i = 0; i < expectedBytes.Length; i++) { if (expectedBytes[i] != actualBytes[i + expectedBytes.Length * j]) { Fail("ERROR!!!: Expected to read byte {0} actual read {1} at {2}", (int)expectedBytes[i], (int)actualBytes[i + expectedBytes.Length * j], i); } } } } private class CallbackHandler { private IAsyncResult _writeAysncResult; private IAsyncResult _beginWriteAysncResult; private readonly SerialPort _com; public CallbackHandler() : this(null) { } private CallbackHandler(SerialPort com) { _com = com; } public void Callback(IAsyncResult writeAysncResult) { Debug.WriteLine("About to enter callback lock (already entered {0})", Monitor.IsEntered(this)); lock (this) { Debug.WriteLine("Inside callback lock"); _writeAysncResult = writeAysncResult; if (!writeAysncResult.IsCompleted) { throw new Exception("Err_23984afaea Expected IAsyncResult passed into callback to not be completed"); } while (null == _beginWriteAysncResult) { Assert.True(Monitor.Wait(this, 5000), "Monitor.Wait in Callback"); } if (null != _beginWriteAysncResult && !_beginWriteAysncResult.IsCompleted) { throw new Exception("Err_7907azpu Expected IAsyncResult returned from begin write to not be completed"); } if (null != _com) { _com.BaseStream.EndWrite(_beginWriteAysncResult); if (!_beginWriteAysncResult.IsCompleted) { throw new Exception("Err_6498afead Expected IAsyncResult returned from begin write to not be completed"); } if (!writeAysncResult.IsCompleted) { throw new Exception("Err_1398ehpo Expected IAsyncResult passed into callback to not be completed"); } } Monitor.Pulse(this); } } public IAsyncResult WriteAysncResult { get { lock (this) { while (null == _writeAysncResult) { Monitor.Wait(this); } return _writeAysncResult; } } } public IAsyncResult BeginWriteAysncResult { get { return _beginWriteAysncResult; } set { lock (this) { _beginWriteAysncResult = value; Monitor.Pulse(this); } } } } #endregion } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; using System.IO.PortsTests; using System.Text; using System.Threading; using Legacy.Support; using Xunit; namespace System.IO.Ports.Tests { public class SerialStream_BeginWrite : PortsTest { // The string size used for large byte array testing private const int LARGE_BUFFER_SIZE = 2048; // When we test Write and do not care about actually writing anything we must still // create an byte array to pass into the method the following is the size of the // byte array used in this situation private const int DEFAULT_BUFFER_SIZE = 1; private const int DEFAULT_BUFFER_OFFSET = 0; private const int DEFAULT_BUFFER_COUNT = 1; // The maximum buffer size when an exception occurs private const int MAX_BUFFER_SIZE_FOR_EXCEPTION = 255; // The maximum buffer size when an exception is not expected private const int MAX_BUFFER_SIZE = 8; // The default number of times the write method is called when verifying write private const int DEFAULT_NUM_WRITES = 3; // The default number of bytes to write private const int DEFAULT_NUM_BYTES_TO_WRITE = 128; // Maximum time to wait for processing the read command to complete private const int MAX_WAIT_WRITE_COMPLETE = 1000; #region Test Cases [ConditionalFact(nameof(HasOneSerialPort))] public void Buffer_Null() { VerifyWriteException(null, 0, 1, typeof(ArgumentNullException)); } [ConditionalFact(nameof(HasOneSerialPort))] public void Offset_NEG1() { VerifyWriteException(new byte[DEFAULT_BUFFER_SIZE], -1, DEFAULT_BUFFER_COUNT, typeof(ArgumentOutOfRangeException)); } [ConditionalFact(nameof(HasOneSerialPort))] public void Offset_NEGRND() { Random rndGen = new Random(-55); VerifyWriteException(new byte[DEFAULT_BUFFER_SIZE], rndGen.Next(int.MinValue, 0), DEFAULT_BUFFER_COUNT, typeof(ArgumentOutOfRangeException)); } [ConditionalFact(nameof(HasOneSerialPort))] public void Offset_MinInt() { VerifyWriteException(new byte[DEFAULT_BUFFER_SIZE], int.MinValue, DEFAULT_BUFFER_COUNT, typeof(ArgumentOutOfRangeException)); } [ConditionalFact(nameof(HasOneSerialPort))] public void Count_NEG1() { VerifyWriteException(new byte[DEFAULT_BUFFER_SIZE], DEFAULT_BUFFER_OFFSET, -1, typeof(ArgumentOutOfRangeException)); } [ConditionalFact(nameof(HasOneSerialPort))] public void Count_NEGRND() { Random rndGen = new Random(-55); VerifyWriteException(new byte[DEFAULT_BUFFER_SIZE], DEFAULT_BUFFER_OFFSET, rndGen.Next(int.MinValue, 0), typeof(ArgumentOutOfRangeException)); } [ConditionalFact(nameof(HasOneSerialPort))] public void Count_MinInt() { VerifyWriteException(new byte[DEFAULT_BUFFER_SIZE], DEFAULT_BUFFER_OFFSET, int.MinValue, typeof(ArgumentOutOfRangeException)); } [ConditionalFact(nameof(HasOneSerialPort))] public void OffsetCount_EQ_Length_Plus_1() { Random rndGen = new Random(-55); int bufferLength = rndGen.Next(1, MAX_BUFFER_SIZE_FOR_EXCEPTION); int offset = rndGen.Next(0, bufferLength); int count = bufferLength + 1 - offset; Type expectedException = typeof(ArgumentException); VerifyWriteException(new byte[bufferLength], offset, count, expectedException); } [ConditionalFact(nameof(HasOneSerialPort))] public void OffsetCount_GT_Length() { Random rndGen = new Random(-55); int bufferLength = rndGen.Next(1, MAX_BUFFER_SIZE_FOR_EXCEPTION); int offset = rndGen.Next(0, bufferLength); int count = rndGen.Next(bufferLength + 1 - offset, int.MaxValue); Type expectedException = typeof(ArgumentException); VerifyWriteException(new byte[bufferLength], offset, count, expectedException); } [ConditionalFact(nameof(HasOneSerialPort))] public void Offset_GT_Length() { Random rndGen = new Random(-55); int bufferLength = rndGen.Next(1, MAX_BUFFER_SIZE_FOR_EXCEPTION); int offset = rndGen.Next(bufferLength, int.MaxValue); int count = DEFAULT_BUFFER_COUNT; Type expectedException = typeof(ArgumentException); VerifyWriteException(new byte[bufferLength], offset, count, expectedException); } [ConditionalFact(nameof(HasOneSerialPort))] public void Count_GT_Length() { Random rndGen = new Random(-55); int bufferLength = rndGen.Next(1, MAX_BUFFER_SIZE_FOR_EXCEPTION); int offset = DEFAULT_BUFFER_OFFSET; int count = rndGen.Next(bufferLength + 1, int.MaxValue); Type expectedException = typeof(ArgumentException); VerifyWriteException(new byte[bufferLength], offset, count, expectedException); } [ConditionalFact(nameof(HasNullModem))] public void OffsetCount_EQ_Length() { Random rndGen = new Random(-55); int bufferLength = rndGen.Next(1, MAX_BUFFER_SIZE); int offset = rndGen.Next(0, bufferLength - 1); int count = bufferLength - offset; VerifyWrite(new byte[bufferLength], offset, count); } [ConditionalFact(nameof(HasNullModem))] public void Offset_EQ_Length_Minus_1() { Random rndGen = new Random(-55); int bufferLength = rndGen.Next(1, MAX_BUFFER_SIZE); int offset = bufferLength - 1; int count = 1; VerifyWrite(new byte[bufferLength], offset, count); } [ConditionalFact(nameof(HasNullModem))] public void Count_EQ_Length() { Random rndGen = new Random(-55); int bufferLength = rndGen.Next(1, MAX_BUFFER_SIZE); int offset = 0; int count = bufferLength; VerifyWrite(new byte[bufferLength], offset, count); } [ConditionalFact(nameof(HasNullModem))] public void ASCIIEncoding() { Random rndGen = new Random(-55); int bufferLength = rndGen.Next(1, MAX_BUFFER_SIZE); int offset = rndGen.Next(0, bufferLength - 1); int count = rndGen.Next(1, bufferLength - offset); VerifyWrite(new byte[bufferLength], offset, count, new ASCIIEncoding()); } [ConditionalFact(nameof(HasNullModem))] public void UTF8Encoding() { Random rndGen = new Random(-55); int bufferLength = rndGen.Next(1, MAX_BUFFER_SIZE); int offset = rndGen.Next(0, bufferLength - 1); int count = rndGen.Next(1, bufferLength - offset); VerifyWrite(new byte[bufferLength], offset, count, new UTF8Encoding()); } [ConditionalFact(nameof(HasNullModem))] public void UTF32Encoding() { Random rndGen = new Random(-55); int bufferLength = rndGen.Next(1, MAX_BUFFER_SIZE); int offset = rndGen.Next(0, bufferLength - 1); int count = rndGen.Next(1, bufferLength - offset); VerifyWrite(new byte[bufferLength], offset, count, new UTF32Encoding()); } [ConditionalFact(nameof(HasNullModem))] public void UnicodeEncoding() { Random rndGen = new Random(-55); int bufferLength = rndGen.Next(1, MAX_BUFFER_SIZE); int offset = rndGen.Next(0, bufferLength - 1); int count = rndGen.Next(1, bufferLength - offset); VerifyWrite(new byte[bufferLength], offset, count, new UnicodeEncoding()); } [ConditionalFact(nameof(HasNullModem), nameof(HasHardwareFlowControl))] public void LargeBuffer() { int bufferLength = LARGE_BUFFER_SIZE; int offset = 0; int count = bufferLength; VerifyWrite(new byte[bufferLength], offset, count, 1); } [ConditionalFact(nameof(HasNullModem))] public void Callback() { using (SerialPort com1 = new SerialPort(TCSupport.LocalMachineSerialInfo.FirstAvailablePortName)) using (SerialPort com2 = new SerialPort(TCSupport.LocalMachineSerialInfo.SecondAvailablePortName)) { CallbackHandler callbackHandler = new CallbackHandler(); Debug.WriteLine("Verifying BeginWrite with a callback specified"); com1.Handshake = Handshake.RequestToSend; com2.ReadTimeout = 300; com1.Open(); com2.Open(); // RTS allows us to control when driver sends the data but does not // guarantee that data will not be consumed by driver // we can check if data was received on the other side though Action read = () => { com2.BaseStream.Read(new byte[DEFAULT_NUM_BYTES_TO_WRITE], 0, DEFAULT_NUM_BYTES_TO_WRITE); }; IAsyncResult writeAsyncResult = com1.BaseStream.BeginWrite(new byte[DEFAULT_NUM_BYTES_TO_WRITE], 0, DEFAULT_NUM_BYTES_TO_WRITE, callbackHandler.Callback, this); callbackHandler.BeginWriteAysncResult = writeAsyncResult; Assert.Equal(this, writeAsyncResult.AsyncState); Thread.Sleep(100); Assert.Throws<TimeoutException>(read); com2.RtsEnable = true; read(); // callbackHandler.WriteAysncResult guarantees that the callback has been called however it does not gauarentee that // the code calling the callback has finished it's processing IAsyncResult callbackWriteAsyncResult = callbackHandler.WriteAysncResult; // No we have to wait for the callbackHandler to complete int elapsedTime = 0; while (!callbackWriteAsyncResult.IsCompleted && elapsedTime < MAX_WAIT_WRITE_COMPLETE) { Thread.Sleep(10); elapsedTime += 10; } Assert.Equal(this, callbackWriteAsyncResult.AsyncState); Assert.False(callbackWriteAsyncResult.CompletedSynchronously, "Should not have completed sync (cback)"); Assert.True(callbackWriteAsyncResult.IsCompleted, "Should have completed (cback)"); Assert.Equal(this, writeAsyncResult.AsyncState); Assert.False(writeAsyncResult.CompletedSynchronously, "Should not have completed sync (write)"); Assert.True(writeAsyncResult.IsCompleted, "Should have completed (write)"); } } [ConditionalFact(nameof(HasNullModem), nameof(HasHardwareFlowControl))] public void Callback_State() { using (SerialPort com1 = new SerialPort(TCSupport.LocalMachineSerialInfo.FirstAvailablePortName)) using (SerialPort com2 = new SerialPort(TCSupport.LocalMachineSerialInfo.SecondAvailablePortName)) { CallbackHandler callbackHandler = new CallbackHandler(); Debug.WriteLine("Verifying BeginWrite with a callback and state specified"); com1.Open(); com2.Open(); Action read = () => { com2.BaseStream.Read(new byte[DEFAULT_NUM_BYTES_TO_WRITE], 0, DEFAULT_NUM_BYTES_TO_WRITE); }; IAsyncResult writeAsyncResult = com1.BaseStream.BeginWrite(new byte[DEFAULT_NUM_BYTES_TO_WRITE], 0, DEFAULT_NUM_BYTES_TO_WRITE, callbackHandler.Callback, this); callbackHandler.BeginWriteAysncResult = writeAsyncResult; Assert.Throws<TimeoutException>(read); com2.RtsEnable = true; read(); // callbackHandler.WriteAysncResult guarantees that the callback has been called however it does not gauarentee that // the code calling the callback has finished it's processing IAsyncResult callbackWriteAsyncResult = callbackHandler.WriteAysncResult; // No we have to wait for the callbackHandler to complete int elapsedTime = 0; while (!callbackWriteAsyncResult.IsCompleted && elapsedTime < MAX_WAIT_WRITE_COMPLETE) { Thread.Sleep(10); elapsedTime += 10; } Assert.Equal(this, callbackWriteAsyncResult.AsyncState); Assert.False(writeAsyncResult.CompletedSynchronously, "Should not have completed sync (cback)"); Assert.True(callbackWriteAsyncResult.IsCompleted, "Should have completed (cback)"); Assert.Equal(this, writeAsyncResult.AsyncState); Assert.False(writeAsyncResult.CompletedSynchronously, "Should not have completed sync (write)"); Assert.True(writeAsyncResult.IsCompleted, "Should have completed (write)"); } } [ConditionalFact(nameof(HasOneSerialPort))] public void InBreak() { using (SerialPort com1 = new SerialPort(TCSupport.LocalMachineSerialInfo.FirstAvailablePortName)) { Debug.WriteLine("Verifying BeginWrite throws InvalidOperationException while in a Break"); com1.Open(); com1.BreakState = true; Assert.Throws<InvalidOperationException>(() => com1.BaseStream.BeginWrite(new byte[8], 0, 8, null, null)); } } #endregion #region Verification for Test Cases private void VerifyWriteException(byte[] buffer, int offset, int count, Type expectedException) { using (SerialPort com = new SerialPort(TCSupport.LocalMachineSerialInfo.FirstAvailablePortName)) { int bufferLength = null == buffer ? 0 : buffer.Length; Debug.WriteLine("Verifying write method throws {0} buffer.Lenght={1}, offset={2}, count={3}", expectedException, bufferLength, offset, count); com.Open(); Assert.Throws(expectedException, () => com.BaseStream.BeginWrite(buffer, offset, count, null, null)); } } private void VerifyWrite(byte[] buffer, int offset, int count) { VerifyWrite(buffer, offset, count, new ASCIIEncoding()); } private void VerifyWrite(byte[] buffer, int offset, int count, int numWrites) { VerifyWrite(buffer, offset, count, new ASCIIEncoding(), numWrites); } private void VerifyWrite(byte[] buffer, int offset, int count, Encoding encoding) { VerifyWrite(buffer, offset, count, encoding, DEFAULT_NUM_WRITES); } private void VerifyWrite(byte[] buffer, int offset, int count, Encoding encoding, int numWrites) { using (SerialPort com1 = new SerialPort(TCSupport.LocalMachineSerialInfo.FirstAvailablePortName)) using (SerialPort com2 = new SerialPort(TCSupport.LocalMachineSerialInfo.SecondAvailablePortName)) { Random rndGen = new Random(-55); Debug.WriteLine("Verifying write method buffer.Lenght={0}, offset={1}, count={2}, endocing={3}", buffer.Length, offset, count, encoding.EncodingName); com1.Encoding = encoding; com2.Encoding = encoding; com1.Open(); com2.Open(); for (int i = 0; i < buffer.Length; i++) { buffer[i] = (byte)rndGen.Next(0, 256); } VerifyWriteByteArray(buffer, offset, count, com1, com2, numWrites); } } private void VerifyWriteByteArray(byte[] buffer, int offset, int count, SerialPort com1, SerialPort com2, int numWrites) { int index = 0; CallbackHandler callbackHandler = new CallbackHandler(); var oldBuffer = (byte[])buffer.Clone(); var expectedBytes = new byte[count]; var actualBytes = new byte[expectedBytes.Length * numWrites]; for (int i = 0; i < count; i++) { expectedBytes[i] = buffer[i + offset]; } for (int i = 0; i < numWrites; i++) { IAsyncResult writeAsyncResult = com1.BaseStream.BeginWrite(buffer, offset, count, callbackHandler.Callback, this); com1.BaseStream.EndWrite(writeAsyncResult); callbackHandler.BeginWriteAysncResult = writeAsyncResult; IAsyncResult callbackWriteAsyncResult = callbackHandler.WriteAysncResult; Assert.Equal(this, callbackWriteAsyncResult.AsyncState); Assert.False(callbackWriteAsyncResult.CompletedSynchronously, "Should not have completed sync (cback)"); Assert.True(callbackWriteAsyncResult.IsCompleted, "Should have completed (cback)"); Assert.Equal(this, writeAsyncResult.AsyncState); Assert.False(writeAsyncResult.CompletedSynchronously, "Should not have completed sync (write)"); Assert.True(writeAsyncResult.IsCompleted, "Should have completed (write)"); } com2.ReadTimeout = 500; Thread.Sleep((int)(((expectedBytes.Length * numWrites * 10.0) / com1.BaudRate) * 1000) + 250); // Make sure buffer was not altered during the write call for (int i = 0; i < buffer.Length; i++) { if (buffer[i] != oldBuffer[i]) { Fail("ERROR!!!: The contents of the buffer were changed from {0} to {1} at {2}", oldBuffer[i], buffer[i], i); } } while (true) { int byteRead; try { byteRead = com2.ReadByte(); } catch (TimeoutException) { break; } if (actualBytes.Length <= index) { // If we have read in more bytes then we expect Fail("ERROR!!!: We have received more bytes then were sent"); break; } actualBytes[index] = (byte)byteRead; index++; if (actualBytes.Length - index != com2.BytesToRead) { Fail("ERROR!!!: Expected BytesToRead={0} actual={1}", actualBytes.Length - index, com2.BytesToRead); } } // Compare the bytes that were read with the ones we expected to read for (int j = 0; j < numWrites; j++) { for (int i = 0; i < expectedBytes.Length; i++) { if (expectedBytes[i] != actualBytes[i + expectedBytes.Length * j]) { Fail("ERROR!!!: Expected to read byte {0} actual read {1} at {2}", (int)expectedBytes[i], (int)actualBytes[i + expectedBytes.Length * j], i); } } } } private class CallbackHandler { private IAsyncResult _writeAysncResult; private IAsyncResult _beginWriteAysncResult; private readonly SerialPort _com; public CallbackHandler() : this(null) { } private CallbackHandler(SerialPort com) { _com = com; } public void Callback(IAsyncResult writeAysncResult) { Debug.WriteLine("About to enter callback lock (already entered {0})", Monitor.IsEntered(this)); lock (this) { Debug.WriteLine("Inside callback lock"); _writeAysncResult = writeAysncResult; if (!writeAysncResult.IsCompleted) { throw new Exception("Err_23984afaea Expected IAsyncResult passed into callback to not be completed"); } while (null == _beginWriteAysncResult) { Assert.True(Monitor.Wait(this, 5000), "Monitor.Wait in Callback"); } if (null != _beginWriteAysncResult && !_beginWriteAysncResult.IsCompleted) { throw new Exception("Err_7907azpu Expected IAsyncResult returned from begin write to not be completed"); } if (null != _com) { _com.BaseStream.EndWrite(_beginWriteAysncResult); if (!_beginWriteAysncResult.IsCompleted) { throw new Exception("Err_6498afead Expected IAsyncResult returned from begin write to not be completed"); } if (!writeAysncResult.IsCompleted) { throw new Exception("Err_1398ehpo Expected IAsyncResult passed into callback to not be completed"); } } Monitor.Pulse(this); } } public IAsyncResult WriteAysncResult { get { lock (this) { while (null == _writeAysncResult) { Monitor.Wait(this); } return _writeAysncResult; } } } public IAsyncResult BeginWriteAysncResult { get { return _beginWriteAysncResult; } set { lock (this) { _beginWriteAysncResult = value; Monitor.Pulse(this); } } } } #endregion } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd.Arm64/CompareGreaterThanOrEqualScalar.Vector64.UInt64.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void CompareGreaterThanOrEqualScalar_Vector64_UInt64() { var test = new SimpleBinaryOpTest__CompareGreaterThanOrEqualScalar_Vector64_UInt64(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanOrEqualScalar_Vector64_UInt64 { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(UInt64[] inArray1, UInt64[] inArray2, UInt64[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<UInt64>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<UInt64>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<UInt64>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<UInt64, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<UInt64, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector64<UInt64> _fld1; public Vector64<UInt64> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref testStruct._fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref testStruct._fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__CompareGreaterThanOrEqualScalar_Vector64_UInt64 testClass) { var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__CompareGreaterThanOrEqualScalar_Vector64_UInt64 testClass) { fixed (Vector64<UInt64>* pFld1 = &_fld1) fixed (Vector64<UInt64>* pFld2 = &_fld2) { var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar( AdvSimd.LoadVector64((UInt64*)(pFld1)), AdvSimd.LoadVector64((UInt64*)(pFld2)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 8; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector64<UInt64>>() / sizeof(UInt64); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector64<UInt64>>() / sizeof(UInt64); private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<UInt64>>() / sizeof(UInt64); private static UInt64[] _data1 = new UInt64[Op1ElementCount]; private static UInt64[] _data2 = new UInt64[Op2ElementCount]; private static Vector64<UInt64> _clsVar1; private static Vector64<UInt64> _clsVar2; private Vector64<UInt64> _fld1; private Vector64<UInt64> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__CompareGreaterThanOrEqualScalar_Vector64_UInt64() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); } public SimpleBinaryOpTest__CompareGreaterThanOrEqualScalar_Vector64_UInt64() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } _dataTable = new DataTable(_data1, _data2, new UInt64[RetElementCount], LargestVectorSize); } public bool IsSupported => AdvSimd.Arm64.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar( Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar( AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(AdvSimd.Arm64).GetMethod(nameof(AdvSimd.Arm64.CompareGreaterThanOrEqualScalar), new Type[] { typeof(Vector64<UInt64>), typeof(Vector64<UInt64>) }) .Invoke(null, new object[] { Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<UInt64>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd.Arm64).GetMethod(nameof(AdvSimd.Arm64.CompareGreaterThanOrEqualScalar), new Type[] { typeof(Vector64<UInt64>), typeof(Vector64<UInt64>) }) .Invoke(null, new object[] { AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<UInt64>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector64<UInt64>* pClsVar1 = &_clsVar1) fixed (Vector64<UInt64>* pClsVar2 = &_clsVar2) { var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar( AdvSimd.LoadVector64((UInt64*)(pClsVar1)), AdvSimd.LoadVector64((UInt64*)(pClsVar2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray2Ptr); var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray2Ptr)); var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__CompareGreaterThanOrEqualScalar_Vector64_UInt64(); var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleBinaryOpTest__CompareGreaterThanOrEqualScalar_Vector64_UInt64(); fixed (Vector64<UInt64>* pFld1 = &test._fld1) fixed (Vector64<UInt64>* pFld2 = &test._fld2) { var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar( AdvSimd.LoadVector64((UInt64*)(pFld1)), AdvSimd.LoadVector64((UInt64*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector64<UInt64>* pFld1 = &_fld1) fixed (Vector64<UInt64>* pFld2 = &_fld2) { var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar( AdvSimd.LoadVector64((UInt64*)(pFld1)), AdvSimd.LoadVector64((UInt64*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar( AdvSimd.LoadVector64((UInt64*)(&test._fld1)), AdvSimd.LoadVector64((UInt64*)(&test._fld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector64<UInt64> op1, Vector64<UInt64> op2, void* result, [CallerMemberName] string method = "") { UInt64[] inArray1 = new UInt64[Op1ElementCount]; UInt64[] inArray2 = new UInt64[Op2ElementCount]; UInt64[] outArray = new UInt64[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { UInt64[] inArray1 = new UInt64[Op1ElementCount]; UInt64[] inArray2 = new UInt64[Op2ElementCount]; UInt64[] outArray = new UInt64[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(UInt64[] left, UInt64[] right, UInt64[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (Helpers.CompareGreaterThanOrEqual(left[0], right[0]) != result[0]) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (result[i] != 0) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd.Arm64)}.{nameof(AdvSimd.Arm64.CompareGreaterThanOrEqualScalar)}<UInt64>(Vector64<UInt64>, Vector64<UInt64>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void CompareGreaterThanOrEqualScalar_Vector64_UInt64() { var test = new SimpleBinaryOpTest__CompareGreaterThanOrEqualScalar_Vector64_UInt64(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanOrEqualScalar_Vector64_UInt64 { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(UInt64[] inArray1, UInt64[] inArray2, UInt64[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<UInt64>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<UInt64>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<UInt64>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<UInt64, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<UInt64, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector64<UInt64> _fld1; public Vector64<UInt64> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref testStruct._fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref testStruct._fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__CompareGreaterThanOrEqualScalar_Vector64_UInt64 testClass) { var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__CompareGreaterThanOrEqualScalar_Vector64_UInt64 testClass) { fixed (Vector64<UInt64>* pFld1 = &_fld1) fixed (Vector64<UInt64>* pFld2 = &_fld2) { var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar( AdvSimd.LoadVector64((UInt64*)(pFld1)), AdvSimd.LoadVector64((UInt64*)(pFld2)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 8; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector64<UInt64>>() / sizeof(UInt64); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector64<UInt64>>() / sizeof(UInt64); private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<UInt64>>() / sizeof(UInt64); private static UInt64[] _data1 = new UInt64[Op1ElementCount]; private static UInt64[] _data2 = new UInt64[Op2ElementCount]; private static Vector64<UInt64> _clsVar1; private static Vector64<UInt64> _clsVar2; private Vector64<UInt64> _fld1; private Vector64<UInt64> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__CompareGreaterThanOrEqualScalar_Vector64_UInt64() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); } public SimpleBinaryOpTest__CompareGreaterThanOrEqualScalar_Vector64_UInt64() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } _dataTable = new DataTable(_data1, _data2, new UInt64[RetElementCount], LargestVectorSize); } public bool IsSupported => AdvSimd.Arm64.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar( Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar( AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(AdvSimd.Arm64).GetMethod(nameof(AdvSimd.Arm64.CompareGreaterThanOrEqualScalar), new Type[] { typeof(Vector64<UInt64>), typeof(Vector64<UInt64>) }) .Invoke(null, new object[] { Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<UInt64>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd.Arm64).GetMethod(nameof(AdvSimd.Arm64.CompareGreaterThanOrEqualScalar), new Type[] { typeof(Vector64<UInt64>), typeof(Vector64<UInt64>) }) .Invoke(null, new object[] { AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<UInt64>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector64<UInt64>* pClsVar1 = &_clsVar1) fixed (Vector64<UInt64>* pClsVar2 = &_clsVar2) { var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar( AdvSimd.LoadVector64((UInt64*)(pClsVar1)), AdvSimd.LoadVector64((UInt64*)(pClsVar2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray2Ptr); var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray2Ptr)); var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__CompareGreaterThanOrEqualScalar_Vector64_UInt64(); var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleBinaryOpTest__CompareGreaterThanOrEqualScalar_Vector64_UInt64(); fixed (Vector64<UInt64>* pFld1 = &test._fld1) fixed (Vector64<UInt64>* pFld2 = &test._fld2) { var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar( AdvSimd.LoadVector64((UInt64*)(pFld1)), AdvSimd.LoadVector64((UInt64*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector64<UInt64>* pFld1 = &_fld1) fixed (Vector64<UInt64>* pFld2 = &_fld2) { var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar( AdvSimd.LoadVector64((UInt64*)(pFld1)), AdvSimd.LoadVector64((UInt64*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = AdvSimd.Arm64.CompareGreaterThanOrEqualScalar( AdvSimd.LoadVector64((UInt64*)(&test._fld1)), AdvSimd.LoadVector64((UInt64*)(&test._fld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector64<UInt64> op1, Vector64<UInt64> op2, void* result, [CallerMemberName] string method = "") { UInt64[] inArray1 = new UInt64[Op1ElementCount]; UInt64[] inArray2 = new UInt64[Op2ElementCount]; UInt64[] outArray = new UInt64[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { UInt64[] inArray1 = new UInt64[Op1ElementCount]; UInt64[] inArray2 = new UInt64[Op2ElementCount]; UInt64[] outArray = new UInt64[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(UInt64[] left, UInt64[] right, UInt64[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (Helpers.CompareGreaterThanOrEqual(left[0], right[0]) != result[0]) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (result[i] != 0) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd.Arm64)}.{nameof(AdvSimd.Arm64.CompareGreaterThanOrEqualScalar)}<UInt64>(Vector64<UInt64>, Vector64<UInt64>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/tests/JIT/Regression/JitBlue/GitHub_11814/GitHub_11814.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType /> <Optimize>True</Optimize> <AllowUnsafeBlocks>True</AllowUnsafeBlocks> </PropertyGroup> <ItemGroup> <Compile Include="$(MSBuildProjectName).cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType /> <Optimize>True</Optimize> <AllowUnsafeBlocks>True</AllowUnsafeBlocks> </PropertyGroup> <ItemGroup> <Compile Include="$(MSBuildProjectName).cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/tests/JIT/jit64/mcc/interop/native_i8c.cpp
// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. #include <stdarg.h> #include "native.h" MCC_API VType8 sum(double count1, int count2, __int64 count3, float count4, short count5, double count6, ...) { int count = (int)count1 + (int)count2 + (int)count3 + (int)count4 + (int)count5 + (int)count6; VType8 res; va_list args; // zero out res res.reset(); // initialize variable arguments. va_start(args, count6); for (int i = 0; i < count; ++i) { VType8 val = va_arg(args, VType8); res.add(val); } // reset variable arguments. va_end(args); return res; }
// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. #include <stdarg.h> #include "native.h" MCC_API VType8 sum(double count1, int count2, __int64 count3, float count4, short count5, double count6, ...) { int count = (int)count1 + (int)count2 + (int)count3 + (int)count4 + (int)count5 + (int)count6; VType8 res; va_list args; // zero out res res.reset(); // initialize variable arguments. va_start(args, count6); for (int i = 0; i < count; ++i) { VType8 val = va_arg(args, VType8); res.add(val); } // reset variable arguments. va_end(args); return res; }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonPropertyInfo.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Reflection; namespace System.Text.Json.Serialization.Metadata { /// <summary> /// Provides JSON serialization-related metadata about a property or field. /// </summary> [DebuggerDisplay("{DebuggerDisplay,nq}")] [EditorBrowsable(EditorBrowsableState.Never)] public abstract class JsonPropertyInfo { internal static readonly JsonPropertyInfo s_missingProperty = GetPropertyPlaceholder(); private JsonTypeInfo? _jsonTypeInfo; internal ConverterStrategy ConverterStrategy; internal abstract JsonConverter ConverterBase { get; set; } internal JsonPropertyInfo() { } internal static JsonPropertyInfo GetPropertyPlaceholder() { JsonPropertyInfo info = new JsonPropertyInfo<object>(); Debug.Assert(!info.IsForTypeInfo); Debug.Assert(!info.ShouldDeserialize); Debug.Assert(!info.ShouldSerialize); info.NameAsString = string.Empty; return info; } // Create a property that is ignored at run-time. internal static JsonPropertyInfo CreateIgnoredPropertyPlaceholder( MemberInfo memberInfo, Type memberType, bool isVirtual, JsonSerializerOptions options) { JsonPropertyInfo jsonPropertyInfo = new JsonPropertyInfo<sbyte>(); jsonPropertyInfo.Options = options; jsonPropertyInfo.MemberInfo = memberInfo; jsonPropertyInfo.IsIgnored = true; jsonPropertyInfo.PropertyType = memberType; jsonPropertyInfo.IsVirtual = isVirtual; jsonPropertyInfo.DeterminePropertyName(); Debug.Assert(!jsonPropertyInfo.ShouldDeserialize); Debug.Assert(!jsonPropertyInfo.ShouldSerialize); return jsonPropertyInfo; } internal Type PropertyType { get; set; } = null!; internal virtual void GetPolicies(JsonIgnoreCondition? ignoreCondition, JsonNumberHandling? declaringTypeNumberHandling) { if (IsForTypeInfo) { Debug.Assert(MemberInfo == null); DetermineNumberHandlingForTypeInfo(declaringTypeNumberHandling); } else { Debug.Assert(MemberInfo != null); DetermineSerializationCapabilities(ignoreCondition); DeterminePropertyName(); DetermineIgnoreCondition(ignoreCondition); JsonPropertyOrderAttribute? orderAttr = GetAttribute<JsonPropertyOrderAttribute>(MemberInfo); if (orderAttr != null) { Order = orderAttr.Order; } JsonNumberHandlingAttribute? attribute = GetAttribute<JsonNumberHandlingAttribute>(MemberInfo); DetermineNumberHandlingForProperty(attribute?.Handling, declaringTypeNumberHandling); } } private void DeterminePropertyName() { Debug.Assert(MemberInfo != null); ClrName = MemberInfo.Name; JsonPropertyNameAttribute? nameAttribute = GetAttribute<JsonPropertyNameAttribute>(MemberInfo); if (nameAttribute != null) { string name = nameAttribute.Name; if (name == null) { ThrowHelper.ThrowInvalidOperationException_SerializerPropertyNameNull(DeclaringType, this); } NameAsString = name; } else if (Options.PropertyNamingPolicy != null) { string name = Options.PropertyNamingPolicy.ConvertName(MemberInfo.Name); if (name == null) { ThrowHelper.ThrowInvalidOperationException_SerializerPropertyNameNull(DeclaringType, this); } NameAsString = name; } else { NameAsString = MemberInfo.Name; } Debug.Assert(NameAsString != null); NameAsUtf8Bytes = Encoding.UTF8.GetBytes(NameAsString); EscapedNameSection = JsonHelpers.GetEscapedPropertyNameSection(NameAsUtf8Bytes, Options.Encoder); } internal void DetermineSerializationCapabilities(JsonIgnoreCondition? ignoreCondition) { Debug.Assert(MemberType == MemberTypes.Property || MemberType == MemberTypes.Field); if ((ConverterStrategy & (ConverterStrategy.Enumerable | ConverterStrategy.Dictionary)) == 0) { Debug.Assert(ignoreCondition != JsonIgnoreCondition.Always); // Three possible values for ignoreCondition: // null = JsonIgnore was not placed on this property, global IgnoreReadOnlyProperties/Fields wins // WhenNull = only ignore when null, global IgnoreReadOnlyProperties/Fields loses // Never = never ignore (always include), global IgnoreReadOnlyProperties/Fields loses bool serializeReadOnlyProperty = ignoreCondition != null || (MemberType == MemberTypes.Property ? !Options.IgnoreReadOnlyProperties : !Options.IgnoreReadOnlyFields); // We serialize if there is a getter + not ignoring readonly properties. ShouldSerialize = HasGetter && (HasSetter || serializeReadOnlyProperty); // We deserialize if there is a setter. ShouldDeserialize = HasSetter; } else { if (HasGetter) { Debug.Assert(ConverterBase != null); ShouldSerialize = true; if (HasSetter) { ShouldDeserialize = true; } } } } internal void DetermineIgnoreCondition(JsonIgnoreCondition? ignoreCondition) { if (ignoreCondition != null) { // This is not true for CodeGen scenarios since we do not cache this as of yet. // Debug.Assert(MemberInfo != null); Debug.Assert(ignoreCondition != JsonIgnoreCondition.Always); if (ignoreCondition == JsonIgnoreCondition.WhenWritingDefault) { IgnoreDefaultValuesOnWrite = true; } else if (ignoreCondition == JsonIgnoreCondition.WhenWritingNull) { if (PropertyTypeCanBeNull) { IgnoreDefaultValuesOnWrite = true; } else { ThrowHelper.ThrowInvalidOperationException_IgnoreConditionOnValueTypeInvalid(ClrName!, DeclaringType); } } } #pragma warning disable SYSLIB0020 // JsonSerializerOptions.IgnoreNullValues is obsolete else if (Options.IgnoreNullValues) { Debug.Assert(Options.DefaultIgnoreCondition == JsonIgnoreCondition.Never); if (PropertyTypeCanBeNull) { IgnoreDefaultValuesOnRead = true; IgnoreDefaultValuesOnWrite = true; } } else if (Options.DefaultIgnoreCondition == JsonIgnoreCondition.WhenWritingNull) { Debug.Assert(!Options.IgnoreNullValues); if (PropertyTypeCanBeNull) { IgnoreDefaultValuesOnWrite = true; } } else if (Options.DefaultIgnoreCondition == JsonIgnoreCondition.WhenWritingDefault) { Debug.Assert(!Options.IgnoreNullValues); IgnoreDefaultValuesOnWrite = true; } #pragma warning restore SYSLIB0020 } internal void DetermineNumberHandlingForTypeInfo(JsonNumberHandling? numberHandling) { if (numberHandling != null && numberHandling != JsonNumberHandling.Strict && !ConverterBase.IsInternalConverter) { ThrowHelper.ThrowInvalidOperationException_NumberHandlingOnPropertyInvalid(this); } if (NumberHandingIsApplicable()) { // This logic is to honor JsonNumberHandlingAttribute placed on // custom collections e.g. public class MyNumberList : List<int>. // Priority 1: Get handling from the type (parent type in this case is the type itself). NumberHandling = numberHandling; // Priority 2: Get handling from JsonSerializerOptions instance. if (!NumberHandling.HasValue && Options.NumberHandling != JsonNumberHandling.Strict) { NumberHandling = Options.NumberHandling; } } } internal void DetermineNumberHandlingForProperty( JsonNumberHandling? propertyNumberHandling, JsonNumberHandling? declaringTypeNumberHandling) { bool numberHandlingIsApplicable = NumberHandingIsApplicable(); if (numberHandlingIsApplicable) { // Priority 1: Get handling from attribute on property/field, or its parent class type. JsonNumberHandling? handling = propertyNumberHandling ?? declaringTypeNumberHandling; // Priority 2: Get handling from JsonSerializerOptions instance. if (!handling.HasValue && Options.NumberHandling != JsonNumberHandling.Strict) { handling = Options.NumberHandling; } NumberHandling = handling; } else if (propertyNumberHandling.HasValue && propertyNumberHandling != JsonNumberHandling.Strict) { ThrowHelper.ThrowInvalidOperationException_NumberHandlingOnPropertyInvalid(this); } } private bool NumberHandingIsApplicable() { if (ConverterBase.IsInternalConverterForNumberType) { return true; } Type potentialNumberType; if (!ConverterBase.IsInternalConverter || ((ConverterStrategy.Enumerable | ConverterStrategy.Dictionary) & ConverterStrategy) == 0) { potentialNumberType = PropertyType; } else { Debug.Assert(ConverterBase.ElementType != null); potentialNumberType = ConverterBase.ElementType; } potentialNumberType = Nullable.GetUnderlyingType(potentialNumberType) ?? potentialNumberType; return potentialNumberType == typeof(byte) || potentialNumberType == typeof(decimal) || potentialNumberType == typeof(double) || potentialNumberType == typeof(short) || potentialNumberType == typeof(int) || potentialNumberType == typeof(long) || potentialNumberType == typeof(sbyte) || potentialNumberType == typeof(float) || potentialNumberType == typeof(ushort) || potentialNumberType == typeof(uint) || potentialNumberType == typeof(ulong) || potentialNumberType == JsonTypeInfo.ObjectType; } internal static TAttribute? GetAttribute<TAttribute>(MemberInfo memberInfo) where TAttribute : Attribute { return (TAttribute?)memberInfo.GetCustomAttribute(typeof(TAttribute), inherit: false); } internal abstract bool GetMemberAndWriteJson(object obj, ref WriteStack state, Utf8JsonWriter writer); internal abstract bool GetMemberAndWriteJsonExtensionData(object obj, ref WriteStack state, Utf8JsonWriter writer); internal abstract object? GetValueAsObject(object obj); internal bool HasGetter { get; set; } internal bool HasSetter { get; set; } internal virtual void Initialize( Type parentClassType, Type declaredPropertyType, ConverterStrategy converterStrategy, MemberInfo? memberInfo, bool isVirtual, JsonConverter converter, JsonIgnoreCondition? ignoreCondition, JsonNumberHandling? parentTypeNumberHandling, JsonSerializerOptions options) { Debug.Assert(converter != null); DeclaringType = parentClassType; PropertyType = declaredPropertyType; ConverterStrategy = converterStrategy; MemberInfo = memberInfo; IsVirtual = isVirtual; ConverterBase = converter; Options = options; } internal abstract void InitializeForTypeInfo( Type declaredType, JsonTypeInfo runtimeTypeInfo, JsonConverter converter, JsonSerializerOptions options); internal bool IgnoreDefaultValuesOnRead { get; private set; } internal bool IgnoreDefaultValuesOnWrite { get; private set; } /// <summary> /// True if the corresponding cref="JsonTypeInfo.PropertyInfoForTypeInfo"/> is this instance. /// </summary> internal bool IsForTypeInfo { get; set; } // There are 3 copies of the property name: // 1) NameAsString. The unescaped property name. // 2) NameAsUtf8Bytes. The Utf8 version of NameAsString. Used during during deserialization for property lookup. // 3) EscapedNameSection. The escaped verson of NameAsUtf8Bytes plus the wrapping quotes and a trailing colon. Used during serialization. /// <summary> /// The unescaped name of the property. /// Is either the actual CLR property name, /// the value specified in JsonPropertyNameAttribute, /// or the value returned from PropertyNamingPolicy(clrPropertyName). /// </summary> internal string NameAsString { get; set; } = null!; /// <summary> /// Utf8 version of NameAsString. /// </summary> internal byte[] NameAsUtf8Bytes { get; set; } = null!; /// <summary> /// The escaped name passed to the writer. /// </summary> internal byte[] EscapedNameSection { get; set; } = null!; internal JsonSerializerOptions Options { get; set; } = null!; // initialized in Init method /// <summary> /// The property order. /// </summary> internal int Order { get; set; } internal bool ReadJsonAndAddExtensionProperty( object obj, ref ReadStack state, ref Utf8JsonReader reader) { object propValue = GetValueAsObject(obj)!; if (propValue is IDictionary<string, object?> dictionaryObjectValue) { if (reader.TokenType == JsonTokenType.Null) { // A null JSON value is treated as a null object reference. dictionaryObjectValue[state.Current.JsonPropertyNameAsString!] = null; } else { JsonConverter<object> converter = (JsonConverter<object>)GetDictionaryValueConverter(JsonTypeInfo.ObjectType); object value = converter.Read(ref reader, JsonTypeInfo.ObjectType, Options)!; dictionaryObjectValue[state.Current.JsonPropertyNameAsString!] = value; } } else if (propValue is IDictionary<string, JsonElement> dictionaryElementValue) { Type elementType = typeof(JsonElement); JsonConverter<JsonElement> converter = (JsonConverter<JsonElement>)GetDictionaryValueConverter(elementType); JsonElement value = converter.Read(ref reader, elementType, Options); dictionaryElementValue[state.Current.JsonPropertyNameAsString!] = value; } else { // Avoid a type reference to JsonObject and its converter to support trimming. Debug.Assert(propValue is Nodes.JsonObject); ConverterBase.ReadElementAndSetProperty(propValue, state.Current.JsonPropertyNameAsString!, ref reader, Options, ref state); } return true; JsonConverter GetDictionaryValueConverter(Type dictionaryValueType) { JsonConverter converter; JsonTypeInfo? dictionaryValueInfo = JsonTypeInfo.ElementTypeInfo; if (dictionaryValueInfo != null) { // Fast path when there is a generic type such as Dictionary<,>. converter = dictionaryValueInfo.PropertyInfoForTypeInfo.ConverterBase; } else { // Slower path for non-generic types that implement IDictionary<,>. // It is possible to cache this converter on JsonTypeInfo if we assume the property value // will always be the same type for all instances. converter = Options.GetConverterInternal(dictionaryValueType); } Debug.Assert(converter != null); return converter; } } internal abstract bool ReadJsonAndSetMember(object obj, ref ReadStack state, ref Utf8JsonReader reader); internal abstract bool ReadJsonAsObject(ref ReadStack state, ref Utf8JsonReader reader, out object? value); internal bool ReadJsonExtensionDataValue(ref ReadStack state, ref Utf8JsonReader reader, out object? value) { Debug.Assert(this == state.Current.JsonTypeInfo.DataExtensionProperty); if (JsonTypeInfo.ElementType == JsonTypeInfo.ObjectType && reader.TokenType == JsonTokenType.Null) { value = null; return true; } JsonConverter<JsonElement> converter = (JsonConverter<JsonElement>)Options.GetConverterInternal(typeof(JsonElement)); if (!converter.TryRead(ref reader, typeof(JsonElement), Options, ref state, out JsonElement jsonElement)) { // JsonElement is a struct that must be read in full. value = null; return false; } value = jsonElement; return true; } internal Type DeclaringType { get; set; } = null!; internal MemberInfo? MemberInfo { get; private set; } internal JsonTypeInfo JsonTypeInfo { get { return _jsonTypeInfo ??= Options.GetOrAddJsonTypeInfo(PropertyType); } set { // Used by JsonMetadataServices. Debug.Assert(_jsonTypeInfo == null); _jsonTypeInfo = value; } } internal abstract void SetExtensionDictionaryAsObject(object obj, object? extensionDict); internal bool ShouldSerialize { get; set; } internal bool ShouldDeserialize { get; set; } internal bool IsIgnored { get; set; } /// <summary> /// Relevant to source generated metadata: did the property have the <see cref="JsonIncludeAttribute"/>? /// </summary> internal bool SrcGen_HasJsonInclude { get; set; } /// <summary> /// Relevant to source generated metadata: did the property have the <see cref="JsonExtensionDataAttribute"/>? /// </summary> internal bool SrcGen_IsExtensionData { get; set; } /// <summary> /// Relevant to source generated metadata: is the property public? /// </summary> internal bool SrcGen_IsPublic { get; set; } internal JsonNumberHandling? NumberHandling { get; set; } // Whether the property type can be null. internal bool PropertyTypeCanBeNull { get; set; } internal JsonIgnoreCondition? IgnoreCondition { get; set; } internal MemberTypes MemberType { get; set; } // TODO: with some refactoring, we should be able to remove this. internal string? ClrName { get; set; } internal bool IsVirtual { get; set; } /// <summary> /// Default value used for parameterized ctor invocation. /// </summary> internal abstract object? DefaultValue { get; } [DebuggerBrowsable(DebuggerBrowsableState.Never)] private string DebuggerDisplay => $"MemberInfo={MemberInfo}"; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Reflection; namespace System.Text.Json.Serialization.Metadata { /// <summary> /// Provides JSON serialization-related metadata about a property or field. /// </summary> [DebuggerDisplay("{DebuggerDisplay,nq}")] [EditorBrowsable(EditorBrowsableState.Never)] public abstract class JsonPropertyInfo { internal static readonly JsonPropertyInfo s_missingProperty = GetPropertyPlaceholder(); private JsonTypeInfo? _jsonTypeInfo; internal ConverterStrategy ConverterStrategy; internal abstract JsonConverter ConverterBase { get; set; } internal JsonPropertyInfo() { } internal static JsonPropertyInfo GetPropertyPlaceholder() { JsonPropertyInfo info = new JsonPropertyInfo<object>(); Debug.Assert(!info.IsForTypeInfo); Debug.Assert(!info.ShouldDeserialize); Debug.Assert(!info.ShouldSerialize); info.NameAsString = string.Empty; return info; } // Create a property that is ignored at run-time. internal static JsonPropertyInfo CreateIgnoredPropertyPlaceholder( MemberInfo memberInfo, Type memberType, bool isVirtual, JsonSerializerOptions options) { JsonPropertyInfo jsonPropertyInfo = new JsonPropertyInfo<sbyte>(); jsonPropertyInfo.Options = options; jsonPropertyInfo.MemberInfo = memberInfo; jsonPropertyInfo.IsIgnored = true; jsonPropertyInfo.PropertyType = memberType; jsonPropertyInfo.IsVirtual = isVirtual; jsonPropertyInfo.DeterminePropertyName(); Debug.Assert(!jsonPropertyInfo.ShouldDeserialize); Debug.Assert(!jsonPropertyInfo.ShouldSerialize); return jsonPropertyInfo; } internal Type PropertyType { get; set; } = null!; internal virtual void GetPolicies(JsonIgnoreCondition? ignoreCondition, JsonNumberHandling? declaringTypeNumberHandling) { if (IsForTypeInfo) { Debug.Assert(MemberInfo == null); DetermineNumberHandlingForTypeInfo(declaringTypeNumberHandling); } else { Debug.Assert(MemberInfo != null); DetermineSerializationCapabilities(ignoreCondition); DeterminePropertyName(); DetermineIgnoreCondition(ignoreCondition); JsonPropertyOrderAttribute? orderAttr = GetAttribute<JsonPropertyOrderAttribute>(MemberInfo); if (orderAttr != null) { Order = orderAttr.Order; } JsonNumberHandlingAttribute? attribute = GetAttribute<JsonNumberHandlingAttribute>(MemberInfo); DetermineNumberHandlingForProperty(attribute?.Handling, declaringTypeNumberHandling); } } private void DeterminePropertyName() { Debug.Assert(MemberInfo != null); ClrName = MemberInfo.Name; JsonPropertyNameAttribute? nameAttribute = GetAttribute<JsonPropertyNameAttribute>(MemberInfo); if (nameAttribute != null) { string name = nameAttribute.Name; if (name == null) { ThrowHelper.ThrowInvalidOperationException_SerializerPropertyNameNull(DeclaringType, this); } NameAsString = name; } else if (Options.PropertyNamingPolicy != null) { string name = Options.PropertyNamingPolicy.ConvertName(MemberInfo.Name); if (name == null) { ThrowHelper.ThrowInvalidOperationException_SerializerPropertyNameNull(DeclaringType, this); } NameAsString = name; } else { NameAsString = MemberInfo.Name; } Debug.Assert(NameAsString != null); NameAsUtf8Bytes = Encoding.UTF8.GetBytes(NameAsString); EscapedNameSection = JsonHelpers.GetEscapedPropertyNameSection(NameAsUtf8Bytes, Options.Encoder); } internal void DetermineSerializationCapabilities(JsonIgnoreCondition? ignoreCondition) { Debug.Assert(MemberType == MemberTypes.Property || MemberType == MemberTypes.Field); if ((ConverterStrategy & (ConverterStrategy.Enumerable | ConverterStrategy.Dictionary)) == 0) { Debug.Assert(ignoreCondition != JsonIgnoreCondition.Always); // Three possible values for ignoreCondition: // null = JsonIgnore was not placed on this property, global IgnoreReadOnlyProperties/Fields wins // WhenNull = only ignore when null, global IgnoreReadOnlyProperties/Fields loses // Never = never ignore (always include), global IgnoreReadOnlyProperties/Fields loses bool serializeReadOnlyProperty = ignoreCondition != null || (MemberType == MemberTypes.Property ? !Options.IgnoreReadOnlyProperties : !Options.IgnoreReadOnlyFields); // We serialize if there is a getter + not ignoring readonly properties. ShouldSerialize = HasGetter && (HasSetter || serializeReadOnlyProperty); // We deserialize if there is a setter. ShouldDeserialize = HasSetter; } else { if (HasGetter) { Debug.Assert(ConverterBase != null); ShouldSerialize = true; if (HasSetter) { ShouldDeserialize = true; } } } } internal void DetermineIgnoreCondition(JsonIgnoreCondition? ignoreCondition) { if (ignoreCondition != null) { // This is not true for CodeGen scenarios since we do not cache this as of yet. // Debug.Assert(MemberInfo != null); Debug.Assert(ignoreCondition != JsonIgnoreCondition.Always); if (ignoreCondition == JsonIgnoreCondition.WhenWritingDefault) { IgnoreDefaultValuesOnWrite = true; } else if (ignoreCondition == JsonIgnoreCondition.WhenWritingNull) { if (PropertyTypeCanBeNull) { IgnoreDefaultValuesOnWrite = true; } else { ThrowHelper.ThrowInvalidOperationException_IgnoreConditionOnValueTypeInvalid(ClrName!, DeclaringType); } } } #pragma warning disable SYSLIB0020 // JsonSerializerOptions.IgnoreNullValues is obsolete else if (Options.IgnoreNullValues) { Debug.Assert(Options.DefaultIgnoreCondition == JsonIgnoreCondition.Never); if (PropertyTypeCanBeNull) { IgnoreDefaultValuesOnRead = true; IgnoreDefaultValuesOnWrite = true; } } else if (Options.DefaultIgnoreCondition == JsonIgnoreCondition.WhenWritingNull) { Debug.Assert(!Options.IgnoreNullValues); if (PropertyTypeCanBeNull) { IgnoreDefaultValuesOnWrite = true; } } else if (Options.DefaultIgnoreCondition == JsonIgnoreCondition.WhenWritingDefault) { Debug.Assert(!Options.IgnoreNullValues); IgnoreDefaultValuesOnWrite = true; } #pragma warning restore SYSLIB0020 } internal void DetermineNumberHandlingForTypeInfo(JsonNumberHandling? numberHandling) { if (numberHandling != null && numberHandling != JsonNumberHandling.Strict && !ConverterBase.IsInternalConverter) { ThrowHelper.ThrowInvalidOperationException_NumberHandlingOnPropertyInvalid(this); } if (NumberHandingIsApplicable()) { // This logic is to honor JsonNumberHandlingAttribute placed on // custom collections e.g. public class MyNumberList : List<int>. // Priority 1: Get handling from the type (parent type in this case is the type itself). NumberHandling = numberHandling; // Priority 2: Get handling from JsonSerializerOptions instance. if (!NumberHandling.HasValue && Options.NumberHandling != JsonNumberHandling.Strict) { NumberHandling = Options.NumberHandling; } } } internal void DetermineNumberHandlingForProperty( JsonNumberHandling? propertyNumberHandling, JsonNumberHandling? declaringTypeNumberHandling) { bool numberHandlingIsApplicable = NumberHandingIsApplicable(); if (numberHandlingIsApplicable) { // Priority 1: Get handling from attribute on property/field, or its parent class type. JsonNumberHandling? handling = propertyNumberHandling ?? declaringTypeNumberHandling; // Priority 2: Get handling from JsonSerializerOptions instance. if (!handling.HasValue && Options.NumberHandling != JsonNumberHandling.Strict) { handling = Options.NumberHandling; } NumberHandling = handling; } else if (propertyNumberHandling.HasValue && propertyNumberHandling != JsonNumberHandling.Strict) { ThrowHelper.ThrowInvalidOperationException_NumberHandlingOnPropertyInvalid(this); } } private bool NumberHandingIsApplicable() { if (ConverterBase.IsInternalConverterForNumberType) { return true; } Type potentialNumberType; if (!ConverterBase.IsInternalConverter || ((ConverterStrategy.Enumerable | ConverterStrategy.Dictionary) & ConverterStrategy) == 0) { potentialNumberType = PropertyType; } else { Debug.Assert(ConverterBase.ElementType != null); potentialNumberType = ConverterBase.ElementType; } potentialNumberType = Nullable.GetUnderlyingType(potentialNumberType) ?? potentialNumberType; return potentialNumberType == typeof(byte) || potentialNumberType == typeof(decimal) || potentialNumberType == typeof(double) || potentialNumberType == typeof(short) || potentialNumberType == typeof(int) || potentialNumberType == typeof(long) || potentialNumberType == typeof(sbyte) || potentialNumberType == typeof(float) || potentialNumberType == typeof(ushort) || potentialNumberType == typeof(uint) || potentialNumberType == typeof(ulong) || potentialNumberType == JsonTypeInfo.ObjectType; } internal static TAttribute? GetAttribute<TAttribute>(MemberInfo memberInfo) where TAttribute : Attribute { return (TAttribute?)memberInfo.GetCustomAttribute(typeof(TAttribute), inherit: false); } internal abstract bool GetMemberAndWriteJson(object obj, ref WriteStack state, Utf8JsonWriter writer); internal abstract bool GetMemberAndWriteJsonExtensionData(object obj, ref WriteStack state, Utf8JsonWriter writer); internal abstract object? GetValueAsObject(object obj); internal bool HasGetter { get; set; } internal bool HasSetter { get; set; } internal virtual void Initialize( Type parentClassType, Type declaredPropertyType, ConverterStrategy converterStrategy, MemberInfo? memberInfo, bool isVirtual, JsonConverter converter, JsonIgnoreCondition? ignoreCondition, JsonNumberHandling? parentTypeNumberHandling, JsonSerializerOptions options) { Debug.Assert(converter != null); DeclaringType = parentClassType; PropertyType = declaredPropertyType; ConverterStrategy = converterStrategy; MemberInfo = memberInfo; IsVirtual = isVirtual; ConverterBase = converter; Options = options; } internal abstract void InitializeForTypeInfo( Type declaredType, JsonTypeInfo runtimeTypeInfo, JsonConverter converter, JsonSerializerOptions options); internal bool IgnoreDefaultValuesOnRead { get; private set; } internal bool IgnoreDefaultValuesOnWrite { get; private set; } /// <summary> /// True if the corresponding cref="JsonTypeInfo.PropertyInfoForTypeInfo"/> is this instance. /// </summary> internal bool IsForTypeInfo { get; set; } // There are 3 copies of the property name: // 1) NameAsString. The unescaped property name. // 2) NameAsUtf8Bytes. The Utf8 version of NameAsString. Used during during deserialization for property lookup. // 3) EscapedNameSection. The escaped verson of NameAsUtf8Bytes plus the wrapping quotes and a trailing colon. Used during serialization. /// <summary> /// The unescaped name of the property. /// Is either the actual CLR property name, /// the value specified in JsonPropertyNameAttribute, /// or the value returned from PropertyNamingPolicy(clrPropertyName). /// </summary> internal string NameAsString { get; set; } = null!; /// <summary> /// Utf8 version of NameAsString. /// </summary> internal byte[] NameAsUtf8Bytes { get; set; } = null!; /// <summary> /// The escaped name passed to the writer. /// </summary> internal byte[] EscapedNameSection { get; set; } = null!; internal JsonSerializerOptions Options { get; set; } = null!; // initialized in Init method /// <summary> /// The property order. /// </summary> internal int Order { get; set; } internal bool ReadJsonAndAddExtensionProperty( object obj, ref ReadStack state, ref Utf8JsonReader reader) { object propValue = GetValueAsObject(obj)!; if (propValue is IDictionary<string, object?> dictionaryObjectValue) { if (reader.TokenType == JsonTokenType.Null) { // A null JSON value is treated as a null object reference. dictionaryObjectValue[state.Current.JsonPropertyNameAsString!] = null; } else { JsonConverter<object> converter = (JsonConverter<object>)GetDictionaryValueConverter(JsonTypeInfo.ObjectType); object value = converter.Read(ref reader, JsonTypeInfo.ObjectType, Options)!; dictionaryObjectValue[state.Current.JsonPropertyNameAsString!] = value; } } else if (propValue is IDictionary<string, JsonElement> dictionaryElementValue) { Type elementType = typeof(JsonElement); JsonConverter<JsonElement> converter = (JsonConverter<JsonElement>)GetDictionaryValueConverter(elementType); JsonElement value = converter.Read(ref reader, elementType, Options); dictionaryElementValue[state.Current.JsonPropertyNameAsString!] = value; } else { // Avoid a type reference to JsonObject and its converter to support trimming. Debug.Assert(propValue is Nodes.JsonObject); ConverterBase.ReadElementAndSetProperty(propValue, state.Current.JsonPropertyNameAsString!, ref reader, Options, ref state); } return true; JsonConverter GetDictionaryValueConverter(Type dictionaryValueType) { JsonConverter converter; JsonTypeInfo? dictionaryValueInfo = JsonTypeInfo.ElementTypeInfo; if (dictionaryValueInfo != null) { // Fast path when there is a generic type such as Dictionary<,>. converter = dictionaryValueInfo.PropertyInfoForTypeInfo.ConverterBase; } else { // Slower path for non-generic types that implement IDictionary<,>. // It is possible to cache this converter on JsonTypeInfo if we assume the property value // will always be the same type for all instances. converter = Options.GetConverterInternal(dictionaryValueType); } Debug.Assert(converter != null); return converter; } } internal abstract bool ReadJsonAndSetMember(object obj, ref ReadStack state, ref Utf8JsonReader reader); internal abstract bool ReadJsonAsObject(ref ReadStack state, ref Utf8JsonReader reader, out object? value); internal bool ReadJsonExtensionDataValue(ref ReadStack state, ref Utf8JsonReader reader, out object? value) { Debug.Assert(this == state.Current.JsonTypeInfo.DataExtensionProperty); if (JsonTypeInfo.ElementType == JsonTypeInfo.ObjectType && reader.TokenType == JsonTokenType.Null) { value = null; return true; } JsonConverter<JsonElement> converter = (JsonConverter<JsonElement>)Options.GetConverterInternal(typeof(JsonElement)); if (!converter.TryRead(ref reader, typeof(JsonElement), Options, ref state, out JsonElement jsonElement)) { // JsonElement is a struct that must be read in full. value = null; return false; } value = jsonElement; return true; } internal Type DeclaringType { get; set; } = null!; internal MemberInfo? MemberInfo { get; private set; } internal JsonTypeInfo JsonTypeInfo { get { return _jsonTypeInfo ??= Options.GetOrAddJsonTypeInfo(PropertyType); } set { // Used by JsonMetadataServices. Debug.Assert(_jsonTypeInfo == null); _jsonTypeInfo = value; } } internal abstract void SetExtensionDictionaryAsObject(object obj, object? extensionDict); internal bool ShouldSerialize { get; set; } internal bool ShouldDeserialize { get; set; } internal bool IsIgnored { get; set; } /// <summary> /// Relevant to source generated metadata: did the property have the <see cref="JsonIncludeAttribute"/>? /// </summary> internal bool SrcGen_HasJsonInclude { get; set; } /// <summary> /// Relevant to source generated metadata: did the property have the <see cref="JsonExtensionDataAttribute"/>? /// </summary> internal bool SrcGen_IsExtensionData { get; set; } /// <summary> /// Relevant to source generated metadata: is the property public? /// </summary> internal bool SrcGen_IsPublic { get; set; } internal JsonNumberHandling? NumberHandling { get; set; } // Whether the property type can be null. internal bool PropertyTypeCanBeNull { get; set; } internal JsonIgnoreCondition? IgnoreCondition { get; set; } internal MemberTypes MemberType { get; set; } // TODO: with some refactoring, we should be able to remove this. internal string? ClrName { get; set; } internal bool IsVirtual { get; set; } /// <summary> /// Default value used for parameterized ctor invocation. /// </summary> internal abstract object? DefaultValue { get; } [DebuggerBrowsable(DebuggerBrowsableState.Never)] private string DebuggerDisplay => $"MemberInfo={MemberInfo}"; } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/libraries/System.Private.Xml/tests/XmlSchema/TestFiles/TestData/XmlSchemaValidatorAPI/PartialValidation.xsd
<?xml version="1.0" encoding="utf-8" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="PartialElement" type="xs:int"/> <xs:element name="PartialElement2" type="xs:string" /> <xs:complexType name="PartialType" /> <xs:complexType name="PartialType2"> <xs:sequence> <xs:element name="bar" /> </xs:sequence> </xs:complexType> <xs:attribute name="PartialAttribute" type="xs:int" /> <xs:attribute name="PartialAttribute2" type="xs:string" /> </xs:schema>
<?xml version="1.0" encoding="utf-8" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="PartialElement" type="xs:int"/> <xs:element name="PartialElement2" type="xs:string" /> <xs:complexType name="PartialType" /> <xs:complexType name="PartialType2"> <xs:sequence> <xs:element name="bar" /> </xs:sequence> </xs:complexType> <xs:attribute name="PartialAttribute" type="xs:int" /> <xs:attribute name="PartialAttribute2" type="xs:string" /> </xs:schema>
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/libraries/Microsoft.Win32.SystemEvents/src/Microsoft/Win32/SessionEndedEventArgs.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; namespace Microsoft.Win32 { /// <devdoc> /// <para>Provides data for the <see cref='Microsoft.Win32.SystemEvents.SessionEnded'/> event.</para> /// </devdoc> public class SessionEndedEventArgs : EventArgs { private readonly SessionEndReasons _reason; /// <devdoc> /// <para>Initializes a new instance of the <see cref='Microsoft.Win32.SessionEndedEventArgs'/> class.</para> /// </devdoc> public SessionEndedEventArgs(SessionEndReasons reason) { _reason = reason; } /// <devdoc> /// <para>Gets how the session ended.</para> /// </devdoc> public SessionEndReasons Reason { get { return _reason; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; namespace Microsoft.Win32 { /// <devdoc> /// <para>Provides data for the <see cref='Microsoft.Win32.SystemEvents.SessionEnded'/> event.</para> /// </devdoc> public class SessionEndedEventArgs : EventArgs { private readonly SessionEndReasons _reason; /// <devdoc> /// <para>Initializes a new instance of the <see cref='Microsoft.Win32.SessionEndedEventArgs'/> class.</para> /// </devdoc> public SessionEndedEventArgs(SessionEndReasons reason) { _reason = reason; } /// <devdoc> /// <para>Gets how the session ended.</para> /// </devdoc> public SessionEndReasons Reason { get { return _reason; } } } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/mono/mono/mini/basic-float.cs
using System; using System.Reflection; /* * Regression tests for the mono JIT. * * Each test needs to be of the form: * * public static int test_<result>_<name> (); * * where <result> is an integer (the value that needs to be returned by * the method to make it pass. * <name> is a user-displayed name used to identify the test. * * The tests can be driven in two ways: * *) running the program directly: Main() uses reflection to find and invoke * the test methods (this is useful mostly to check that the tests are correct) * *) with the --regression switch of the jit (this is the preferred way since * all the tests will be run with optimizations on and off) * * The reflection logic could be moved to a .dll since we need at least another * regression test file written in IL code to have better control on how * the IL code looks. */ /* A comparison made to same variable. */ #pragma warning disable 1718 #if __MOBILE__ class FloatTests #else class Tests #endif { #if !__MOBILE__ public static int Main (string[] args) { return TestDriver.RunTests (typeof (Tests), args); } #endif public static int test_0_beq () { double a = 2.0; if (a != 2.0) return 1; return 0; } public static int test_0_bne_un () { double a = 2.0; if (a == 1.0) return 1; return 0; } public static int test_0_conv_r8 () { double a = 2; if (a != 2.0) return 1; return 0; } public static int test_0_conv_i () { double a = 2.0; int i = (int)a; if (i != 2) return 1; uint ui = (uint)a; if (ui != 2) return 2; short s = (short)a; if (s != 2) return 3; ushort us = (ushort)a; if (us != 2) return 4; byte b = (byte)a; if (b != 2) return 5; sbyte sb = (sbyte)a; if (sb != 2) return 6; return 0; } public static int test_0_fconv_u8 () { double d = Double.NaN; ulong ui; ui = (ulong)d; if (ui != 0) return 1; d = Double.PositiveInfinity; ui = (ulong)d; /* x64: 0, ARM64: ulong.MaxValue (verified against CoreCLR) */ if (ui != 0 && ui != ulong.MaxValue) return 2; d = Double.NegativeInfinity; ui = (ulong)d; /* x64: long.MaxValue + 1 (inconsistent with conversion to u4 but matches CLR) */ if (ui != 0 && ui != (ulong)long.MaxValue + 1) return 3; return 0; } public static int test_0_fconv_u4 () { double d = Double.NaN; uint ui; ui = (uint)d; if (ui != 0) return 1; d = Double.PositiveInfinity; ui = (uint)d; /* x64: 0, ARM64: uint.MaxValue (verified against CoreCLR) */ if (ui != 0 && ui != uint.MaxValue) return 2; d = Double.NegativeInfinity; ui = (uint)d; if (ui != 0) return 3; return 0; } public static int test_0_rconv_u8 () { float d = float.NaN; ulong ui; ui = (ulong)d; if (ui != 0) return 1; d = float.PositiveInfinity; ui = (ulong)d; /* x64: 0, ARM64: ulong.MaxValue (verified against CoreCLR) */ if (ui != 0 && ui != ulong.MaxValue) return 2; d = float.NegativeInfinity; ui = (ulong)d; /* x64: long.MaxValue + 1 (inconsistent with conversion to u4 but matches CLR) */ if (ui != 0 && ui != (ulong)long.MaxValue + 1) return 3; return 0; } public static int test_0_rconv_u4 () { float d = float.NaN; uint ui; ui = (uint)d; if (ui != 0) return 1; d = float.PositiveInfinity; ui = (uint)d; /* x64: 0, ARM64: uint.MaxValue (verified against CoreCLR) */ if (ui != 0 && ui != uint.MaxValue) return 2; d = float.NegativeInfinity; ui = (uint)d; if (ui != 0) return 3; return 0; } public static int test_5_conv_r4 () { int i = 5; float f = (float)i; return (int)f; } public static int test_0_conv_r4_m1 () { int i = -1; float f = (float)i; return (int)f + 1; } public static int test_5_double_conv_r4 () { double d = 5.0; float f = (float)d; return (int)f; } public static int test_5_float_conv_r8 () { float f = 5.0F; double d = (double)f; return (int)d; } public static int test_5_conv_r8 () { int i = 5; double f = (double)i; return (int)f; } public static int test_5_add () { double a = 2.0; double b = 3.0; return (int)(a + b); } public static int test_5_sub () { double a = 8.0; double b = 3.0; return (int)(a - b); } public static int test_24_mul () { double a = 8.0; double b = 3.0; return (int)(a * b); } public static int test_4_div () { double a = 8.0; double b = 2.0; return (int)(a / b); } public static int test_2_rem () { double a = 8.0; double b = 3.0; return (int)(a % b); } public static int test_2_neg () { double a = -2.0; return (int)(-a); } public static int test_46_float_add_spill () { // we overflow the FP stack double a = 1; double b = 2; double c = 3; double d = 4; double e = 5; double f = 6; double g = 7; double h = 8; double i = 9; return (int)(1.0 + (a + (b + (c + (d + (e + (f + (g + (h + i))))))))); } public static int test_4_float_sub_spill () { // we overflow the FP stack double a = 1; double b = 2; double c = 3; double d = 4; double e = 5; double f = 6; double g = 7; double h = 8; double i = 9; return -(int)(1.0 - (a - (b - (c - (d - (e - (f - (g - (h - i))))))))); ////// -(int)(1.0 - (1 - (2 - (3 - (4 - (5 - (6 - (7 - (8 - 9))))))))); } public static int test_362880_float_mul_spill () { // we overflow the FP stack double a = 1; double b = 2; double c = 3; double d = 4; double e = 5; double f = 6; double g = 7; double h = 8; double i = 9; return (int)(1.0 * (a * (b * (c * (d * (e * (f * (g * (h * i))))))))); } public static int test_4_long_cast () { long a = 1000; double d = (double)a; long b = (long)d; if (b != 1000) return 0; a = -1; d = (double)a; b = (long)d; if (b != -1) return 1; return 4; } public static int test_4_ulong_cast () { ulong a = 1000; double d = (double)a; ulong b = (ulong)d; if (b != 1000) return 0; a = 0xffffffffffffffff; float f = (float)a; if (!(f > 0f)) return 1; return 4; } public static int test_4_single_long_cast () { long a = 1000; float d = (float)a; long b = (long)d; if (b != 1000) return 0; a = -1; d = (float)a; b = (long)d; if (b != -1) return 1; return 4; } public static int test_0_lconv_to_r8 () { long a = 150; double b = (double) a; if (b != 150.0) return 1; return 0; } public static int test_0_lconv_to_r4 () { long a = 3000; float b = (float) a; if (b != 3000.0F) return 1; return 0; } static void doit (double value, out long m) { m = (long) value; } public static int test_0_ftol_clobber () { long m; doit (1.3, out m); if (m != 1) return 2; return 0; } public static int test_0_rounding () { long ticks = 631502475130080000L; long ticksperday = 864000000000L; double days = (double) ticks / ticksperday; if ((int)days != 730905) return 1; return 0; } /* FIXME: This only works on little-endian machines */ /* static unsafe int test_2_negative_zero () { int result = 0; double d = -0.0; float f = -0.0f; byte *ptr = (byte*)&d; if (ptr [7] == 0) return result; result ++; ptr = (byte*)&f; if (ptr [3] == 0) return result; result ++; return result; } */ public static int test_16_float_cmp () { double a = 2.0; double b = 1.0; int result = 0; bool val; val = a == a; if (!val) return result; result++; val = (a != a); if (val) return result; result++; val = a < a; if (val) return result; result++; val = a > a; if (val) return result; result++; val = a <= a; if (!val) return result; result++; val = a >= a; if (!val) return result; result++; val = b == a; if (val) return result; result++; val = b < a; if (!val) return result; result++; val = b > a; if (val) return result; result++; val = b <= a; if (!val) return result; result++; val = b >= a; if (val) return result; result++; val = a == b; if (val) return result; result++; val = a < b; if (val) return result; result++; val = a > b; if (!val) return result; result++; val = a <= b; if (val) return result; result++; val = a >= b; if (!val) return result; result++; return result; } public static int test_15_float_cmp_un () { double a = Double.NaN; double b = 1.0; int result = 0; bool val; val = a == a; if (val) return result; result++; val = a < a; if (val) return result; result++; val = a > a; if (val) return result; result++; val = a <= a; if (val) return result; result++; val = a >= a; if (val) return result; result++; val = b == a; if (val) return result; result++; val = b < a; if (val) return result; result++; val = b > a; if (val) return result; result++; val = b <= a; if (val) return result; result++; val = b >= a; if (val) return result; result++; val = a == b; if (val) return result; result++; val = a < b; if (val) return result; result++; val = a > b; if (val) return result; result++; val = a <= b; if (val) return result; result++; val = a >= b; if (val) return result; result++; return result; } public static int test_15_float_branch () { double a = 2.0; double b = 1.0; int result = 0; if (!(a == a)) return result; result++; if (a < a) return result; result++; if (a > a) return result; result++; if (!(a <= a)) return result; result++; if (!(a >= a)) return result; result++; if (b == a) return result; result++; if (!(b < a)) return result; result++; if (b > a) return result; result++; if (!(b <= a)) return result; result++; if (b >= a) return result; result++; if (a == b) return result; result++; if (a < b) return result; result++; if (!(a > b)) return result; result++; if (a <= b) return result; result++; if (!(a >= b)) return result; result++; return result; } public static int test_15_float_branch_un () { double a = Double.NaN; double b = 1.0; int result = 0; if (a == a) return result; result++; if (a < a) return result; result++; if (a > a) return result; result++; if (a <= a) return result; result++; if (a >= a) return result; result++; if (b == a) return result; result++; if (b < a) return result; result++; if (b > a) return result; result++; if (b <= a) return result; result++; if (b >= a) return result; result++; if (a == b) return result; result++; if (a < b) return result; result++; if (a > b) return result; result++; if (a <= b) return result; result++; if (a >= b) return result; result++; return result; } public static int test_0_float_precision () { float f1 = 3.40282346638528859E+38f; float f2 = 3.40282346638528859E+38f; float PositiveInfinity = (float)(1.0f / 0.0f); float f = (float)(f1 + f2); return f == PositiveInfinity ? 0 : 1; } static double VALUE = 0.19975845134874831D; public static int test_0_float_conversion_reduces_double_precision () { double d = (float)VALUE; if (d != 0.19975845515727997d) return 1; return 0; } /* This doesn't work with llvm */ /* public static int test_0_long_to_double_conversion () { long l = 9223372036854775807L; long conv = (long)((double)l); if (conv != -9223372036854775808L) return 1; return 0; } */ public static int INT_VAL = 0x13456799; public static int test_0_int4_to_float_convertion () { double d = (double)(float)INT_VAL; if (d != 323315616) return 1; return 0; } public static int test_0_int8_to_float_convertion () { double d = (double)(float)(long)INT_VAL; if (d != 323315616) return 1; return 0; } public static int test_5_r4_fadd () { float f1 = 3.0f; float f2 = 2.0f; return (int)(f1 + f2); } public static int test_1_r4_fsub () { float f1 = 3.0f; float f2 = 2.0f; return (int)(f1 - f2); } public static int test_6_fmul_r4 () { float f1 = 2.0f; float f2 = 3.0f; return (int)(f1 * f2); } public static int test_3_fdiv_r4 () { float f1 = 6.0f; float f2 = 2.0f; return (int)(f1 / f2); } public static int test_1_frem_r4 () { float f1 = 7.0f; float f2 = 2.0f; return (int)(f1 % f2); } public static int test_0_fcmp_eq_r4 () { float f1 = 1.0f; float f2 = 1.0f; return f1 == f2 ? 0 : 1; } public static int test_0_fcmp_eq_2_r4 () { float f1 = 1.0f; float f2 = 2.0f; return f1 == f2 ? 1 : 0; } public static int test_0_fcmp_eq_r4_mixed () { float f1 = 1.0f; double f2 = 1.0; return f1 == f2 ? 0 : 1; } public static int test_3_iconv_to_r4 () { int i = 3; float f = (float)i; return (int)f; } public static int test_2_neg_r4 () { float a = -2.0f; return (int)(-a); } public static int test_0_fceq_r4 () { float f1 = 1.0f; float f2 = 1.0f; bool res = f1 == f2; return res ? 0 : 1; } public static int test_0_fcgt_r4 () { float f1 = 2.0f; float f2 = 1.0f; bool res = f1 > f2; bool res2 = f2 > f1; return res && !res2 ? 0 : 1; } public static int test_0_fclt_r4 () { float f1 = 1.0f; float f2 = 2.0f; bool res = f1 < f2; bool res2 = f2 < f1; return res && !res2 ? 0 : 1; } public static int test_0_fclt_un_r4 () { float f1 = 2.0f; float f2 = 1.0f; bool res = f1 >= f2; bool res2 = f2 >= f1; return res && !res2 ? 0 : 1; } public static int test_0_fcgt_un_r4 () { float f1 = 1.0f; float f2 = 2.0f; bool res = f1 <= f2; bool res2 = f2 <= f1; return res && !res2 ? 0 : 1; } public static int test_0_fconv_to_u4_r4 () { float a = 10.0f; uint b = (uint)a; return b == 10 ? 0 : 1; } public static int test_0_fconv_to_u1_r4 () { float a = 10.0f; byte b = (byte)a; return b == 10 ? 0 : 1; } public static int test_0_fconv_to_i1_r4 () { float a = 127.0f; sbyte b = (sbyte)a; return b == 127 ? 0 : 1; } public static int test_0_fconv_to_u2_r4 () { float a = 10.0f; ushort b = (ushort)a; return b == 10 ? 0 : 1; } public static int test_0_fconv_to_i2_r4 () { float a = 127.0f; short b = (short)a; return b == 127 ? 0 : 1; } public static int test_10_rconv_to_u8 () { ulong l = 10; float f = (float)l; l = (ulong)f; return (int)l; } }
using System; using System.Reflection; /* * Regression tests for the mono JIT. * * Each test needs to be of the form: * * public static int test_<result>_<name> (); * * where <result> is an integer (the value that needs to be returned by * the method to make it pass. * <name> is a user-displayed name used to identify the test. * * The tests can be driven in two ways: * *) running the program directly: Main() uses reflection to find and invoke * the test methods (this is useful mostly to check that the tests are correct) * *) with the --regression switch of the jit (this is the preferred way since * all the tests will be run with optimizations on and off) * * The reflection logic could be moved to a .dll since we need at least another * regression test file written in IL code to have better control on how * the IL code looks. */ /* A comparison made to same variable. */ #pragma warning disable 1718 #if __MOBILE__ class FloatTests #else class Tests #endif { #if !__MOBILE__ public static int Main (string[] args) { return TestDriver.RunTests (typeof (Tests), args); } #endif public static int test_0_beq () { double a = 2.0; if (a != 2.0) return 1; return 0; } public static int test_0_bne_un () { double a = 2.0; if (a == 1.0) return 1; return 0; } public static int test_0_conv_r8 () { double a = 2; if (a != 2.0) return 1; return 0; } public static int test_0_conv_i () { double a = 2.0; int i = (int)a; if (i != 2) return 1; uint ui = (uint)a; if (ui != 2) return 2; short s = (short)a; if (s != 2) return 3; ushort us = (ushort)a; if (us != 2) return 4; byte b = (byte)a; if (b != 2) return 5; sbyte sb = (sbyte)a; if (sb != 2) return 6; return 0; } public static int test_0_fconv_u8 () { double d = Double.NaN; ulong ui; ui = (ulong)d; if (ui != 0) return 1; d = Double.PositiveInfinity; ui = (ulong)d; /* x64: 0, ARM64: ulong.MaxValue (verified against CoreCLR) */ if (ui != 0 && ui != ulong.MaxValue) return 2; d = Double.NegativeInfinity; ui = (ulong)d; /* x64: long.MaxValue + 1 (inconsistent with conversion to u4 but matches CLR) */ if (ui != 0 && ui != (ulong)long.MaxValue + 1) return 3; return 0; } public static int test_0_fconv_u4 () { double d = Double.NaN; uint ui; ui = (uint)d; if (ui != 0) return 1; d = Double.PositiveInfinity; ui = (uint)d; /* x64: 0, ARM64: uint.MaxValue (verified against CoreCLR) */ if (ui != 0 && ui != uint.MaxValue) return 2; d = Double.NegativeInfinity; ui = (uint)d; if (ui != 0) return 3; return 0; } public static int test_0_rconv_u8 () { float d = float.NaN; ulong ui; ui = (ulong)d; if (ui != 0) return 1; d = float.PositiveInfinity; ui = (ulong)d; /* x64: 0, ARM64: ulong.MaxValue (verified against CoreCLR) */ if (ui != 0 && ui != ulong.MaxValue) return 2; d = float.NegativeInfinity; ui = (ulong)d; /* x64: long.MaxValue + 1 (inconsistent with conversion to u4 but matches CLR) */ if (ui != 0 && ui != (ulong)long.MaxValue + 1) return 3; return 0; } public static int test_0_rconv_u4 () { float d = float.NaN; uint ui; ui = (uint)d; if (ui != 0) return 1; d = float.PositiveInfinity; ui = (uint)d; /* x64: 0, ARM64: uint.MaxValue (verified against CoreCLR) */ if (ui != 0 && ui != uint.MaxValue) return 2; d = float.NegativeInfinity; ui = (uint)d; if (ui != 0) return 3; return 0; } public static int test_5_conv_r4 () { int i = 5; float f = (float)i; return (int)f; } public static int test_0_conv_r4_m1 () { int i = -1; float f = (float)i; return (int)f + 1; } public static int test_5_double_conv_r4 () { double d = 5.0; float f = (float)d; return (int)f; } public static int test_5_float_conv_r8 () { float f = 5.0F; double d = (double)f; return (int)d; } public static int test_5_conv_r8 () { int i = 5; double f = (double)i; return (int)f; } public static int test_5_add () { double a = 2.0; double b = 3.0; return (int)(a + b); } public static int test_5_sub () { double a = 8.0; double b = 3.0; return (int)(a - b); } public static int test_24_mul () { double a = 8.0; double b = 3.0; return (int)(a * b); } public static int test_4_div () { double a = 8.0; double b = 2.0; return (int)(a / b); } public static int test_2_rem () { double a = 8.0; double b = 3.0; return (int)(a % b); } public static int test_2_neg () { double a = -2.0; return (int)(-a); } public static int test_46_float_add_spill () { // we overflow the FP stack double a = 1; double b = 2; double c = 3; double d = 4; double e = 5; double f = 6; double g = 7; double h = 8; double i = 9; return (int)(1.0 + (a + (b + (c + (d + (e + (f + (g + (h + i))))))))); } public static int test_4_float_sub_spill () { // we overflow the FP stack double a = 1; double b = 2; double c = 3; double d = 4; double e = 5; double f = 6; double g = 7; double h = 8; double i = 9; return -(int)(1.0 - (a - (b - (c - (d - (e - (f - (g - (h - i))))))))); ////// -(int)(1.0 - (1 - (2 - (3 - (4 - (5 - (6 - (7 - (8 - 9))))))))); } public static int test_362880_float_mul_spill () { // we overflow the FP stack double a = 1; double b = 2; double c = 3; double d = 4; double e = 5; double f = 6; double g = 7; double h = 8; double i = 9; return (int)(1.0 * (a * (b * (c * (d * (e * (f * (g * (h * i))))))))); } public static int test_4_long_cast () { long a = 1000; double d = (double)a; long b = (long)d; if (b != 1000) return 0; a = -1; d = (double)a; b = (long)d; if (b != -1) return 1; return 4; } public static int test_4_ulong_cast () { ulong a = 1000; double d = (double)a; ulong b = (ulong)d; if (b != 1000) return 0; a = 0xffffffffffffffff; float f = (float)a; if (!(f > 0f)) return 1; return 4; } public static int test_4_single_long_cast () { long a = 1000; float d = (float)a; long b = (long)d; if (b != 1000) return 0; a = -1; d = (float)a; b = (long)d; if (b != -1) return 1; return 4; } public static int test_0_lconv_to_r8 () { long a = 150; double b = (double) a; if (b != 150.0) return 1; return 0; } public static int test_0_lconv_to_r4 () { long a = 3000; float b = (float) a; if (b != 3000.0F) return 1; return 0; } static void doit (double value, out long m) { m = (long) value; } public static int test_0_ftol_clobber () { long m; doit (1.3, out m); if (m != 1) return 2; return 0; } public static int test_0_rounding () { long ticks = 631502475130080000L; long ticksperday = 864000000000L; double days = (double) ticks / ticksperday; if ((int)days != 730905) return 1; return 0; } /* FIXME: This only works on little-endian machines */ /* static unsafe int test_2_negative_zero () { int result = 0; double d = -0.0; float f = -0.0f; byte *ptr = (byte*)&d; if (ptr [7] == 0) return result; result ++; ptr = (byte*)&f; if (ptr [3] == 0) return result; result ++; return result; } */ public static int test_16_float_cmp () { double a = 2.0; double b = 1.0; int result = 0; bool val; val = a == a; if (!val) return result; result++; val = (a != a); if (val) return result; result++; val = a < a; if (val) return result; result++; val = a > a; if (val) return result; result++; val = a <= a; if (!val) return result; result++; val = a >= a; if (!val) return result; result++; val = b == a; if (val) return result; result++; val = b < a; if (!val) return result; result++; val = b > a; if (val) return result; result++; val = b <= a; if (!val) return result; result++; val = b >= a; if (val) return result; result++; val = a == b; if (val) return result; result++; val = a < b; if (val) return result; result++; val = a > b; if (!val) return result; result++; val = a <= b; if (val) return result; result++; val = a >= b; if (!val) return result; result++; return result; } public static int test_15_float_cmp_un () { double a = Double.NaN; double b = 1.0; int result = 0; bool val; val = a == a; if (val) return result; result++; val = a < a; if (val) return result; result++; val = a > a; if (val) return result; result++; val = a <= a; if (val) return result; result++; val = a >= a; if (val) return result; result++; val = b == a; if (val) return result; result++; val = b < a; if (val) return result; result++; val = b > a; if (val) return result; result++; val = b <= a; if (val) return result; result++; val = b >= a; if (val) return result; result++; val = a == b; if (val) return result; result++; val = a < b; if (val) return result; result++; val = a > b; if (val) return result; result++; val = a <= b; if (val) return result; result++; val = a >= b; if (val) return result; result++; return result; } public static int test_15_float_branch () { double a = 2.0; double b = 1.0; int result = 0; if (!(a == a)) return result; result++; if (a < a) return result; result++; if (a > a) return result; result++; if (!(a <= a)) return result; result++; if (!(a >= a)) return result; result++; if (b == a) return result; result++; if (!(b < a)) return result; result++; if (b > a) return result; result++; if (!(b <= a)) return result; result++; if (b >= a) return result; result++; if (a == b) return result; result++; if (a < b) return result; result++; if (!(a > b)) return result; result++; if (a <= b) return result; result++; if (!(a >= b)) return result; result++; return result; } public static int test_15_float_branch_un () { double a = Double.NaN; double b = 1.0; int result = 0; if (a == a) return result; result++; if (a < a) return result; result++; if (a > a) return result; result++; if (a <= a) return result; result++; if (a >= a) return result; result++; if (b == a) return result; result++; if (b < a) return result; result++; if (b > a) return result; result++; if (b <= a) return result; result++; if (b >= a) return result; result++; if (a == b) return result; result++; if (a < b) return result; result++; if (a > b) return result; result++; if (a <= b) return result; result++; if (a >= b) return result; result++; return result; } public static int test_0_float_precision () { float f1 = 3.40282346638528859E+38f; float f2 = 3.40282346638528859E+38f; float PositiveInfinity = (float)(1.0f / 0.0f); float f = (float)(f1 + f2); return f == PositiveInfinity ? 0 : 1; } static double VALUE = 0.19975845134874831D; public static int test_0_float_conversion_reduces_double_precision () { double d = (float)VALUE; if (d != 0.19975845515727997d) return 1; return 0; } /* This doesn't work with llvm */ /* public static int test_0_long_to_double_conversion () { long l = 9223372036854775807L; long conv = (long)((double)l); if (conv != -9223372036854775808L) return 1; return 0; } */ public static int INT_VAL = 0x13456799; public static int test_0_int4_to_float_convertion () { double d = (double)(float)INT_VAL; if (d != 323315616) return 1; return 0; } public static int test_0_int8_to_float_convertion () { double d = (double)(float)(long)INT_VAL; if (d != 323315616) return 1; return 0; } public static int test_5_r4_fadd () { float f1 = 3.0f; float f2 = 2.0f; return (int)(f1 + f2); } public static int test_1_r4_fsub () { float f1 = 3.0f; float f2 = 2.0f; return (int)(f1 - f2); } public static int test_6_fmul_r4 () { float f1 = 2.0f; float f2 = 3.0f; return (int)(f1 * f2); } public static int test_3_fdiv_r4 () { float f1 = 6.0f; float f2 = 2.0f; return (int)(f1 / f2); } public static int test_1_frem_r4 () { float f1 = 7.0f; float f2 = 2.0f; return (int)(f1 % f2); } public static int test_0_fcmp_eq_r4 () { float f1 = 1.0f; float f2 = 1.0f; return f1 == f2 ? 0 : 1; } public static int test_0_fcmp_eq_2_r4 () { float f1 = 1.0f; float f2 = 2.0f; return f1 == f2 ? 1 : 0; } public static int test_0_fcmp_eq_r4_mixed () { float f1 = 1.0f; double f2 = 1.0; return f1 == f2 ? 0 : 1; } public static int test_3_iconv_to_r4 () { int i = 3; float f = (float)i; return (int)f; } public static int test_2_neg_r4 () { float a = -2.0f; return (int)(-a); } public static int test_0_fceq_r4 () { float f1 = 1.0f; float f2 = 1.0f; bool res = f1 == f2; return res ? 0 : 1; } public static int test_0_fcgt_r4 () { float f1 = 2.0f; float f2 = 1.0f; bool res = f1 > f2; bool res2 = f2 > f1; return res && !res2 ? 0 : 1; } public static int test_0_fclt_r4 () { float f1 = 1.0f; float f2 = 2.0f; bool res = f1 < f2; bool res2 = f2 < f1; return res && !res2 ? 0 : 1; } public static int test_0_fclt_un_r4 () { float f1 = 2.0f; float f2 = 1.0f; bool res = f1 >= f2; bool res2 = f2 >= f1; return res && !res2 ? 0 : 1; } public static int test_0_fcgt_un_r4 () { float f1 = 1.0f; float f2 = 2.0f; bool res = f1 <= f2; bool res2 = f2 <= f1; return res && !res2 ? 0 : 1; } public static int test_0_fconv_to_u4_r4 () { float a = 10.0f; uint b = (uint)a; return b == 10 ? 0 : 1; } public static int test_0_fconv_to_u1_r4 () { float a = 10.0f; byte b = (byte)a; return b == 10 ? 0 : 1; } public static int test_0_fconv_to_i1_r4 () { float a = 127.0f; sbyte b = (sbyte)a; return b == 127 ? 0 : 1; } public static int test_0_fconv_to_u2_r4 () { float a = 10.0f; ushort b = (ushort)a; return b == 10 ? 0 : 1; } public static int test_0_fconv_to_i2_r4 () { float a = 127.0f; short b = (short)a; return b == 127 ? 0 : 1; } public static int test_10_rconv_to_u8 () { ulong l = 10; float f = (float)l; l = (ulong)f; return (int)l; } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/ExceptionTypeNameFormatter.Runtime.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace Internal.TypeSystem { partial class ExceptionTypeNameFormatter { private static string GetTypeName(DefType type) { if (type is NoMetadata.NoMetadataType) return ((NoMetadata.NoMetadataType)type).NameForDiagnostics; return type.Name; } private static string GetTypeNamespace(DefType type) { if (type is NoMetadata.NoMetadataType) return ((NoMetadata.NoMetadataType)type).NamespaceForDiagnostics; return type.Namespace; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace Internal.TypeSystem { partial class ExceptionTypeNameFormatter { private static string GetTypeName(DefType type) { if (type is NoMetadata.NoMetadataType) return ((NoMetadata.NoMetadataType)type).NameForDiagnostics; return type.Name; } private static string GetTypeNamespace(DefType type) { if (type is NoMetadata.NoMetadataType) return ((NoMetadata.NoMetadataType)type).NamespaceForDiagnostics; return type.Namespace; } } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/tests/JIT/HardwareIntrinsics/General/Vector256/LessThan.Double.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; namespace JIT.HardwareIntrinsics.General { public static partial class Program { private static void LessThanDouble() { var test = new VectorBinaryOpTest__LessThanDouble(); // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorBinaryOpTest__LessThanDouble { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Double[] inArray1, Double[] inArray2, Double[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Double>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Double>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Double>(); if ((alignment != 32 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Double, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Double, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector256<Double> _fld1; public Vector256<Double> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref testStruct._fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref testStruct._fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); return testStruct; } public void RunStructFldScenario(VectorBinaryOpTest__LessThanDouble testClass) { var result = Vector256.LessThan(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector256<Double>>() / sizeof(Double); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector256<Double>>() / sizeof(Double); private static readonly int RetElementCount = Unsafe.SizeOf<Vector256<Double>>() / sizeof(Double); private static Double[] _data1 = new Double[Op1ElementCount]; private static Double[] _data2 = new Double[Op2ElementCount]; private static Vector256<Double> _clsVar1; private static Vector256<Double> _clsVar2; private Vector256<Double> _fld1; private Vector256<Double> _fld2; private DataTable _dataTable; static VectorBinaryOpTest__LessThanDouble() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); } public VectorBinaryOpTest__LessThanDouble() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Vector256.LessThan( Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var method = typeof(Vector256).GetMethod(nameof(Vector256.LessThan), new Type[] { typeof(Vector256<Double>), typeof(Vector256<Double>) }); if (method is null) { method = typeof(Vector256).GetMethod(nameof(Vector256.LessThan), 1, new Type[] { typeof(Vector256<>).MakeGenericType(Type.MakeGenericMethodParameter(0)), typeof(Vector256<>).MakeGenericType(Type.MakeGenericMethodParameter(0)) }); } if (method.IsGenericMethodDefinition) { method = method.MakeGenericMethod(typeof(Double)); } var result = method.Invoke(null, new object[] { Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Vector256.LessThan( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr); var result = Vector256.LessThan(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new VectorBinaryOpTest__LessThanDouble(); var result = Vector256.LessThan(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Vector256.LessThan(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Vector256.LessThan(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } private void ValidateResult(Vector256<Double> op1, Vector256<Double> op2, void* result, [CallerMemberName] string method = "") { Double[] inArray1 = new Double[Op1ElementCount]; Double[] inArray2 = new Double[Op2ElementCount]; Double[] outArray = new Double[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Double>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Double[] inArray1 = new Double[Op1ElementCount]; Double[] inArray2 = new Double[Op2ElementCount]; Double[] outArray = new Double[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector256<Double>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector256<Double>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Double>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Double[] left, Double[] right, Double[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] < right[0]) ? -1 : 0)) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] < right[i]) ? -1 : 0)) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Vector256)}.{nameof(Vector256.LessThan)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; namespace JIT.HardwareIntrinsics.General { public static partial class Program { private static void LessThanDouble() { var test = new VectorBinaryOpTest__LessThanDouble(); // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorBinaryOpTest__LessThanDouble { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Double[] inArray1, Double[] inArray2, Double[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Double>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Double>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Double>(); if ((alignment != 32 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Double, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Double, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector256<Double> _fld1; public Vector256<Double> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref testStruct._fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref testStruct._fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); return testStruct; } public void RunStructFldScenario(VectorBinaryOpTest__LessThanDouble testClass) { var result = Vector256.LessThan(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector256<Double>>() / sizeof(Double); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector256<Double>>() / sizeof(Double); private static readonly int RetElementCount = Unsafe.SizeOf<Vector256<Double>>() / sizeof(Double); private static Double[] _data1 = new Double[Op1ElementCount]; private static Double[] _data2 = new Double[Op2ElementCount]; private static Vector256<Double> _clsVar1; private static Vector256<Double> _clsVar2; private Vector256<Double> _fld1; private Vector256<Double> _fld2; private DataTable _dataTable; static VectorBinaryOpTest__LessThanDouble() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); } public VectorBinaryOpTest__LessThanDouble() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Vector256.LessThan( Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var method = typeof(Vector256).GetMethod(nameof(Vector256.LessThan), new Type[] { typeof(Vector256<Double>), typeof(Vector256<Double>) }); if (method is null) { method = typeof(Vector256).GetMethod(nameof(Vector256.LessThan), 1, new Type[] { typeof(Vector256<>).MakeGenericType(Type.MakeGenericMethodParameter(0)), typeof(Vector256<>).MakeGenericType(Type.MakeGenericMethodParameter(0)) }); } if (method.IsGenericMethodDefinition) { method = method.MakeGenericMethod(typeof(Double)); } var result = method.Invoke(null, new object[] { Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Vector256.LessThan( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr); var result = Vector256.LessThan(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new VectorBinaryOpTest__LessThanDouble(); var result = Vector256.LessThan(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Vector256.LessThan(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Vector256.LessThan(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } private void ValidateResult(Vector256<Double> op1, Vector256<Double> op2, void* result, [CallerMemberName] string method = "") { Double[] inArray1 = new Double[Op1ElementCount]; Double[] inArray2 = new Double[Op2ElementCount]; Double[] outArray = new Double[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Double>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Double[] inArray1 = new Double[Op1ElementCount]; Double[] inArray2 = new Double[Op2ElementCount]; Double[] outArray = new Double[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector256<Double>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector256<Double>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Double>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Double[] left, Double[] right, Double[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] < right[0]) ? -1 : 0)) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] < right[i]) ? -1 : 0)) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Vector256)}.{nameof(Vector256.LessThan)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/coreclr/vm/argslot.h
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // ============================================================================ // File: argslot.h // // ============================================================================ // Contains the ARG_SLOT type. #ifndef __ARG_SLOT_H__ #define __ARG_SLOT_H__ // The ARG_SLOT must be big enough to represent all pointer and basic types (except for 80-bit fp values). // So, it's guaranteed to be at least 64-bit. typedef unsigned __int64 ARG_SLOT; #define SIZEOF_ARG_SLOT 8 #if BIGENDIAN // Returns the address of the payload inside the argslot inline BYTE* ArgSlotEndianessFixup(ARG_SLOT* pArg, UINT cbSize) { LIMITED_METHOD_CONTRACT; BYTE* pBuf = (BYTE*)pArg; switch (cbSize) { case 1: pBuf += 7; break; case 2: pBuf += 6; break; case 4: pBuf += 4; break; } return pBuf; } #else #define ArgSlotEndianessFixup(pArg, cbSize) ((BYTE *)(pArg)) #endif #endif // __ARG_SLOT_H__
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // ============================================================================ // File: argslot.h // // ============================================================================ // Contains the ARG_SLOT type. #ifndef __ARG_SLOT_H__ #define __ARG_SLOT_H__ // The ARG_SLOT must be big enough to represent all pointer and basic types (except for 80-bit fp values). // So, it's guaranteed to be at least 64-bit. typedef unsigned __int64 ARG_SLOT; #define SIZEOF_ARG_SLOT 8 #if BIGENDIAN // Returns the address of the payload inside the argslot inline BYTE* ArgSlotEndianessFixup(ARG_SLOT* pArg, UINT cbSize) { LIMITED_METHOD_CONTRACT; BYTE* pBuf = (BYTE*)pArg; switch (cbSize) { case 1: pBuf += 7; break; case 2: pBuf += 6; break; case 4: pBuf += 4; break; } return pBuf; } #else #define ArgSlotEndianessFixup(pArg, cbSize) ((BYTE *)(pArg)) #endif #endif // __ARG_SLOT_H__
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/libraries/Microsoft.Extensions.Options/src/OptionsMonitorExtensions.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Diagnostics.CodeAnalysis; namespace Microsoft.Extensions.Options { /// <summary> /// Extension methods for <see cref="IOptionsMonitor{TOptions}"/>. /// </summary> public static class OptionsMonitorExtensions { /// <summary> /// Registers a listener to be called whenever <typeparamref name="TOptions"/> changes. /// </summary> /// <param name="monitor">The IOptionsMonitor.</param> /// <param name="listener">The action to be invoked when <typeparamref name="TOptions"/> has changed.</param> /// <returns>An <see cref="IDisposable"/> which should be disposed to stop listening for changes.</returns> public static IDisposable? OnChange<[DynamicallyAccessedMembers(Options.DynamicallyAccessedMembers)] TOptions>( this IOptionsMonitor<TOptions> monitor, Action<TOptions> listener) => monitor.OnChange((o, _) => listener(o)); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Diagnostics.CodeAnalysis; namespace Microsoft.Extensions.Options { /// <summary> /// Extension methods for <see cref="IOptionsMonitor{TOptions}"/>. /// </summary> public static class OptionsMonitorExtensions { /// <summary> /// Registers a listener to be called whenever <typeparamref name="TOptions"/> changes. /// </summary> /// <param name="monitor">The IOptionsMonitor.</param> /// <param name="listener">The action to be invoked when <typeparamref name="TOptions"/> has changed.</param> /// <returns>An <see cref="IDisposable"/> which should be disposed to stop listening for changes.</returns> public static IDisposable? OnChange<[DynamicallyAccessedMembers(Options.DynamicallyAccessedMembers)] TOptions>( this IOptionsMonitor<TOptions> monitor, Action<TOptions> listener) => monitor.OnChange((o, _) => listener(o)); } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/libraries/System.Private.Xml/tests/XmlSchema/TestFiles/TestData/105897_a.xsd
<xs:schema targetNamespace="http://schemas.microsoft.com/net/2003/06/policy" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:S="http://www.w3.org/2002/12/soap-envelope" xmlns:tns="http://schemas.microsoft.com/net/2003/06/policy" elementFormDefault="qualified" attributeFormDefault="unqualified" blockDefault="#all"> <xs:import namespace="http://www.w3.org/2002/12/soap-envelope"/> <xs:element name="SelectedPolicies"> <xs:complexType> <xs:sequence> <xs:element name="SelectedPolicy" minOccurs="1" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="SelectedAssertions" minOccurs="1" type="xs:base64Binary"/> <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> <xs:attribute name="Digest" type="xs:base64Binary" use="required"/> <xs:attribute name="DigestAlgorithm" type="xs:QName"/> <xs:attribute ref="S:mustUnderstand"/> <xs:attribute ref="S:role"/> <xs:anyAttribute namespace="##any" processContents="lax"/> </xs:complexType> </xs:element> <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> <xs:anyAttribute namespace="##any" processContents="lax"/> </xs:complexType> </xs:element> </xs:schema>
<xs:schema targetNamespace="http://schemas.microsoft.com/net/2003/06/policy" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:S="http://www.w3.org/2002/12/soap-envelope" xmlns:tns="http://schemas.microsoft.com/net/2003/06/policy" elementFormDefault="qualified" attributeFormDefault="unqualified" blockDefault="#all"> <xs:import namespace="http://www.w3.org/2002/12/soap-envelope"/> <xs:element name="SelectedPolicies"> <xs:complexType> <xs:sequence> <xs:element name="SelectedPolicy" minOccurs="1" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="SelectedAssertions" minOccurs="1" type="xs:base64Binary"/> <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> <xs:attribute name="Digest" type="xs:base64Binary" use="required"/> <xs:attribute name="DigestAlgorithm" type="xs:QName"/> <xs:attribute ref="S:mustUnderstand"/> <xs:attribute ref="S:role"/> <xs:anyAttribute namespace="##any" processContents="lax"/> </xs:complexType> </xs:element> <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> <xs:anyAttribute namespace="##any" processContents="lax"/> </xs:complexType> </xs:element> </xs:schema>
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/libraries/System.Private.Xml/tests/Xslt/TestFiles/TestData/XsltApi/books_entity_ref.xml
<?xml version="1.0" ?> <!DOCTYPE Book [ <!ENTITY copy "&#169;"> <!ENTITY Name "Professional XML"> <!ENTITY PubName "Wrox Press Ltd."> <!ENTITY PubYear "2001"> <!ENTITY CopyrightText "Copyright &copy; &PubName; All Rights.."> ]> <Book> <Publisher> <Name>&Name;</Name> <PubName>&PubName;</PubName> <PubYear>&PubYear;</PubYear> <CopyRight>&CopyrightText;</CopyRight> </Publisher> </Book>
<?xml version="1.0" ?> <!DOCTYPE Book [ <!ENTITY copy "&#169;"> <!ENTITY Name "Professional XML"> <!ENTITY PubName "Wrox Press Ltd."> <!ENTITY PubYear "2001"> <!ENTITY CopyrightText "Copyright &copy; &PubName; All Rights.."> ]> <Book> <Publisher> <Name>&Name;</Name> <PubName>&PubName;</PubName> <PubYear>&PubYear;</PubYear> <CopyRight>&CopyrightText;</CopyRight> </Publisher> </Book>
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/tests/JIT/Generics/Instantiation/delegates/Delegate005.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Threading; internal delegate T GenDelegate<T>(T p1, out T p2); internal class Foo { public T Function<T>(T i, out T j) { j = i; return i; } } internal class Test_Delegate005 { public static int Main() { int i, j; Foo inst = new Foo(); GenDelegate<int> MyDelegate = new GenDelegate<int>(inst.Function<int>); i = MyDelegate(10, out j); if ((i != 10) || (j != 10)) { Console.WriteLine("Failed Sync Invokation"); return 1; } Console.WriteLine("Test Passes"); return 100; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Threading; internal delegate T GenDelegate<T>(T p1, out T p2); internal class Foo { public T Function<T>(T i, out T j) { j = i; return i; } } internal class Test_Delegate005 { public static int Main() { int i, j; Foo inst = new Foo(); GenDelegate<int> MyDelegate = new GenDelegate<int>(inst.Function<int>); i = MyDelegate(10, out j); if ((i != 10) || (j != 10)) { Console.WriteLine("Failed Sync Invokation"); return 1; } Console.WriteLine("Test Passes"); return 100; } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblySignatureKeyAttribute.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Reflection { [AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = false)] public sealed class AssemblySignatureKeyAttribute : Attribute { public AssemblySignatureKeyAttribute(string publicKey, string countersignature) { PublicKey = publicKey; Countersignature = countersignature; } public string PublicKey { get; } public string Countersignature { get; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Reflection { [AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = false)] public sealed class AssemblySignatureKeyAttribute : Attribute { public AssemblySignatureKeyAttribute(string publicKey, string countersignature) { PublicKey = publicKey; Countersignature = countersignature; } public string PublicKey { get; } public string Countersignature { get; } } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/tests/JIT/jit64/opt/cse/VolatileTest_op_and.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> <!-- Issue https://github.com/dotnet/runtime/issues/50381 --> <GCStressIncompatible Condition="'$(TargetArchitecture)' == 'arm64' and '$(TargetOS)' == 'OSX'">true</GCStressIncompatible> </PropertyGroup> <PropertyGroup> <!-- Set to 'Full' if the Debug? column is marked in the spreadsheet. Leave blank otherwise. --> <DebugType>PdbOnly</DebugType> <NoStandardLib>True</NoStandardLib> <Noconfig>True</Noconfig> <DefineConstants>$(DefineConstants);OP_AND</DefineConstants> </PropertyGroup> <ItemGroup> <Compile Include="VolatileTest.cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> <!-- Issue https://github.com/dotnet/runtime/issues/50381 --> <GCStressIncompatible Condition="'$(TargetArchitecture)' == 'arm64' and '$(TargetOS)' == 'OSX'">true</GCStressIncompatible> </PropertyGroup> <PropertyGroup> <!-- Set to 'Full' if the Debug? column is marked in the spreadsheet. Leave blank otherwise. --> <DebugType>PdbOnly</DebugType> <NoStandardLib>True</NoStandardLib> <Noconfig>True</Noconfig> <DefineConstants>$(DefineConstants);OP_AND</DefineConstants> </PropertyGroup> <ItemGroup> <Compile Include="VolatileTest.cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/tests/JIT/CodeGenBringUpTests/ModConst_d.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> <Optimize>False</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="ModConst.cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> <Optimize>False</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="ModConst.cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/native/external/libunwind/src/unwind/SetIP.c
/* libunwind - a platform-independent unwind library Copyright (C) 2003-2004 Hewlett-Packard Co Contributed by David Mosberger-Tang <[email protected]> This file is part of libunwind. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "unwind-internal.h" void _Unwind_SetIP (struct _Unwind_Context *context, unsigned long new_value) { unw_set_reg (&context->cursor, UNW_REG_IP, new_value); } void __libunwind_Unwind_SetIP (struct _Unwind_Context *, unsigned long) ALIAS (_Unwind_SetIP);
/* libunwind - a platform-independent unwind library Copyright (C) 2003-2004 Hewlett-Packard Co Contributed by David Mosberger-Tang <[email protected]> This file is part of libunwind. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "unwind-internal.h" void _Unwind_SetIP (struct _Unwind_Context *context, unsigned long new_value) { unw_set_reg (&context->cursor, UNW_REG_IP, new_value); } void __libunwind_Unwind_SetIP (struct _Unwind_Context *, unsigned long) ALIAS (_Unwind_SetIP);
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/libraries/Common/src/Interop/OSX/System.Native/Interop.SearchPath.iOS.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Runtime.InteropServices; internal static partial class Interop { internal static partial class Sys { [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_SearchPath_TempDirectory", StringMarshalling = StringMarshalling.Utf8)] internal static partial string SearchPathTempDirectory(); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Runtime.InteropServices; internal static partial class Interop { internal static partial class Sys { [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_SearchPath_TempDirectory", StringMarshalling = StringMarshalling.Utf8)] internal static partial string SearchPathTempDirectory(); } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/tests/JIT/opt/OSR/promoted.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Diagnostics; using System.Runtime.CompilerServices; // OSR complications with promoted structs struct Y { public Y(int _a, int _b) { a = _a; b = _b; } [MethodImpl(MethodImplOptions.NoInlining)] public static void Init(int _a, int _b) { s_y = new Y(_a, _b); } public static Y s_y; public int a; public int b; } class OSRMethodStructPromotion { [MethodImpl(MethodImplOptions.NoInlining)] public static int F(int from, int to) { Y.Init(from, to); Y y = Y.s_y; int result = 0; for (int i = y.a; i < y.b; i++) { result += i; } return result; } public static int Main(string[] args) { int final = 1_000_000; F(0, 10); int result = F(0, final); int expected = 1783293664; return result == expected ? 100 : -1; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Diagnostics; using System.Runtime.CompilerServices; // OSR complications with promoted structs struct Y { public Y(int _a, int _b) { a = _a; b = _b; } [MethodImpl(MethodImplOptions.NoInlining)] public static void Init(int _a, int _b) { s_y = new Y(_a, _b); } public static Y s_y; public int a; public int b; } class OSRMethodStructPromotion { [MethodImpl(MethodImplOptions.NoInlining)] public static int F(int from, int to) { Y.Init(from, to); Y y = Y.s_y; int result = 0; for (int i = y.a; i < y.b; i++) { result += i; } return result; } public static int Main(string[] args) { int final = 1_000_000; F(0, 10); int result = F(0, final); int expected = 1783293664; return result == expected ? 100 : -1; } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/coreclr/inc/corhlpr.cpp
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /**************************************************************************** ** ** ** Corhlpr.h - signature helpers. ** ** ** ****************************************************************************/ #ifndef SOS_INCLUDE #ifdef _BLD_CLR #include "utilcode.h" #endif #include "corhlpr.h" #include <stdlib.h> #endif // !SOS_INCLUDE //***************************************************************************** // //***** File format helper classes // //***************************************************************************** extern "C" { /***************************************************************************/ /* Note that this construtor does not set the LocalSig, but has the advantage that it does not have any dependancy on EE structures. inside the EE use the FunctionDesc constructor */ void __stdcall DecoderInit(void *pThis, COR_ILMETHOD *header) { COR_ILMETHOD_DECODER *decoder = (COR_ILMETHOD_DECODER *)pThis; memset(decoder, 0, sizeof(COR_ILMETHOD_DECODER)); if (header->Tiny.IsTiny()) { decoder->SetMaxStack(header->Tiny.GetMaxStack()); decoder->Code = header->Tiny.GetCode(); decoder->SetCodeSize(header->Tiny.GetCodeSize()); decoder->SetFlags(CorILMethod_TinyFormat); return; } if (header->Fat.IsFat()) { #ifdef HOST_64BIT if((((size_t) header) & 3) == 0) // header is aligned #else _ASSERTE((((size_t) header) & 3) == 0); // header is aligned #endif { *((COR_ILMETHOD_FAT *)decoder) = header->Fat; decoder->Code = header->Fat.GetCode(); if (header->Fat.GetSize() >= (sizeof(COR_ILMETHOD_FAT) / 4)) // Size if valid { decoder->Sect = header->Fat.GetSect(); if ((decoder->Sect != NULL) && (decoder->Sect->Kind() == CorILMethod_Sect_EHTable)) { decoder->EH = (COR_ILMETHOD_SECT_EH *)decoder->Sect; decoder->Sect = decoder->Sect->Next(); } } } return; } } // DecoderInit // Calculate the total method size. First get address of end of code. If there are no sections, then // the end of code addr marks end of COR_ILMETHOD. Otherwise find addr of end of last section and use it // to mark end of COR_ILMETHOD. Assumes that the code is directly followed // by each section in the on-disk format int __stdcall DecoderGetOnDiskSize(void * pThis, COR_ILMETHOD* header) { COR_ILMETHOD_DECODER* decoder = (COR_ILMETHOD_DECODER*)pThis; if (decoder->Code == NULL) return 0; BYTE *lastAddr = (BYTE*)decoder->Code + decoder->GetCodeSize(); // addr of end of code const COR_ILMETHOD_SECT *sect = decoder->EH; if (sect != 0 && sect->Next() == 0) { lastAddr = (BYTE *)sect + sect->DataSize(); } else { const COR_ILMETHOD_SECT *nextSect; for (sect = decoder->Sect; sect; sect = nextSect) { nextSect = sect->Next(); if (nextSect == 0) { // sect points to the last section, so set lastAddr lastAddr = (BYTE *)sect + sect->DataSize(); break; } } } return (int)(lastAddr - (BYTE*)header); } /*********************************************************************/ /* APIs for emitting sections etc */ unsigned __stdcall IlmethodSize(COR_ILMETHOD_FAT* header, BOOL moreSections) { if (header->GetMaxStack() <= 8 && (header->GetFlags() & ~CorILMethod_FormatMask) == 0 && header->GetLocalVarSigTok() == 0 && header->GetCodeSize() < 64 && !moreSections) return(sizeof(COR_ILMETHOD_TINY)); return(sizeof(COR_ILMETHOD_FAT)); } /*********************************************************************/ // emit the header (bestFormat) return amount emitted unsigned __stdcall IlmethodEmit(unsigned size, COR_ILMETHOD_FAT* header, BOOL moreSections, BYTE* outBuff) { #ifndef SOS_INCLUDE #ifdef _DEBUG BYTE* origBuff = outBuff; #endif #endif // !SOS_INCLUDE if (size == 1) { // Tiny format *outBuff++ = (BYTE) (CorILMethod_TinyFormat | (header->GetCodeSize() << 2)); } else { // Fat format _ASSERTE((((size_t) outBuff) & 3) == 0); // header is dword aligned COR_ILMETHOD_FAT* fatHeader = (COR_ILMETHOD_FAT*) outBuff; outBuff += sizeof(COR_ILMETHOD_FAT); *fatHeader = *header; fatHeader->SetFlags(fatHeader->GetFlags() | CorILMethod_FatFormat); _ASSERTE((fatHeader->GetFlags() & CorILMethod_FormatMask) == CorILMethod_FatFormat); if (moreSections) fatHeader->SetFlags(fatHeader->GetFlags() | CorILMethod_MoreSects); fatHeader->SetSize(sizeof(COR_ILMETHOD_FAT) / 4); } #ifndef SOS_INCLUDE _ASSERTE(&origBuff[size] == outBuff); #endif // !SOS_INCLUDE return(size); } /*********************************************************************/ /* static */ IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT* __stdcall SectEH_EHClause(void *pSectEH, unsigned idx, IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT* buff) { if (((COR_ILMETHOD_SECT_EH *)pSectEH)->IsFat()) return(&(((COR_ILMETHOD_SECT_EH *)pSectEH)->Fat.Clauses[idx])); COR_ILMETHOD_SECT_EH_CLAUSE_FAT* fatClause = (COR_ILMETHOD_SECT_EH_CLAUSE_FAT*)buff; COR_ILMETHOD_SECT_EH_CLAUSE_SMALL* smallClause = (COR_ILMETHOD_SECT_EH_CLAUSE_SMALL*)&((COR_ILMETHOD_SECT_EH *)pSectEH)->Small.Clauses[idx]; // mask to remove sign extension - cast just wouldn't work fatClause->SetFlags((CorExceptionFlag)(smallClause->GetFlags()&0x0000ffff)); fatClause->SetClassToken(smallClause->GetClassToken()); fatClause->SetTryOffset(smallClause->GetTryOffset()); fatClause->SetTryLength(smallClause->GetTryLength()); fatClause->SetHandlerLength(smallClause->GetHandlerLength()); fatClause->SetHandlerOffset(smallClause->GetHandlerOffset()); return(buff); } /*********************************************************************/ // compute the size of the section (best format) // codeSize is the size of the method // deprecated unsigned __stdcall SectEH_SizeWithCode(unsigned ehCount, unsigned codeSize) { return((ehCount)? SectEH_SizeWorst(ehCount) : 0); } // will return worse-case size and then Emit will return actual size unsigned __stdcall SectEH_SizeWorst(unsigned ehCount) { return((ehCount)? (COR_ILMETHOD_SECT_EH_FAT::Size(ehCount)) : 0); } // will return exact size which will match the size returned by Emit unsigned __stdcall SectEH_SizeExact(unsigned ehCount, IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT* clauses) { if (ehCount == 0) return(0); unsigned smallSize = COR_ILMETHOD_SECT_EH_SMALL::Size(ehCount); if (smallSize > COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE) return(COR_ILMETHOD_SECT_EH_FAT::Size(ehCount)); for (unsigned i = 0; i < ehCount; i++) { COR_ILMETHOD_SECT_EH_CLAUSE_FAT* fatClause = (COR_ILMETHOD_SECT_EH_CLAUSE_FAT*)&clauses[i]; if (fatClause->GetTryOffset() > 0xFFFF || fatClause->GetTryLength() > 0xFF || fatClause->GetHandlerOffset() > 0xFFFF || fatClause->GetHandlerLength() > 0xFF) { return(COR_ILMETHOD_SECT_EH_FAT::Size(ehCount)); } } return smallSize; } /*********************************************************************/ // emit the section (best format); unsigned __stdcall SectEH_Emit(unsigned size, unsigned ehCount, IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT* clauses, BOOL moreSections, BYTE* outBuff, ULONG* ehTypeOffsets) { if (size == 0) return(0); _ASSERTE((((size_t) outBuff) & 3) == 0); // header is dword aligned BYTE* origBuff = outBuff; if (ehCount <= 0) return 0; // Initialize the ehTypeOffsets array. if (ehTypeOffsets) { for (unsigned int i = 0; i < ehCount; i++) ehTypeOffsets[i] = (ULONG) -1; } if (COR_ILMETHOD_SECT_EH_SMALL::Size(ehCount) < COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE) { COR_ILMETHOD_SECT_EH_SMALL* EHSect = (COR_ILMETHOD_SECT_EH_SMALL*) outBuff; unsigned i; for (i = 0; i < ehCount; i++) { COR_ILMETHOD_SECT_EH_CLAUSE_FAT* fatClause = (COR_ILMETHOD_SECT_EH_CLAUSE_FAT*)&clauses[i]; if (fatClause->GetTryOffset() > 0xFFFF || fatClause->GetTryLength() > 0xFF || fatClause->GetHandlerOffset() > 0xFFFF || fatClause->GetHandlerLength() > 0xFF) { break; // fall through and generate as FAT } _ASSERTE((fatClause->GetFlags() & ~0xFFFF) == 0); _ASSERTE((fatClause->GetTryOffset() & ~0xFFFF) == 0); _ASSERTE((fatClause->GetTryLength() & ~0xFF) == 0); _ASSERTE((fatClause->GetHandlerOffset() & ~0xFFFF) == 0); _ASSERTE((fatClause->GetHandlerLength() & ~0xFF) == 0); COR_ILMETHOD_SECT_EH_CLAUSE_SMALL* smallClause = (COR_ILMETHOD_SECT_EH_CLAUSE_SMALL*)&EHSect->Clauses[i]; smallClause->SetFlags((CorExceptionFlag) fatClause->GetFlags()); smallClause->SetTryOffset(fatClause->GetTryOffset()); smallClause->SetTryLength(fatClause->GetTryLength()); smallClause->SetHandlerOffset(fatClause->GetHandlerOffset()); smallClause->SetHandlerLength(fatClause->GetHandlerLength()); smallClause->SetClassToken(fatClause->GetClassToken()); } if (i >= ehCount) { // if actually got through all the clauses and they are small enough EHSect->Kind = CorILMethod_Sect_EHTable; if (moreSections) EHSect->Kind |= CorILMethod_Sect_MoreSects; #ifndef SOS_INCLUDE EHSect->DataSize = EHSect->Size(ehCount); #else EHSect->DataSize = (BYTE) EHSect->Size(ehCount); #endif // !SOS_INCLUDE EHSect->Reserved = 0; _ASSERTE(EHSect->DataSize == EHSect->Size(ehCount)); // make sure didn't overflow outBuff = (BYTE*) &EHSect->Clauses[ehCount]; // Set the offsets for the exception type tokens. if (ehTypeOffsets) { for (i = 0; i < ehCount; i++) { COR_ILMETHOD_SECT_EH_CLAUSE_SMALL* smallClause = (COR_ILMETHOD_SECT_EH_CLAUSE_SMALL*)&EHSect->Clauses[i]; if (smallClause->GetFlags() == COR_ILEXCEPTION_CLAUSE_NONE) { _ASSERTE(! IsNilToken(smallClause->GetClassToken())); ehTypeOffsets[i] = (ULONG)((BYTE *)&smallClause->ClassToken - origBuff); } } } return(size); } } // either total size too big or one of constituent elements too big (eg. offset or length) COR_ILMETHOD_SECT_EH_FAT* EHSect = (COR_ILMETHOD_SECT_EH_FAT*) outBuff; EHSect->SetKind(CorILMethod_Sect_EHTable | CorILMethod_Sect_FatFormat); if (moreSections) EHSect->SetKind(EHSect->GetKind() | CorILMethod_Sect_MoreSects); EHSect->SetDataSize(EHSect->Size(ehCount)); memcpy(EHSect->Clauses, clauses, ehCount * sizeof(COR_ILMETHOD_SECT_EH_CLAUSE_FAT)); outBuff = (BYTE*) &EHSect->Clauses[ehCount]; _ASSERTE(&origBuff[size] == outBuff); // Set the offsets for the exception type tokens. if (ehTypeOffsets) { for (unsigned int i = 0; i < ehCount; i++) { COR_ILMETHOD_SECT_EH_CLAUSE_FAT* fatClause = (COR_ILMETHOD_SECT_EH_CLAUSE_FAT*)&EHSect->Clauses[i]; if (fatClause->GetFlags() == COR_ILEXCEPTION_CLAUSE_NONE) { _ASSERTE(! IsNilToken(fatClause->GetClassToken())); ehTypeOffsets[i] = (ULONG)((BYTE *)&fatClause->ClassToken - origBuff); } } } return(size); } } // extern "C"
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /**************************************************************************** ** ** ** Corhlpr.h - signature helpers. ** ** ** ****************************************************************************/ #ifndef SOS_INCLUDE #ifdef _BLD_CLR #include "utilcode.h" #endif #include "corhlpr.h" #include <stdlib.h> #endif // !SOS_INCLUDE //***************************************************************************** // //***** File format helper classes // //***************************************************************************** extern "C" { /***************************************************************************/ /* Note that this construtor does not set the LocalSig, but has the advantage that it does not have any dependancy on EE structures. inside the EE use the FunctionDesc constructor */ void __stdcall DecoderInit(void *pThis, COR_ILMETHOD *header) { COR_ILMETHOD_DECODER *decoder = (COR_ILMETHOD_DECODER *)pThis; memset(decoder, 0, sizeof(COR_ILMETHOD_DECODER)); if (header->Tiny.IsTiny()) { decoder->SetMaxStack(header->Tiny.GetMaxStack()); decoder->Code = header->Tiny.GetCode(); decoder->SetCodeSize(header->Tiny.GetCodeSize()); decoder->SetFlags(CorILMethod_TinyFormat); return; } if (header->Fat.IsFat()) { #ifdef HOST_64BIT if((((size_t) header) & 3) == 0) // header is aligned #else _ASSERTE((((size_t) header) & 3) == 0); // header is aligned #endif { *((COR_ILMETHOD_FAT *)decoder) = header->Fat; decoder->Code = header->Fat.GetCode(); if (header->Fat.GetSize() >= (sizeof(COR_ILMETHOD_FAT) / 4)) // Size if valid { decoder->Sect = header->Fat.GetSect(); if ((decoder->Sect != NULL) && (decoder->Sect->Kind() == CorILMethod_Sect_EHTable)) { decoder->EH = (COR_ILMETHOD_SECT_EH *)decoder->Sect; decoder->Sect = decoder->Sect->Next(); } } } return; } } // DecoderInit // Calculate the total method size. First get address of end of code. If there are no sections, then // the end of code addr marks end of COR_ILMETHOD. Otherwise find addr of end of last section and use it // to mark end of COR_ILMETHOD. Assumes that the code is directly followed // by each section in the on-disk format int __stdcall DecoderGetOnDiskSize(void * pThis, COR_ILMETHOD* header) { COR_ILMETHOD_DECODER* decoder = (COR_ILMETHOD_DECODER*)pThis; if (decoder->Code == NULL) return 0; BYTE *lastAddr = (BYTE*)decoder->Code + decoder->GetCodeSize(); // addr of end of code const COR_ILMETHOD_SECT *sect = decoder->EH; if (sect != 0 && sect->Next() == 0) { lastAddr = (BYTE *)sect + sect->DataSize(); } else { const COR_ILMETHOD_SECT *nextSect; for (sect = decoder->Sect; sect; sect = nextSect) { nextSect = sect->Next(); if (nextSect == 0) { // sect points to the last section, so set lastAddr lastAddr = (BYTE *)sect + sect->DataSize(); break; } } } return (int)(lastAddr - (BYTE*)header); } /*********************************************************************/ /* APIs for emitting sections etc */ unsigned __stdcall IlmethodSize(COR_ILMETHOD_FAT* header, BOOL moreSections) { if (header->GetMaxStack() <= 8 && (header->GetFlags() & ~CorILMethod_FormatMask) == 0 && header->GetLocalVarSigTok() == 0 && header->GetCodeSize() < 64 && !moreSections) return(sizeof(COR_ILMETHOD_TINY)); return(sizeof(COR_ILMETHOD_FAT)); } /*********************************************************************/ // emit the header (bestFormat) return amount emitted unsigned __stdcall IlmethodEmit(unsigned size, COR_ILMETHOD_FAT* header, BOOL moreSections, BYTE* outBuff) { #ifndef SOS_INCLUDE #ifdef _DEBUG BYTE* origBuff = outBuff; #endif #endif // !SOS_INCLUDE if (size == 1) { // Tiny format *outBuff++ = (BYTE) (CorILMethod_TinyFormat | (header->GetCodeSize() << 2)); } else { // Fat format _ASSERTE((((size_t) outBuff) & 3) == 0); // header is dword aligned COR_ILMETHOD_FAT* fatHeader = (COR_ILMETHOD_FAT*) outBuff; outBuff += sizeof(COR_ILMETHOD_FAT); *fatHeader = *header; fatHeader->SetFlags(fatHeader->GetFlags() | CorILMethod_FatFormat); _ASSERTE((fatHeader->GetFlags() & CorILMethod_FormatMask) == CorILMethod_FatFormat); if (moreSections) fatHeader->SetFlags(fatHeader->GetFlags() | CorILMethod_MoreSects); fatHeader->SetSize(sizeof(COR_ILMETHOD_FAT) / 4); } #ifndef SOS_INCLUDE _ASSERTE(&origBuff[size] == outBuff); #endif // !SOS_INCLUDE return(size); } /*********************************************************************/ /* static */ IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT* __stdcall SectEH_EHClause(void *pSectEH, unsigned idx, IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT* buff) { if (((COR_ILMETHOD_SECT_EH *)pSectEH)->IsFat()) return(&(((COR_ILMETHOD_SECT_EH *)pSectEH)->Fat.Clauses[idx])); COR_ILMETHOD_SECT_EH_CLAUSE_FAT* fatClause = (COR_ILMETHOD_SECT_EH_CLAUSE_FAT*)buff; COR_ILMETHOD_SECT_EH_CLAUSE_SMALL* smallClause = (COR_ILMETHOD_SECT_EH_CLAUSE_SMALL*)&((COR_ILMETHOD_SECT_EH *)pSectEH)->Small.Clauses[idx]; // mask to remove sign extension - cast just wouldn't work fatClause->SetFlags((CorExceptionFlag)(smallClause->GetFlags()&0x0000ffff)); fatClause->SetClassToken(smallClause->GetClassToken()); fatClause->SetTryOffset(smallClause->GetTryOffset()); fatClause->SetTryLength(smallClause->GetTryLength()); fatClause->SetHandlerLength(smallClause->GetHandlerLength()); fatClause->SetHandlerOffset(smallClause->GetHandlerOffset()); return(buff); } /*********************************************************************/ // compute the size of the section (best format) // codeSize is the size of the method // deprecated unsigned __stdcall SectEH_SizeWithCode(unsigned ehCount, unsigned codeSize) { return((ehCount)? SectEH_SizeWorst(ehCount) : 0); } // will return worse-case size and then Emit will return actual size unsigned __stdcall SectEH_SizeWorst(unsigned ehCount) { return((ehCount)? (COR_ILMETHOD_SECT_EH_FAT::Size(ehCount)) : 0); } // will return exact size which will match the size returned by Emit unsigned __stdcall SectEH_SizeExact(unsigned ehCount, IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT* clauses) { if (ehCount == 0) return(0); unsigned smallSize = COR_ILMETHOD_SECT_EH_SMALL::Size(ehCount); if (smallSize > COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE) return(COR_ILMETHOD_SECT_EH_FAT::Size(ehCount)); for (unsigned i = 0; i < ehCount; i++) { COR_ILMETHOD_SECT_EH_CLAUSE_FAT* fatClause = (COR_ILMETHOD_SECT_EH_CLAUSE_FAT*)&clauses[i]; if (fatClause->GetTryOffset() > 0xFFFF || fatClause->GetTryLength() > 0xFF || fatClause->GetHandlerOffset() > 0xFFFF || fatClause->GetHandlerLength() > 0xFF) { return(COR_ILMETHOD_SECT_EH_FAT::Size(ehCount)); } } return smallSize; } /*********************************************************************/ // emit the section (best format); unsigned __stdcall SectEH_Emit(unsigned size, unsigned ehCount, IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT* clauses, BOOL moreSections, BYTE* outBuff, ULONG* ehTypeOffsets) { if (size == 0) return(0); _ASSERTE((((size_t) outBuff) & 3) == 0); // header is dword aligned BYTE* origBuff = outBuff; if (ehCount <= 0) return 0; // Initialize the ehTypeOffsets array. if (ehTypeOffsets) { for (unsigned int i = 0; i < ehCount; i++) ehTypeOffsets[i] = (ULONG) -1; } if (COR_ILMETHOD_SECT_EH_SMALL::Size(ehCount) < COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE) { COR_ILMETHOD_SECT_EH_SMALL* EHSect = (COR_ILMETHOD_SECT_EH_SMALL*) outBuff; unsigned i; for (i = 0; i < ehCount; i++) { COR_ILMETHOD_SECT_EH_CLAUSE_FAT* fatClause = (COR_ILMETHOD_SECT_EH_CLAUSE_FAT*)&clauses[i]; if (fatClause->GetTryOffset() > 0xFFFF || fatClause->GetTryLength() > 0xFF || fatClause->GetHandlerOffset() > 0xFFFF || fatClause->GetHandlerLength() > 0xFF) { break; // fall through and generate as FAT } _ASSERTE((fatClause->GetFlags() & ~0xFFFF) == 0); _ASSERTE((fatClause->GetTryOffset() & ~0xFFFF) == 0); _ASSERTE((fatClause->GetTryLength() & ~0xFF) == 0); _ASSERTE((fatClause->GetHandlerOffset() & ~0xFFFF) == 0); _ASSERTE((fatClause->GetHandlerLength() & ~0xFF) == 0); COR_ILMETHOD_SECT_EH_CLAUSE_SMALL* smallClause = (COR_ILMETHOD_SECT_EH_CLAUSE_SMALL*)&EHSect->Clauses[i]; smallClause->SetFlags((CorExceptionFlag) fatClause->GetFlags()); smallClause->SetTryOffset(fatClause->GetTryOffset()); smallClause->SetTryLength(fatClause->GetTryLength()); smallClause->SetHandlerOffset(fatClause->GetHandlerOffset()); smallClause->SetHandlerLength(fatClause->GetHandlerLength()); smallClause->SetClassToken(fatClause->GetClassToken()); } if (i >= ehCount) { // if actually got through all the clauses and they are small enough EHSect->Kind = CorILMethod_Sect_EHTable; if (moreSections) EHSect->Kind |= CorILMethod_Sect_MoreSects; #ifndef SOS_INCLUDE EHSect->DataSize = EHSect->Size(ehCount); #else EHSect->DataSize = (BYTE) EHSect->Size(ehCount); #endif // !SOS_INCLUDE EHSect->Reserved = 0; _ASSERTE(EHSect->DataSize == EHSect->Size(ehCount)); // make sure didn't overflow outBuff = (BYTE*) &EHSect->Clauses[ehCount]; // Set the offsets for the exception type tokens. if (ehTypeOffsets) { for (i = 0; i < ehCount; i++) { COR_ILMETHOD_SECT_EH_CLAUSE_SMALL* smallClause = (COR_ILMETHOD_SECT_EH_CLAUSE_SMALL*)&EHSect->Clauses[i]; if (smallClause->GetFlags() == COR_ILEXCEPTION_CLAUSE_NONE) { _ASSERTE(! IsNilToken(smallClause->GetClassToken())); ehTypeOffsets[i] = (ULONG)((BYTE *)&smallClause->ClassToken - origBuff); } } } return(size); } } // either total size too big or one of constituent elements too big (eg. offset or length) COR_ILMETHOD_SECT_EH_FAT* EHSect = (COR_ILMETHOD_SECT_EH_FAT*) outBuff; EHSect->SetKind(CorILMethod_Sect_EHTable | CorILMethod_Sect_FatFormat); if (moreSections) EHSect->SetKind(EHSect->GetKind() | CorILMethod_Sect_MoreSects); EHSect->SetDataSize(EHSect->Size(ehCount)); memcpy(EHSect->Clauses, clauses, ehCount * sizeof(COR_ILMETHOD_SECT_EH_CLAUSE_FAT)); outBuff = (BYTE*) &EHSect->Clauses[ehCount]; _ASSERTE(&origBuff[size] == outBuff); // Set the offsets for the exception type tokens. if (ehTypeOffsets) { for (unsigned int i = 0; i < ehCount; i++) { COR_ILMETHOD_SECT_EH_CLAUSE_FAT* fatClause = (COR_ILMETHOD_SECT_EH_CLAUSE_FAT*)&EHSect->Clauses[i]; if (fatClause->GetFlags() == COR_ILEXCEPTION_CLAUSE_NONE) { _ASSERTE(! IsNilToken(fatClause->GetClassToken())); ehTypeOffsets[i] = (ULONG)((BYTE *)&fatClause->ClassToken - origBuff); } } } return(size); } } // extern "C"
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/ShiftArithmeticRounded.Vector128.Int16.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void ShiftArithmeticRounded_Vector128_Int16() { var test = new SimpleBinaryOpTest__ShiftArithmeticRounded_Vector128_Int16(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleBinaryOpTest__ShiftArithmeticRounded_Vector128_Int16 { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Int16[] inArray1, Int16[] inArray2, Int16[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int16>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Int16>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int16>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Int16, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Int16, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector128<Int16> _fld1; public Vector128<Int16> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref testStruct._fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref testStruct._fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__ShiftArithmeticRounded_Vector128_Int16 testClass) { var result = AdvSimd.ShiftArithmeticRounded(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__ShiftArithmeticRounded_Vector128_Int16 testClass) { fixed (Vector128<Int16>* pFld1 = &_fld1) fixed (Vector128<Int16>* pFld2 = &_fld2) { var result = AdvSimd.ShiftArithmeticRounded( AdvSimd.LoadVector128((Int16*)(pFld1)), AdvSimd.LoadVector128((Int16*)(pFld2)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Int16>>() / sizeof(Int16); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Int16>>() / sizeof(Int16); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int16>>() / sizeof(Int16); private static Int16[] _data1 = new Int16[Op1ElementCount]; private static Int16[] _data2 = new Int16[Op2ElementCount]; private static Vector128<Int16> _clsVar1; private static Vector128<Int16> _clsVar2; private Vector128<Int16> _fld1; private Vector128<Int16> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__ShiftArithmeticRounded_Vector128_Int16() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); } public SimpleBinaryOpTest__ShiftArithmeticRounded_Vector128_Int16() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } _dataTable = new DataTable(_data1, _data2, new Int16[RetElementCount], LargestVectorSize); } public bool IsSupported => AdvSimd.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = AdvSimd.ShiftArithmeticRounded( Unsafe.Read<Vector128<Int16>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Int16>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = AdvSimd.ShiftArithmeticRounded( AdvSimd.LoadVector128((Int16*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Int16*)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.ShiftArithmeticRounded), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Int16>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Int16>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int16>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.ShiftArithmeticRounded), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((Int16*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Int16*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int16>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.ShiftArithmeticRounded( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<Int16>* pClsVar1 = &_clsVar1) fixed (Vector128<Int16>* pClsVar2 = &_clsVar2) { var result = AdvSimd.ShiftArithmeticRounded( AdvSimd.LoadVector128((Int16*)(pClsVar1)), AdvSimd.LoadVector128((Int16*)(pClsVar2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector128<Int16>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Int16>>(_dataTable.inArray2Ptr); var result = AdvSimd.ShiftArithmeticRounded(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector128((Int16*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((Int16*)(_dataTable.inArray2Ptr)); var result = AdvSimd.ShiftArithmeticRounded(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__ShiftArithmeticRounded_Vector128_Int16(); var result = AdvSimd.ShiftArithmeticRounded(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleBinaryOpTest__ShiftArithmeticRounded_Vector128_Int16(); fixed (Vector128<Int16>* pFld1 = &test._fld1) fixed (Vector128<Int16>* pFld2 = &test._fld2) { var result = AdvSimd.ShiftArithmeticRounded( AdvSimd.LoadVector128((Int16*)(pFld1)), AdvSimd.LoadVector128((Int16*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.ShiftArithmeticRounded(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<Int16>* pFld1 = &_fld1) fixed (Vector128<Int16>* pFld2 = &_fld2) { var result = AdvSimd.ShiftArithmeticRounded( AdvSimd.LoadVector128((Int16*)(pFld1)), AdvSimd.LoadVector128((Int16*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = AdvSimd.ShiftArithmeticRounded(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = AdvSimd.ShiftArithmeticRounded( AdvSimd.LoadVector128((Int16*)(&test._fld1)), AdvSimd.LoadVector128((Int16*)(&test._fld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector128<Int16> op1, Vector128<Int16> op2, void* result, [CallerMemberName] string method = "") { Int16[] inArray1 = new Int16[Op1ElementCount]; Int16[] inArray2 = new Int16[Op2ElementCount]; Int16[] outArray = new Int16[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int16>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Int16[] inArray1 = new Int16[Op1ElementCount]; Int16[] inArray2 = new Int16[Op2ElementCount]; Int16[] outArray = new Int16[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Int16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Int16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int16>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Int16[] left, Int16[] right, Int16[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.ShiftArithmeticRounded(left[i], right[i]) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.ShiftArithmeticRounded)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void ShiftArithmeticRounded_Vector128_Int16() { var test = new SimpleBinaryOpTest__ShiftArithmeticRounded_Vector128_Int16(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleBinaryOpTest__ShiftArithmeticRounded_Vector128_Int16 { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Int16[] inArray1, Int16[] inArray2, Int16[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int16>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Int16>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int16>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Int16, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Int16, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector128<Int16> _fld1; public Vector128<Int16> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref testStruct._fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref testStruct._fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__ShiftArithmeticRounded_Vector128_Int16 testClass) { var result = AdvSimd.ShiftArithmeticRounded(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__ShiftArithmeticRounded_Vector128_Int16 testClass) { fixed (Vector128<Int16>* pFld1 = &_fld1) fixed (Vector128<Int16>* pFld2 = &_fld2) { var result = AdvSimd.ShiftArithmeticRounded( AdvSimd.LoadVector128((Int16*)(pFld1)), AdvSimd.LoadVector128((Int16*)(pFld2)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Int16>>() / sizeof(Int16); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Int16>>() / sizeof(Int16); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int16>>() / sizeof(Int16); private static Int16[] _data1 = new Int16[Op1ElementCount]; private static Int16[] _data2 = new Int16[Op2ElementCount]; private static Vector128<Int16> _clsVar1; private static Vector128<Int16> _clsVar2; private Vector128<Int16> _fld1; private Vector128<Int16> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__ShiftArithmeticRounded_Vector128_Int16() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); } public SimpleBinaryOpTest__ShiftArithmeticRounded_Vector128_Int16() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } _dataTable = new DataTable(_data1, _data2, new Int16[RetElementCount], LargestVectorSize); } public bool IsSupported => AdvSimd.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = AdvSimd.ShiftArithmeticRounded( Unsafe.Read<Vector128<Int16>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Int16>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = AdvSimd.ShiftArithmeticRounded( AdvSimd.LoadVector128((Int16*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Int16*)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.ShiftArithmeticRounded), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Int16>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Int16>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int16>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.ShiftArithmeticRounded), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((Int16*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Int16*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int16>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.ShiftArithmeticRounded( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<Int16>* pClsVar1 = &_clsVar1) fixed (Vector128<Int16>* pClsVar2 = &_clsVar2) { var result = AdvSimd.ShiftArithmeticRounded( AdvSimd.LoadVector128((Int16*)(pClsVar1)), AdvSimd.LoadVector128((Int16*)(pClsVar2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector128<Int16>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Int16>>(_dataTable.inArray2Ptr); var result = AdvSimd.ShiftArithmeticRounded(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector128((Int16*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((Int16*)(_dataTable.inArray2Ptr)); var result = AdvSimd.ShiftArithmeticRounded(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__ShiftArithmeticRounded_Vector128_Int16(); var result = AdvSimd.ShiftArithmeticRounded(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleBinaryOpTest__ShiftArithmeticRounded_Vector128_Int16(); fixed (Vector128<Int16>* pFld1 = &test._fld1) fixed (Vector128<Int16>* pFld2 = &test._fld2) { var result = AdvSimd.ShiftArithmeticRounded( AdvSimd.LoadVector128((Int16*)(pFld1)), AdvSimd.LoadVector128((Int16*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.ShiftArithmeticRounded(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<Int16>* pFld1 = &_fld1) fixed (Vector128<Int16>* pFld2 = &_fld2) { var result = AdvSimd.ShiftArithmeticRounded( AdvSimd.LoadVector128((Int16*)(pFld1)), AdvSimd.LoadVector128((Int16*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = AdvSimd.ShiftArithmeticRounded(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = AdvSimd.ShiftArithmeticRounded( AdvSimd.LoadVector128((Int16*)(&test._fld1)), AdvSimd.LoadVector128((Int16*)(&test._fld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector128<Int16> op1, Vector128<Int16> op2, void* result, [CallerMemberName] string method = "") { Int16[] inArray1 = new Int16[Op1ElementCount]; Int16[] inArray2 = new Int16[Op2ElementCount]; Int16[] outArray = new Int16[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int16>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Int16[] inArray1 = new Int16[Op1ElementCount]; Int16[] inArray2 = new Int16[Op2ElementCount]; Int16[] outArray = new Int16[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Int16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Int16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int16>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Int16[] left, Int16[] right, Int16[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.ShiftArithmeticRounded(left[i], right[i]) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.ShiftArithmeticRounded)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/tests/Regressions/coreclr/0582/csgen.1.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <ItemGroup> <Compile Include="csgen.1.cs" /> </ItemGroup> <ItemGroup> <NoWarn Include="162" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <ItemGroup> <Compile Include="csgen.1.cs" /> </ItemGroup> <ItemGroup> <NoWarn Include="162" /> </ItemGroup> </Project>
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/AddScalar.Vector64.UInt64.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void AddScalar_Vector64_UInt64() { var test = new SimpleBinaryOpTest__AddScalar_Vector64_UInt64(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleBinaryOpTest__AddScalar_Vector64_UInt64 { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(UInt64[] inArray1, UInt64[] inArray2, UInt64[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<UInt64>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<UInt64>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<UInt64>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<UInt64, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<UInt64, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector64<UInt64> _fld1; public Vector64<UInt64> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref testStruct._fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref testStruct._fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__AddScalar_Vector64_UInt64 testClass) { var result = AdvSimd.AddScalar(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__AddScalar_Vector64_UInt64 testClass) { fixed (Vector64<UInt64>* pFld1 = &_fld1) fixed (Vector64<UInt64>* pFld2 = &_fld2) { var result = AdvSimd.AddScalar( AdvSimd.LoadVector64((UInt64*)(pFld1)), AdvSimd.LoadVector64((UInt64*)(pFld2)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 8; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector64<UInt64>>() / sizeof(UInt64); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector64<UInt64>>() / sizeof(UInt64); private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<UInt64>>() / sizeof(UInt64); private static UInt64[] _data1 = new UInt64[Op1ElementCount]; private static UInt64[] _data2 = new UInt64[Op2ElementCount]; private static Vector64<UInt64> _clsVar1; private static Vector64<UInt64> _clsVar2; private Vector64<UInt64> _fld1; private Vector64<UInt64> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__AddScalar_Vector64_UInt64() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); } public SimpleBinaryOpTest__AddScalar_Vector64_UInt64() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } _dataTable = new DataTable(_data1, _data2, new UInt64[RetElementCount], LargestVectorSize); } public bool IsSupported => AdvSimd.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = AdvSimd.AddScalar( Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = AdvSimd.AddScalar( AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.AddScalar), new Type[] { typeof(Vector64<UInt64>), typeof(Vector64<UInt64>) }) .Invoke(null, new object[] { Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<UInt64>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.AddScalar), new Type[] { typeof(Vector64<UInt64>), typeof(Vector64<UInt64>) }) .Invoke(null, new object[] { AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<UInt64>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.AddScalar( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector64<UInt64>* pClsVar1 = &_clsVar1) fixed (Vector64<UInt64>* pClsVar2 = &_clsVar2) { var result = AdvSimd.AddScalar( AdvSimd.LoadVector64((UInt64*)(pClsVar1)), AdvSimd.LoadVector64((UInt64*)(pClsVar2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray2Ptr); var result = AdvSimd.AddScalar(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray2Ptr)); var result = AdvSimd.AddScalar(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__AddScalar_Vector64_UInt64(); var result = AdvSimd.AddScalar(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleBinaryOpTest__AddScalar_Vector64_UInt64(); fixed (Vector64<UInt64>* pFld1 = &test._fld1) fixed (Vector64<UInt64>* pFld2 = &test._fld2) { var result = AdvSimd.AddScalar( AdvSimd.LoadVector64((UInt64*)(pFld1)), AdvSimd.LoadVector64((UInt64*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.AddScalar(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector64<UInt64>* pFld1 = &_fld1) fixed (Vector64<UInt64>* pFld2 = &_fld2) { var result = AdvSimd.AddScalar( AdvSimd.LoadVector64((UInt64*)(pFld1)), AdvSimd.LoadVector64((UInt64*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = AdvSimd.AddScalar(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = AdvSimd.AddScalar( AdvSimd.LoadVector64((UInt64*)(&test._fld1)), AdvSimd.LoadVector64((UInt64*)(&test._fld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector64<UInt64> op1, Vector64<UInt64> op2, void* result, [CallerMemberName] string method = "") { UInt64[] inArray1 = new UInt64[Op1ElementCount]; UInt64[] inArray2 = new UInt64[Op2ElementCount]; UInt64[] outArray = new UInt64[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { UInt64[] inArray1 = new UInt64[Op1ElementCount]; UInt64[] inArray2 = new UInt64[Op2ElementCount]; UInt64[] outArray = new UInt64[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(UInt64[] left, UInt64[] right, UInt64[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (Helpers.Add(left[0], right[0]) != result[0]) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (result[i] != 0) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.AddScalar)}<UInt64>(Vector64<UInt64>, Vector64<UInt64>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void AddScalar_Vector64_UInt64() { var test = new SimpleBinaryOpTest__AddScalar_Vector64_UInt64(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleBinaryOpTest__AddScalar_Vector64_UInt64 { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(UInt64[] inArray1, UInt64[] inArray2, UInt64[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<UInt64>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<UInt64>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<UInt64>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<UInt64, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<UInt64, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector64<UInt64> _fld1; public Vector64<UInt64> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref testStruct._fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref testStruct._fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__AddScalar_Vector64_UInt64 testClass) { var result = AdvSimd.AddScalar(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__AddScalar_Vector64_UInt64 testClass) { fixed (Vector64<UInt64>* pFld1 = &_fld1) fixed (Vector64<UInt64>* pFld2 = &_fld2) { var result = AdvSimd.AddScalar( AdvSimd.LoadVector64((UInt64*)(pFld1)), AdvSimd.LoadVector64((UInt64*)(pFld2)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 8; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector64<UInt64>>() / sizeof(UInt64); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector64<UInt64>>() / sizeof(UInt64); private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<UInt64>>() / sizeof(UInt64); private static UInt64[] _data1 = new UInt64[Op1ElementCount]; private static UInt64[] _data2 = new UInt64[Op2ElementCount]; private static Vector64<UInt64> _clsVar1; private static Vector64<UInt64> _clsVar2; private Vector64<UInt64> _fld1; private Vector64<UInt64> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__AddScalar_Vector64_UInt64() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); } public SimpleBinaryOpTest__AddScalar_Vector64_UInt64() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } _dataTable = new DataTable(_data1, _data2, new UInt64[RetElementCount], LargestVectorSize); } public bool IsSupported => AdvSimd.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = AdvSimd.AddScalar( Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = AdvSimd.AddScalar( AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.AddScalar), new Type[] { typeof(Vector64<UInt64>), typeof(Vector64<UInt64>) }) .Invoke(null, new object[] { Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<UInt64>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.AddScalar), new Type[] { typeof(Vector64<UInt64>), typeof(Vector64<UInt64>) }) .Invoke(null, new object[] { AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<UInt64>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.AddScalar( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector64<UInt64>* pClsVar1 = &_clsVar1) fixed (Vector64<UInt64>* pClsVar2 = &_clsVar2) { var result = AdvSimd.AddScalar( AdvSimd.LoadVector64((UInt64*)(pClsVar1)), AdvSimd.LoadVector64((UInt64*)(pClsVar2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector64<UInt64>>(_dataTable.inArray2Ptr); var result = AdvSimd.AddScalar(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector64((UInt64*)(_dataTable.inArray2Ptr)); var result = AdvSimd.AddScalar(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__AddScalar_Vector64_UInt64(); var result = AdvSimd.AddScalar(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleBinaryOpTest__AddScalar_Vector64_UInt64(); fixed (Vector64<UInt64>* pFld1 = &test._fld1) fixed (Vector64<UInt64>* pFld2 = &test._fld2) { var result = AdvSimd.AddScalar( AdvSimd.LoadVector64((UInt64*)(pFld1)), AdvSimd.LoadVector64((UInt64*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.AddScalar(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector64<UInt64>* pFld1 = &_fld1) fixed (Vector64<UInt64>* pFld2 = &_fld2) { var result = AdvSimd.AddScalar( AdvSimd.LoadVector64((UInt64*)(pFld1)), AdvSimd.LoadVector64((UInt64*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = AdvSimd.AddScalar(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = AdvSimd.AddScalar( AdvSimd.LoadVector64((UInt64*)(&test._fld1)), AdvSimd.LoadVector64((UInt64*)(&test._fld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector64<UInt64> op1, Vector64<UInt64> op2, void* result, [CallerMemberName] string method = "") { UInt64[] inArray1 = new UInt64[Op1ElementCount]; UInt64[] inArray2 = new UInt64[Op2ElementCount]; UInt64[] outArray = new UInt64[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { UInt64[] inArray1 = new UInt64[Op1ElementCount]; UInt64[] inArray2 = new UInt64[Op2ElementCount]; UInt64[] outArray = new UInt64[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<UInt64>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(UInt64[] left, UInt64[] right, UInt64[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (Helpers.Add(left[0], right[0]) != result[0]) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (result[i] != 0) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.AddScalar)}<UInt64>(Vector64<UInt64>, Vector64<UInt64>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/libraries/System.IO.FileSystem/tests/Directory/GetDirectoryRoot.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; namespace System.IO.Tests { public class Directory_GetDirectoryRoot : FileSystemTest { [Fact] public void NullPath_ThrowsArgumentNullException() { Assert.Throws<ArgumentNullException>(() => Directory.GetDirectoryRoot(null)); } [Fact] public void GetRootOfRoot() { string root = Directory.GetDirectoryRoot(Path.GetPathRoot(TestDirectory)); Assert.Equal(Path.GetPathRoot(TestDirectory), root); } [Fact] public void RelativeDirectory() { string root = Directory.GetDirectoryRoot(Path.DirectorySeparatorChar + "testDir"); Assert.Equal(Path.GetPathRoot(Directory.GetCurrentDirectory()), root); } [Fact] public void NestedDirectories() { string root = Directory.GetDirectoryRoot(Path.Combine("a", "a", "a", "b") + Path.DirectorySeparatorChar); Assert.Equal(Path.GetPathRoot(Directory.GetCurrentDirectory()), root); } [Fact] public void DotPaths() { string root = Directory.GetDirectoryRoot(Path.Combine("Test1", ".", "test2", "..", "test3")); Assert.Equal(Path.GetPathRoot(Directory.GetCurrentDirectory()), root); } [Fact] public void WhitespacePaths() { string root = Directory.GetDirectoryRoot(Path.Combine("T es t1", "te s t2", "t est 3")); Assert.Equal(Path.GetPathRoot(Directory.GetCurrentDirectory()), root); } [Fact] [PlatformSpecific(TestPlatforms.Windows)] // UNC shares public void UNCShares() { string root = Directory.GetDirectoryRoot(new string(Path.DirectorySeparatorChar, 2) + Path.Combine("Test1", "test2", "test3")); Assert.Equal(new string(Path.DirectorySeparatorChar, 2) + Path.Combine("Test1", "test2"), root); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; namespace System.IO.Tests { public class Directory_GetDirectoryRoot : FileSystemTest { [Fact] public void NullPath_ThrowsArgumentNullException() { Assert.Throws<ArgumentNullException>(() => Directory.GetDirectoryRoot(null)); } [Fact] public void GetRootOfRoot() { string root = Directory.GetDirectoryRoot(Path.GetPathRoot(TestDirectory)); Assert.Equal(Path.GetPathRoot(TestDirectory), root); } [Fact] public void RelativeDirectory() { string root = Directory.GetDirectoryRoot(Path.DirectorySeparatorChar + "testDir"); Assert.Equal(Path.GetPathRoot(Directory.GetCurrentDirectory()), root); } [Fact] public void NestedDirectories() { string root = Directory.GetDirectoryRoot(Path.Combine("a", "a", "a", "b") + Path.DirectorySeparatorChar); Assert.Equal(Path.GetPathRoot(Directory.GetCurrentDirectory()), root); } [Fact] public void DotPaths() { string root = Directory.GetDirectoryRoot(Path.Combine("Test1", ".", "test2", "..", "test3")); Assert.Equal(Path.GetPathRoot(Directory.GetCurrentDirectory()), root); } [Fact] public void WhitespacePaths() { string root = Directory.GetDirectoryRoot(Path.Combine("T es t1", "te s t2", "t est 3")); Assert.Equal(Path.GetPathRoot(Directory.GetCurrentDirectory()), root); } [Fact] [PlatformSpecific(TestPlatforms.Windows)] // UNC shares public void UNCShares() { string root = Directory.GetDirectoryRoot(new string(Path.DirectorySeparatorChar, 2) + Path.Combine("Test1", "test2", "test3")); Assert.Equal(new string(Path.DirectorySeparatorChar, 2) + Path.Combine("Test1", "test2"), root); } } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/tests/JIT/opt/LocAlloc/localloc.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // Conversion of small fixed localloc to locals // and inlining of localloc callees using System; class L { unsafe static int Use4() { byte* i = stackalloc byte[4]; i[2] = 50; return i[2] * 2; } unsafe static int Use(int x) { byte* i = stackalloc byte[x]; i[1] = 50; return i[1] * 2; } public static int Main() { int v0 = Use4(); int v1 = Use(10); int v2 = Use(100); int v3 = Use(v0); int v4 = 0; int v5 = 0; int v6 = 0; for (int i = 0; i < 7; i++) { v5 += Use4(); v5 += Use(4); v6 += Use(v0); } return v0 + v1 + v2 + v3 + v4 + v5 + v6 - 2400; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // Conversion of small fixed localloc to locals // and inlining of localloc callees using System; class L { unsafe static int Use4() { byte* i = stackalloc byte[4]; i[2] = 50; return i[2] * 2; } unsafe static int Use(int x) { byte* i = stackalloc byte[x]; i[1] = 50; return i[1] * 2; } public static int Main() { int v0 = Use4(); int v1 = Use(10); int v2 = Use(100); int v3 = Use(v0); int v4 = 0; int v5 = 0; int v6 = 0; for (int i = 0; i < 7; i++) { v5 += Use4(); v5 += Use(4); v6 += Use(v0); } return v0 + v1 + v2 + v3 + v4 + v5 + v6 - 2400; } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/libraries/System.Reflection.Emit/tests/TypeBuilder/TypeBuilderSize.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; namespace System.Reflection.Emit.Tests { public class TypeBuilderSize { [Fact] public void Size_NoneSet_ReturnsUnspecified() { TypeBuilder type = Helpers.DynamicType(TypeAttributes.Class | TypeAttributes.Public); Assert.Equal(0, type.Size); type.DefineGenericParameters("T", "U"); Assert.Equal(0, type.Size); } [Theory] [InlineData(int.MaxValue)] [InlineData(1024)] [InlineData(100)] [InlineData(0)] [InlineData(-1)] [InlineData(int.MinValue)] public void Size_Set_ReturnsExpected(int size) { ModuleBuilder module = Helpers.DynamicModule(); TypeBuilder type = module.DefineType("TestType", TypeAttributes.Class | TypeAttributes.Public, null, size); Assert.Equal(size, type.Size); type.DefineGenericParameters("T", "U"); Assert.Equal(size, type.Size); // We should be able to create the type no matter the size Assert.Equal(type.Name, type.CreateTypeInfo().Name); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; namespace System.Reflection.Emit.Tests { public class TypeBuilderSize { [Fact] public void Size_NoneSet_ReturnsUnspecified() { TypeBuilder type = Helpers.DynamicType(TypeAttributes.Class | TypeAttributes.Public); Assert.Equal(0, type.Size); type.DefineGenericParameters("T", "U"); Assert.Equal(0, type.Size); } [Theory] [InlineData(int.MaxValue)] [InlineData(1024)] [InlineData(100)] [InlineData(0)] [InlineData(-1)] [InlineData(int.MinValue)] public void Size_Set_ReturnsExpected(int size) { ModuleBuilder module = Helpers.DynamicModule(); TypeBuilder type = module.DefineType("TestType", TypeAttributes.Class | TypeAttributes.Public, null, size); Assert.Equal(size, type.Size); type.DefineGenericParameters("T", "U"); Assert.Equal(size, type.Size); // We should be able to create the type no matter the size Assert.Equal(type.Name, type.CreateTypeInfo().Name); } } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/tests/JIT/jit64/valuetypes/nullable/box-unbox/null/box-unbox-null010.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>PdbOnly</DebugType> </PropertyGroup> <ItemGroup> <Compile Include="box-unbox-null010.cs" /> <Compile Include="..\structdef.cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>PdbOnly</DebugType> </PropertyGroup> <ItemGroup> <Compile Include="box-unbox-null010.cs" /> <Compile Include="..\structdef.cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/tests/JIT/SIMD/Plane.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Numerics; class PlaneTest { private const int Pass = 100; private const int Fail = -1; public static int PlaneCreateFromVerticesTest() { int returnVal = Pass; Vector3 point1 = new Vector3(0.0f, 1.0f, 1.0f); Vector3 point2 = new Vector3(0.0f, 0.0f, 1.0f); Vector3 point3 = new Vector3(1.0f, 0.0f, 1.0f); Plane target = Plane.CreateFromVertices(point1, point2, point3); Plane expected = new Plane(new Vector3(0, 0, 1), -1.0f); if (!target.Equals(expected)) { returnVal = Fail; } return returnVal; } static int Main() { return PlaneCreateFromVerticesTest(); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Numerics; class PlaneTest { private const int Pass = 100; private const int Fail = -1; public static int PlaneCreateFromVerticesTest() { int returnVal = Pass; Vector3 point1 = new Vector3(0.0f, 1.0f, 1.0f); Vector3 point2 = new Vector3(0.0f, 0.0f, 1.0f); Vector3 point3 = new Vector3(1.0f, 0.0f, 1.0f); Plane target = Plane.CreateFromVertices(point1, point2, point3); Plane expected = new Plane(new Vector3(0, 0, 1), -1.0f); if (!target.Equals(expected)) { returnVal = Fail; } return returnVal; } static int Main() { return PlaneCreateFromVerticesTest(); } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoByRefType.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Diagnostics; namespace System.Reflection.TypeLoading { /// <summary> /// All RoTypes that return true for IsByRef. /// </summary> internal sealed class RoByRefType : RoHasElementType { internal RoByRefType(RoType elementType) : base(elementType) { Debug.Assert(elementType != null); } protected sealed override bool IsArrayImpl() => false; public sealed override bool IsSZArray => false; public sealed override bool IsVariableBoundArray => false; protected sealed override bool IsByRefImpl() => true; protected sealed override bool IsPointerImpl() => false; public sealed override int GetArrayRank() => throw new ArgumentException(SR.Argument_HasToBeArrayClass); protected sealed override TypeAttributes ComputeAttributeFlags() => TypeAttributes.Public; protected sealed override string Suffix => "&"; protected sealed override RoType? ComputeBaseTypeWithoutDesktopQuirk() => null; protected sealed override IEnumerable<RoType> ComputeDirectlyImplementedInterfaces() => Array.Empty<RoType>(); internal sealed override IEnumerable<ConstructorInfo> GetConstructorsCore(NameFilter? filter) => Array.Empty<ConstructorInfo>(); internal sealed override IEnumerable<MethodInfo> GetMethodsCore(NameFilter? filter, Type reflectedType) => Array.Empty<MethodInfo>(); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Diagnostics; namespace System.Reflection.TypeLoading { /// <summary> /// All RoTypes that return true for IsByRef. /// </summary> internal sealed class RoByRefType : RoHasElementType { internal RoByRefType(RoType elementType) : base(elementType) { Debug.Assert(elementType != null); } protected sealed override bool IsArrayImpl() => false; public sealed override bool IsSZArray => false; public sealed override bool IsVariableBoundArray => false; protected sealed override bool IsByRefImpl() => true; protected sealed override bool IsPointerImpl() => false; public sealed override int GetArrayRank() => throw new ArgumentException(SR.Argument_HasToBeArrayClass); protected sealed override TypeAttributes ComputeAttributeFlags() => TypeAttributes.Public; protected sealed override string Suffix => "&"; protected sealed override RoType? ComputeBaseTypeWithoutDesktopQuirk() => null; protected sealed override IEnumerable<RoType> ComputeDirectlyImplementedInterfaces() => Array.Empty<RoType>(); internal sealed override IEnumerable<ConstructorInfo> GetConstructorsCore(NameFilter? filter) => Array.Empty<ConstructorInfo>(); internal sealed override IEnumerable<MethodInfo> GetMethodsCore(NameFilter? filter, Type reflectedType) => Array.Empty<MethodInfo>(); } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/AbsoluteDifference.Vector128.Int16.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void AbsoluteDifference_Vector128_Int16() { var test = new SimpleBinaryOpTest__AbsoluteDifference_Vector128_Int16(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleBinaryOpTest__AbsoluteDifference_Vector128_Int16 { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Int16[] inArray1, Int16[] inArray2, UInt16[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int16>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Int16>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<UInt16>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Int16, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Int16, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector128<Int16> _fld1; public Vector128<Int16> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref testStruct._fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref testStruct._fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__AbsoluteDifference_Vector128_Int16 testClass) { var result = AdvSimd.AbsoluteDifference(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__AbsoluteDifference_Vector128_Int16 testClass) { fixed (Vector128<Int16>* pFld1 = &_fld1) fixed (Vector128<Int16>* pFld2 = &_fld2) { var result = AdvSimd.AbsoluteDifference( AdvSimd.LoadVector128((Int16*)(pFld1)), AdvSimd.LoadVector128((Int16*)(pFld2)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Int16>>() / sizeof(Int16); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Int16>>() / sizeof(Int16); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<UInt16>>() / sizeof(UInt16); private static Int16[] _data1 = new Int16[Op1ElementCount]; private static Int16[] _data2 = new Int16[Op2ElementCount]; private static Vector128<Int16> _clsVar1; private static Vector128<Int16> _clsVar2; private Vector128<Int16> _fld1; private Vector128<Int16> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__AbsoluteDifference_Vector128_Int16() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); } public SimpleBinaryOpTest__AbsoluteDifference_Vector128_Int16() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } _dataTable = new DataTable(_data1, _data2, new UInt16[RetElementCount], LargestVectorSize); } public bool IsSupported => AdvSimd.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = AdvSimd.AbsoluteDifference( Unsafe.Read<Vector128<Int16>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Int16>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = AdvSimd.AbsoluteDifference( AdvSimd.LoadVector128((Int16*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Int16*)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.AbsoluteDifference), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Int16>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Int16>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt16>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.AbsoluteDifference), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((Int16*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Int16*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt16>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.AbsoluteDifference( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<Int16>* pClsVar1 = &_clsVar1) fixed (Vector128<Int16>* pClsVar2 = &_clsVar2) { var result = AdvSimd.AbsoluteDifference( AdvSimd.LoadVector128((Int16*)(pClsVar1)), AdvSimd.LoadVector128((Int16*)(pClsVar2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector128<Int16>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Int16>>(_dataTable.inArray2Ptr); var result = AdvSimd.AbsoluteDifference(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector128((Int16*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((Int16*)(_dataTable.inArray2Ptr)); var result = AdvSimd.AbsoluteDifference(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__AbsoluteDifference_Vector128_Int16(); var result = AdvSimd.AbsoluteDifference(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleBinaryOpTest__AbsoluteDifference_Vector128_Int16(); fixed (Vector128<Int16>* pFld1 = &test._fld1) fixed (Vector128<Int16>* pFld2 = &test._fld2) { var result = AdvSimd.AbsoluteDifference( AdvSimd.LoadVector128((Int16*)(pFld1)), AdvSimd.LoadVector128((Int16*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.AbsoluteDifference(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<Int16>* pFld1 = &_fld1) fixed (Vector128<Int16>* pFld2 = &_fld2) { var result = AdvSimd.AbsoluteDifference( AdvSimd.LoadVector128((Int16*)(pFld1)), AdvSimd.LoadVector128((Int16*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = AdvSimd.AbsoluteDifference(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = AdvSimd.AbsoluteDifference( AdvSimd.LoadVector128((Int16*)(&test._fld1)), AdvSimd.LoadVector128((Int16*)(&test._fld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector128<Int16> op1, Vector128<Int16> op2, void* result, [CallerMemberName] string method = "") { Int16[] inArray1 = new Int16[Op1ElementCount]; Int16[] inArray2 = new Int16[Op2ElementCount]; UInt16[] outArray = new UInt16[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Int16[] inArray1 = new Int16[Op1ElementCount]; Int16[] inArray2 = new Int16[Op2ElementCount]; UInt16[] outArray = new UInt16[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Int16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Int16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Int16[] left, Int16[] right, UInt16[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.AbsoluteDifference(left[i], right[i]) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.AbsoluteDifference)}<UInt16>(Vector128<Int16>, Vector128<Int16>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void AbsoluteDifference_Vector128_Int16() { var test = new SimpleBinaryOpTest__AbsoluteDifference_Vector128_Int16(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleBinaryOpTest__AbsoluteDifference_Vector128_Int16 { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Int16[] inArray1, Int16[] inArray2, UInt16[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int16>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Int16>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<UInt16>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Int16, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Int16, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector128<Int16> _fld1; public Vector128<Int16> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref testStruct._fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref testStruct._fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__AbsoluteDifference_Vector128_Int16 testClass) { var result = AdvSimd.AbsoluteDifference(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__AbsoluteDifference_Vector128_Int16 testClass) { fixed (Vector128<Int16>* pFld1 = &_fld1) fixed (Vector128<Int16>* pFld2 = &_fld2) { var result = AdvSimd.AbsoluteDifference( AdvSimd.LoadVector128((Int16*)(pFld1)), AdvSimd.LoadVector128((Int16*)(pFld2)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Int16>>() / sizeof(Int16); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Int16>>() / sizeof(Int16); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<UInt16>>() / sizeof(UInt16); private static Int16[] _data1 = new Int16[Op1ElementCount]; private static Int16[] _data2 = new Int16[Op2ElementCount]; private static Vector128<Int16> _clsVar1; private static Vector128<Int16> _clsVar2; private Vector128<Int16> _fld1; private Vector128<Int16> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__AbsoluteDifference_Vector128_Int16() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); } public SimpleBinaryOpTest__AbsoluteDifference_Vector128_Int16() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } _dataTable = new DataTable(_data1, _data2, new UInt16[RetElementCount], LargestVectorSize); } public bool IsSupported => AdvSimd.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = AdvSimd.AbsoluteDifference( Unsafe.Read<Vector128<Int16>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Int16>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = AdvSimd.AbsoluteDifference( AdvSimd.LoadVector128((Int16*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Int16*)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.AbsoluteDifference), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Int16>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Int16>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt16>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.AbsoluteDifference), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((Int16*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Int16*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt16>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.AbsoluteDifference( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<Int16>* pClsVar1 = &_clsVar1) fixed (Vector128<Int16>* pClsVar2 = &_clsVar2) { var result = AdvSimd.AbsoluteDifference( AdvSimd.LoadVector128((Int16*)(pClsVar1)), AdvSimd.LoadVector128((Int16*)(pClsVar2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector128<Int16>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Int16>>(_dataTable.inArray2Ptr); var result = AdvSimd.AbsoluteDifference(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector128((Int16*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((Int16*)(_dataTable.inArray2Ptr)); var result = AdvSimd.AbsoluteDifference(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__AbsoluteDifference_Vector128_Int16(); var result = AdvSimd.AbsoluteDifference(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleBinaryOpTest__AbsoluteDifference_Vector128_Int16(); fixed (Vector128<Int16>* pFld1 = &test._fld1) fixed (Vector128<Int16>* pFld2 = &test._fld2) { var result = AdvSimd.AbsoluteDifference( AdvSimd.LoadVector128((Int16*)(pFld1)), AdvSimd.LoadVector128((Int16*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.AbsoluteDifference(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<Int16>* pFld1 = &_fld1) fixed (Vector128<Int16>* pFld2 = &_fld2) { var result = AdvSimd.AbsoluteDifference( AdvSimd.LoadVector128((Int16*)(pFld1)), AdvSimd.LoadVector128((Int16*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = AdvSimd.AbsoluteDifference(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = AdvSimd.AbsoluteDifference( AdvSimd.LoadVector128((Int16*)(&test._fld1)), AdvSimd.LoadVector128((Int16*)(&test._fld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector128<Int16> op1, Vector128<Int16> op2, void* result, [CallerMemberName] string method = "") { Int16[] inArray1 = new Int16[Op1ElementCount]; Int16[] inArray2 = new Int16[Op2ElementCount]; UInt16[] outArray = new UInt16[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Int16[] inArray1 = new Int16[Op1ElementCount]; Int16[] inArray2 = new Int16[Op2ElementCount]; UInt16[] outArray = new UInt16[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Int16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Int16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Int16[] left, Int16[] right, UInt16[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.AbsoluteDifference(left[i], right[i]) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.AbsoluteDifference)}<UInt16>(Vector128<Int16>, Vector128<Int16>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/libraries/System.Security.Cryptography.X509Certificates/tests/CertificateCreation/ECDsaX509SignatureGeneratorTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Linq; using Test.Cryptography; using Xunit; namespace System.Security.Cryptography.X509Certificates.Tests.CertificateCreation { public static class ECDsaX509SignatureGeneratorTests { [Fact] public static void ECDsaX509SignatureGeneratorCtor_Exceptions() { AssertExtensions.Throws<ArgumentNullException>( "key", () => X509SignatureGenerator.CreateForECDsa(null)); } [Theory] [MemberData(nameof(GetApplicableTestData))] public static void PublicKeyEncoding(EccTestData testData) { ECParameters keyParameters = testData.KeyParameters; using (ECDsa ecdsa = ECDsa.Create(keyParameters)) { X509SignatureGenerator signatureGenerator = X509SignatureGenerator.CreateForECDsa(ecdsa); PublicKey publicKey = signatureGenerator.PublicKey; Assert.Equal( testData.CurveEncodedOidHex, publicKey.EncodedParameters.RawData.ByteArrayToHex()); string expectedKeyHex = // Uncompressed Point "04" + // Qx keyParameters.Q.X.ByteArrayToHex() + // Qy keyParameters.Q.Y.ByteArrayToHex(); Assert.Equal(expectedKeyHex, publicKey.EncodedKeyValue.RawData.ByteArrayToHex()); const string ecPublicKeyOid = "1.2.840.10045.2.1"; Assert.Equal(ecPublicKeyOid, publicKey.Oid.Value); Assert.Equal(ecPublicKeyOid, publicKey.EncodedParameters.Oid.Value); Assert.Equal(ecPublicKeyOid, publicKey.EncodedKeyValue.Oid.Value); PublicKey publicKey2 = signatureGenerator.PublicKey; Assert.Same(publicKey, publicKey2); } } [Theory] [InlineData("SHA256")] [InlineData("SHA384")] [InlineData("SHA512")] public static void SignatureAlgorithm_StableNotSame(string hashAlgorithmName) { using (ECDsa ecdsa = ECDsa.Create(EccTestData.Secp256r1Data.KeyParameters)) { HashAlgorithmName hashAlgorithm = new HashAlgorithmName(hashAlgorithmName); var generator = X509SignatureGenerator.CreateForECDsa(ecdsa); byte[] sigAlg = generator.GetSignatureAlgorithmIdentifier(hashAlgorithm); byte[] sigAlg2 = generator.GetSignatureAlgorithmIdentifier(hashAlgorithm); Assert.NotSame(sigAlg, sigAlg2); Assert.Equal(sigAlg, sigAlg2); } } [Theory] [InlineData("MD5")] [InlineData("SHA1")] [InlineData("Potato")] public static void SignatureAlgorithm_NotSupported(string hashAlgorithmName) { using (ECDsa ecdsa = ECDsa.Create(EccTestData.Secp256r1Data.KeyParameters)) { HashAlgorithmName hashAlgorithm = new HashAlgorithmName(hashAlgorithmName); var generator = X509SignatureGenerator.CreateForECDsa(ecdsa); Assert.Throws<ArgumentOutOfRangeException>( "hashAlgorithm", () => generator.GetSignatureAlgorithmIdentifier(hashAlgorithm)); } } [Theory] [InlineData("SHA256")] [InlineData("SHA384")] [InlineData("SHA512")] public static void SignatureAlgorithm_Encoding(string hashAlgorithmName) { string expectedAlgOid; switch (hashAlgorithmName) { case "SHA1": expectedAlgOid = "06072A8648CE3D0401"; break; case "SHA256": expectedAlgOid = "06082A8648CE3D040302"; break; case "SHA384": expectedAlgOid = "06082A8648CE3D040303"; break; case "SHA512": expectedAlgOid = "06082A8648CE3D040304"; break; default: throw new ArgumentOutOfRangeException(nameof(hashAlgorithmName)); } EccTestData testData = EccTestData.Secp521r1Data; string expectedHex = $"30{(expectedAlgOid.Length / 2):X2}{expectedAlgOid}"; using (ECDsa ecdsa = ECDsa.Create(testData.KeyParameters)) { var generator = X509SignatureGenerator.CreateForECDsa(ecdsa); byte[] sigAlg = generator.GetSignatureAlgorithmIdentifier(new HashAlgorithmName(hashAlgorithmName)); Assert.Equal(expectedHex, sigAlg.ByteArrayToHex()); } } public static IEnumerable<object[]> GetApplicableTestData() { return EccTestData.EnumerateApplicableTests().Select(x => new object[] { x }); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Linq; using Test.Cryptography; using Xunit; namespace System.Security.Cryptography.X509Certificates.Tests.CertificateCreation { public static class ECDsaX509SignatureGeneratorTests { [Fact] public static void ECDsaX509SignatureGeneratorCtor_Exceptions() { AssertExtensions.Throws<ArgumentNullException>( "key", () => X509SignatureGenerator.CreateForECDsa(null)); } [Theory] [MemberData(nameof(GetApplicableTestData))] public static void PublicKeyEncoding(EccTestData testData) { ECParameters keyParameters = testData.KeyParameters; using (ECDsa ecdsa = ECDsa.Create(keyParameters)) { X509SignatureGenerator signatureGenerator = X509SignatureGenerator.CreateForECDsa(ecdsa); PublicKey publicKey = signatureGenerator.PublicKey; Assert.Equal( testData.CurveEncodedOidHex, publicKey.EncodedParameters.RawData.ByteArrayToHex()); string expectedKeyHex = // Uncompressed Point "04" + // Qx keyParameters.Q.X.ByteArrayToHex() + // Qy keyParameters.Q.Y.ByteArrayToHex(); Assert.Equal(expectedKeyHex, publicKey.EncodedKeyValue.RawData.ByteArrayToHex()); const string ecPublicKeyOid = "1.2.840.10045.2.1"; Assert.Equal(ecPublicKeyOid, publicKey.Oid.Value); Assert.Equal(ecPublicKeyOid, publicKey.EncodedParameters.Oid.Value); Assert.Equal(ecPublicKeyOid, publicKey.EncodedKeyValue.Oid.Value); PublicKey publicKey2 = signatureGenerator.PublicKey; Assert.Same(publicKey, publicKey2); } } [Theory] [InlineData("SHA256")] [InlineData("SHA384")] [InlineData("SHA512")] public static void SignatureAlgorithm_StableNotSame(string hashAlgorithmName) { using (ECDsa ecdsa = ECDsa.Create(EccTestData.Secp256r1Data.KeyParameters)) { HashAlgorithmName hashAlgorithm = new HashAlgorithmName(hashAlgorithmName); var generator = X509SignatureGenerator.CreateForECDsa(ecdsa); byte[] sigAlg = generator.GetSignatureAlgorithmIdentifier(hashAlgorithm); byte[] sigAlg2 = generator.GetSignatureAlgorithmIdentifier(hashAlgorithm); Assert.NotSame(sigAlg, sigAlg2); Assert.Equal(sigAlg, sigAlg2); } } [Theory] [InlineData("MD5")] [InlineData("SHA1")] [InlineData("Potato")] public static void SignatureAlgorithm_NotSupported(string hashAlgorithmName) { using (ECDsa ecdsa = ECDsa.Create(EccTestData.Secp256r1Data.KeyParameters)) { HashAlgorithmName hashAlgorithm = new HashAlgorithmName(hashAlgorithmName); var generator = X509SignatureGenerator.CreateForECDsa(ecdsa); Assert.Throws<ArgumentOutOfRangeException>( "hashAlgorithm", () => generator.GetSignatureAlgorithmIdentifier(hashAlgorithm)); } } [Theory] [InlineData("SHA256")] [InlineData("SHA384")] [InlineData("SHA512")] public static void SignatureAlgorithm_Encoding(string hashAlgorithmName) { string expectedAlgOid; switch (hashAlgorithmName) { case "SHA1": expectedAlgOid = "06072A8648CE3D0401"; break; case "SHA256": expectedAlgOid = "06082A8648CE3D040302"; break; case "SHA384": expectedAlgOid = "06082A8648CE3D040303"; break; case "SHA512": expectedAlgOid = "06082A8648CE3D040304"; break; default: throw new ArgumentOutOfRangeException(nameof(hashAlgorithmName)); } EccTestData testData = EccTestData.Secp521r1Data; string expectedHex = $"30{(expectedAlgOid.Length / 2):X2}{expectedAlgOid}"; using (ECDsa ecdsa = ECDsa.Create(testData.KeyParameters)) { var generator = X509SignatureGenerator.CreateForECDsa(ecdsa); byte[] sigAlg = generator.GetSignatureAlgorithmIdentifier(new HashAlgorithmName(hashAlgorithmName)); Assert.Equal(expectedHex, sigAlg.ByteArrayToHex()); } } public static IEnumerable<object[]> GetApplicableTestData() { return EccTestData.EnumerateApplicableTests().Select(x => new object[] { x }); } } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/libraries/System.ComponentModel.Composition/tests/System/ComponentModel/Composition/Factories/CatalogFactory.MutableComposablePartCatalog.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.ComponentModel.Composition.Hosting; using System.ComponentModel.Composition.Primitives; using System.Linq; namespace System.ComponentModel.Composition.Factories { partial class CatalogFactory { public class MutableComposablePartCatalog : ComposablePartCatalog, INotifyComposablePartCatalogChanged { private readonly HashSet<ComposablePartDefinition> _definitions; public MutableComposablePartCatalog(IEnumerable<ComposablePartDefinition> definitions) { _definitions = new HashSet<ComposablePartDefinition>(definitions); } public void AddDefinition(ComposablePartDefinition definition) { OnDefinitionsChanged(definition, true); } public void RemoveDefinition(ComposablePartDefinition definition) { OnDefinitionsChanged(definition, false); } public override IQueryable<ComposablePartDefinition> Parts { get { return _definitions.AsQueryable(); } } private void OnDefinitionsChanged(ComposablePartDefinition definition, bool added) { ComposablePartDefinition[] addedDefinitions = added ? new ComposablePartDefinition[] { definition } : new ComposablePartDefinition[0]; ComposablePartDefinition[] removeDefinitions = added ? new ComposablePartDefinition[0] : new ComposablePartDefinition[] { definition }; var e = new ComposablePartCatalogChangeEventArgs(addedDefinitions, removeDefinitions, null); Changing(this, e); if (added) { _definitions.Add(definition); } else { _definitions.Remove(definition); } if (Changed != null) { Changed(this, e); } } public event EventHandler<ComposablePartCatalogChangeEventArgs> Changed; public event EventHandler<ComposablePartCatalogChangeEventArgs> Changing; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.ComponentModel.Composition.Hosting; using System.ComponentModel.Composition.Primitives; using System.Linq; namespace System.ComponentModel.Composition.Factories { partial class CatalogFactory { public class MutableComposablePartCatalog : ComposablePartCatalog, INotifyComposablePartCatalogChanged { private readonly HashSet<ComposablePartDefinition> _definitions; public MutableComposablePartCatalog(IEnumerable<ComposablePartDefinition> definitions) { _definitions = new HashSet<ComposablePartDefinition>(definitions); } public void AddDefinition(ComposablePartDefinition definition) { OnDefinitionsChanged(definition, true); } public void RemoveDefinition(ComposablePartDefinition definition) { OnDefinitionsChanged(definition, false); } public override IQueryable<ComposablePartDefinition> Parts { get { return _definitions.AsQueryable(); } } private void OnDefinitionsChanged(ComposablePartDefinition definition, bool added) { ComposablePartDefinition[] addedDefinitions = added ? new ComposablePartDefinition[] { definition } : new ComposablePartDefinition[0]; ComposablePartDefinition[] removeDefinitions = added ? new ComposablePartDefinition[0] : new ComposablePartDefinition[] { definition }; var e = new ComposablePartCatalogChangeEventArgs(addedDefinitions, removeDefinitions, null); Changing(this, e); if (added) { _definitions.Add(definition); } else { _definitions.Remove(definition); } if (Changed != null) { Changed(this, e); } } public event EventHandler<ComposablePartCatalogChangeEventArgs> Changed; public event EventHandler<ComposablePartCatalogChangeEventArgs> Changing; } } }
-1
dotnet/runtime
65,948
Publish crossgen as AOT if supported by the target platform
If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
agocke
2022-02-28T06:12:47Z
2022-04-01T17:22:29Z
7d562f9d2a4285881ae1c412aecb164dc9370013
0d1e04ba2a9ebc9d21a7f65db00407dd0056b547
Publish crossgen as AOT if supported by the target platform. If we're on a platform that supports NativeAOT, this publishes crossgen as NativeAOT. If not, it publishes as self-contained. Trimming is not yet enabled, but will come in a separate PR.
./src/tests/Loader/classloader/TypeGeneratorTests/TypeGeneratorTest928/Generated928.il
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. .assembly extern mscorlib { .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) .ver 4:0:0:0 } .assembly extern TestFramework { .publickeytoken = ( B0 3F 5F 7F 11 D5 0A 3A ) } //TYPES IN FORWARDER ASSEMBLIES: //TEST ASSEMBLY: .assembly Generated928 { .hash algorithm 0x00008004 } .assembly extern xunit.core {} .class public BaseClass0 { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void [mscorlib]System.Object::.ctor() ret } } .class public BaseClass1 extends BaseClass0 { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void BaseClass0::.ctor() ret } } .class public G3_C1400`1<T0> extends class G2_C429`2<!T0,class BaseClass0> implements class IBase2`2<class BaseClass1,class BaseClass0> { .method public hidebysig newslot virtual instance string Method7<M0>() cil managed noinlining { ldstr "G3_C1400::Method7.15976<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string ClassMethod4192() cil managed noinlining { ldstr "G3_C1400::ClassMethod4192.15977()" ret } .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void class G2_C429`2<!T0,class BaseClass0>::.ctor() ret } } .class public G2_C429`2<T0, T1> extends class G1_C8`2<class BaseClass1,class BaseClass1> implements class IBase2`2<!T0,!T0>, class IBase1`1<class BaseClass0> { .method public hidebysig newslot virtual instance string Method7<M0>() cil managed noinlining { ldstr "G2_C429::Method7.8859<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string 'IBase2<T0,T0>.Method7'<M0>() cil managed noinlining { .override method instance string class IBase2`2<!T0,!T0>::Method7<[1]>() ldstr "G2_C429::Method7.MI.8860<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig virtual instance string Method4() cil managed noinlining { ldstr "G2_C429::Method4.8861()" ret } .method public hidebysig newslot virtual instance string Method5() cil managed noinlining { ldstr "G2_C429::Method5.8862()" ret } .method public hidebysig newslot virtual instance string Method6<M0>() cil managed noinlining { ldstr "G2_C429::Method6.8863<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string ClassMethod2218<M0>() cil managed noinlining { ldstr "G2_C429::ClassMethod2218.8864<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string 'G1_C8<class BaseClass1,class BaseClass1>.ClassMethod1334'<M0>() cil managed noinlining { .override method instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<[1]>() ldstr "G2_C429::ClassMethod1334.MI.8865<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void class G1_C8`2<class BaseClass1,class BaseClass1>::.ctor() ret } } .class interface public abstract IBase2`2<+T0, -T1> { .method public hidebysig newslot abstract virtual instance string Method7<M0>() cil managed { } } .class public G1_C8`2<T0, T1> implements class IBase2`2<!T0,!T1>, IBase0 { .method public hidebysig virtual instance string Method7<M0>() cil managed noinlining { ldstr "G1_C8::Method7.4821<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string 'IBase2<T0,T1>.Method7'<M0>() cil managed noinlining { .override method instance string class IBase2`2<!T0,!T1>::Method7<[1]>() ldstr "G1_C8::Method7.MI.4822<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string Method0() cil managed noinlining { ldstr "G1_C8::Method0.4823()" ret } .method public hidebysig newslot virtual instance string 'IBase0.Method0'() cil managed noinlining { .override method instance string IBase0::Method0() ldstr "G1_C8::Method0.MI.4824()" ret } .method public hidebysig virtual instance string Method1() cil managed noinlining { ldstr "G1_C8::Method1.4825()" ret } .method public hidebysig newslot virtual instance string Method2<M0>() cil managed noinlining { ldstr "G1_C8::Method2.4826<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string 'IBase0.Method2'<M0>() cil managed noinlining { .override method instance string IBase0::Method2<[1]>() ldstr "G1_C8::Method2.MI.4827<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string Method3<M0>() cil managed noinlining { ldstr "G1_C8::Method3.4828<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string ClassMethod1332() cil managed noinlining { ldstr "G1_C8::ClassMethod1332.4829()" ret } .method public hidebysig newslot virtual instance string ClassMethod1333() cil managed noinlining { ldstr "G1_C8::ClassMethod1333.4830()" ret } .method public hidebysig newslot virtual instance string ClassMethod1334<M0>() cil managed noinlining { ldstr "G1_C8::ClassMethod1334.4831<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string ClassMethod1335<M0>() cil managed noinlining { ldstr "G1_C8::ClassMethod1335.4832<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void [mscorlib]System.Object::.ctor() ret } } .class interface public abstract IBase1`1<+T0> { .method public hidebysig newslot abstract virtual instance string Method4() cil managed { } .method public hidebysig newslot abstract virtual instance string Method5() cil managed { } .method public hidebysig newslot abstract virtual instance string Method6<M0>() cil managed { } } .class interface public abstract IBase0 { .method public hidebysig newslot abstract virtual instance string Method0() cil managed { } .method public hidebysig newslot abstract virtual instance string Method1() cil managed { } .method public hidebysig newslot abstract virtual instance string Method2<M0>() cil managed { } .method public hidebysig newslot abstract virtual instance string Method3<M0>() cil managed { } } .class public auto ansi beforefieldinit Generated928 { .method static void M.BaseClass0<(BaseClass0)W>(!!W inst, string exp) cil managed { .maxstack 5 .locals init (string[] actualResults) ldc.i4.s 0 newarr string stloc.s actualResults ldarg.1 ldstr "M.BaseClass0<(BaseClass0)W>(!!W inst, string exp)" ldc.i4.s 0 ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.BaseClass1<(BaseClass1)W>(!!W inst, string exp) cil managed { .maxstack 5 .locals init (string[] actualResults) ldc.i4.s 0 newarr string stloc.s actualResults ldarg.1 ldstr "M.BaseClass1<(BaseClass1)W>(!!W inst, string exp)" ldc.i4.s 0 ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G3_C1400.T<T0,(class G3_C1400`1<!!T0>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G3_C1400.T<T0,(class G3_C1400`1<!!T0>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::ClassMethod2218<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::ClassMethod4192() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G3_C1400.A<(class G3_C1400`1<class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G3_C1400.A<(class G3_C1400`1<class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod2218<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod4192() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G3_C1400.B<(class G3_C1400`1<class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G3_C1400.B<(class G3_C1400`1<class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod2218<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod4192() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C429.T.T<T0,T1,(class G2_C429`2<!!T0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 18 .locals init (string[] actualResults) ldc.i4.s 13 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C429.T.T<T0,T1,(class G2_C429`2<!!T0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 13 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::ClassMethod2218<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C429.A.T<T1,(class G2_C429`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 18 .locals init (string[] actualResults) ldc.i4.s 13 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C429.A.T<T1,(class G2_C429`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 13 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::ClassMethod2218<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C429.A.A<(class G2_C429`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 18 .locals init (string[] actualResults) ldc.i4.s 13 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C429.A.A<(class G2_C429`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 13 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod2218<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C429.A.B<(class G2_C429`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 18 .locals init (string[] actualResults) ldc.i4.s 13 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C429.A.B<(class G2_C429`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 13 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod2218<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C429.B.T<T1,(class G2_C429`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 18 .locals init (string[] actualResults) ldc.i4.s 13 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C429.B.T<T1,(class G2_C429`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 13 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::ClassMethod2218<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C429.B.A<(class G2_C429`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 18 .locals init (string[] actualResults) ldc.i4.s 13 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C429.B.A<(class G2_C429`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 13 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod2218<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C429.B.B<(class G2_C429`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 18 .locals init (string[] actualResults) ldc.i4.s 13 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C429.B.B<(class G2_C429`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 13 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod2218<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.T.T<T0,T1,(class IBase2`2<!!T0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.T.T<T0,T1,(class IBase2`2<!!T0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<!!T0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.A.T<T1,(class IBase2`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.A.T<T1,(class IBase2`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.A.A<(class IBase2`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.A.A<(class IBase2`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.A.B<(class IBase2`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.A.B<(class IBase2`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.B.T<T1,(class IBase2`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.B.T<T1,(class IBase2`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass1,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.B.A<(class IBase2`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.B.A<(class IBase2`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.B.B<(class IBase2`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.B.B<(class IBase2`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C8.T.T<T0,T1,(class G1_C8`2<!!T0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 14 .locals init (string[] actualResults) ldc.i4.s 9 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C8.T.T<T0,T1,(class G1_C8`2<!!T0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 9 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<!!T0,!!T1>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<!!T0,!!T1>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<!!T0,!!T1>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<!!T0,!!T1>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<!!T0,!!T1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<!!T0,!!T1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<!!T0,!!T1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<!!T0,!!T1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<!!T0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C8.A.T<T1,(class G1_C8`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 14 .locals init (string[] actualResults) ldc.i4.s 9 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C8.A.T<T1,(class G1_C8`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 9 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,!!T1>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,!!T1>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,!!T1>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,!!T1>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,!!T1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,!!T1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,!!T1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,!!T1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C8.A.A<(class G1_C8`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 14 .locals init (string[] actualResults) ldc.i4.s 9 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C8.A.A<(class G1_C8`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 9 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C8.A.B<(class G1_C8`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 14 .locals init (string[] actualResults) ldc.i4.s 9 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C8.A.B<(class G1_C8`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 9 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C8.B.T<T1,(class G1_C8`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 14 .locals init (string[] actualResults) ldc.i4.s 9 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C8.B.T<T1,(class G1_C8`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 9 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,!!T1>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,!!T1>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,!!T1>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,!!T1>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,!!T1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,!!T1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,!!T1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,!!T1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C8.B.A<(class G1_C8`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 14 .locals init (string[] actualResults) ldc.i4.s 9 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C8.B.A<(class G1_C8`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 9 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C8.B.B<(class G1_C8`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 14 .locals init (string[] actualResults) ldc.i4.s 9 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C8.B.B<(class G1_C8`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 9 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase1.T<T0,(class IBase1`1<!!T0>)W>(!!W 'inst', string exp) cil managed { .maxstack 8 .locals init (string[] actualResults) ldc.i4.s 3 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase1.T<T0,(class IBase1`1<!!T0>)W>(!!W 'inst', string exp)" ldc.i4.s 3 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<!!T0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<!!T0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<!!T0>::Method6<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase1.A<(class IBase1`1<class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 8 .locals init (string[] actualResults) ldc.i4.s 3 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase1.A<(class IBase1`1<class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 3 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase1.B<(class IBase1`1<class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 8 .locals init (string[] actualResults) ldc.i4.s 3 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase1.B<(class IBase1`1<class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 3 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass1>::Method6<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase0<(IBase0)W>(!!W inst, string exp) cil managed { .maxstack 9 .locals init (string[] actualResults) ldc.i4.s 4 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase0<(IBase0)W>(!!W inst, string exp)" ldc.i4.s 4 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string IBase0::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string IBase0::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string IBase0::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string IBase0::Method3<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method public hidebysig static void MethodCallingTest() cil managed { .maxstack 10 .locals init (object V_0) ldstr "========================== Method Calling Test ==========================" call void [mscorlib]System.Console::WriteLine(string) newobj instance void class G3_C1400`1<class BaseClass0>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod2218<object>() ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method7<object>() ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase1`1<class BaseClass0>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod4192() ldstr "G3_C1400::ClassMethod4192.15977()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::Method7<object>() ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod2218<object>() ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>() ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop newobj instance void class G3_C1400`1<class BaseClass1>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod2218<object>() ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method7<object>() ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase1`1<class BaseClass0>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod4192() ldstr "G3_C1400::ClassMethod4192.15977()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::Method7<object>() ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod2218<object>() ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>() ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop newobj instance void class G2_C429`2<class BaseClass0,class BaseClass0>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod2218<object>() ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method7<object>() ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase1`1<class BaseClass0>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop newobj instance void class G2_C429`2<class BaseClass0,class BaseClass1>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod2218<object>() ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase1`1<class BaseClass0>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop newobj instance void class G2_C429`2<class BaseClass1,class BaseClass0>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod2218<object>() ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method7<object>() ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase1`1<class BaseClass0>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop newobj instance void class G2_C429`2<class BaseClass1,class BaseClass1>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod2218<object>() ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase1`1<class BaseClass0>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop newobj instance void class G1_C8`2<class BaseClass0,class BaseClass0>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C8`2<class BaseClass0,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1334<object>() ldstr "G1_C8::ClassMethod1334.4831<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method7<object>() ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop newobj instance void class G1_C8`2<class BaseClass0,class BaseClass1>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C8`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1334<object>() ldstr "G1_C8::ClassMethod1334.4831<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop newobj instance void class G1_C8`2<class BaseClass1,class BaseClass0>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C8`2<class BaseClass1,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1334<object>() ldstr "G1_C8::ClassMethod1334.4831<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method7<object>() ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>() ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop newobj instance void class G1_C8`2<class BaseClass1,class BaseClass1>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() ldstr "G1_C8::ClassMethod1334.4831<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldstr "========================================================================\n\n" call void [mscorlib]System.Console::WriteLine(string) ret } .method public hidebysig static void ConstrainedCallsTest() cil managed { .maxstack 10 .locals init (object V_0) ldstr "========================== Constrained Calls Test ==========================" call void [mscorlib]System.Console::WriteLine(string) newobj instance void class G3_C1400`1<class BaseClass0>::.ctor() stloc.0 ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.T.T<class BaseClass1,class BaseClass1,class G3_C1400`1<class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.T<class BaseClass1,class G3_C1400`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.B<class G3_C1400`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G3_C1400`1<class BaseClass0>>(!!2,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.B.T<class BaseClass1,class G3_C1400`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.B.B<class G3_C1400`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method0.MI.4824()#G1_C8::Method1.4825()#G1_C8::Method2.MI.4827<System.Object>()#G1_C8::Method3.4828<System.Object>()#" call void Generated928::M.IBase0<class G3_C1400`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G3_C1400`1<class BaseClass0>>(!!2,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass1,class G3_C1400`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.A.B<class G3_C1400`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.T.T<class BaseClass0,class BaseClass0,class G3_C1400`1<class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.A.T<class BaseClass0,class G3_C1400`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.A.A<class G3_C1400`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G3_C1400`1<class BaseClass0>>(!!2,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass0,class G3_C1400`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.A.A<class G3_C1400`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.T<class BaseClass0,class G3_C1400`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.A<class G3_C1400`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G3_C1400::ClassMethod4192.15977()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.G3_C1400.T<class BaseClass0,class G3_C1400`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G3_C1400::ClassMethod4192.15977()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.G3_C1400.A<class G3_C1400`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass1,class BaseClass0,class G3_C1400`1<class BaseClass0>>(!!2,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.B.T<class BaseClass0,class G3_C1400`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.B.A<class G3_C1400`1<class BaseClass0>>(!!0,string) newobj instance void class G3_C1400`1<class BaseClass1>::.ctor() stloc.0 ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.T.T<class BaseClass1,class BaseClass1,class G3_C1400`1<class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.T<class BaseClass1,class G3_C1400`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.B<class G3_C1400`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G3_C1400`1<class BaseClass1>>(!!2,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.B.T<class BaseClass1,class G3_C1400`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.B.B<class G3_C1400`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::Method0.MI.4824()#G1_C8::Method1.4825()#G1_C8::Method2.MI.4827<System.Object>()#G1_C8::Method3.4828<System.Object>()#" call void Generated928::M.IBase0<class G3_C1400`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G3_C1400`1<class BaseClass1>>(!!2,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass1,class G3_C1400`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.A.B<class G3_C1400`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.T.T<class BaseClass1,class BaseClass0,class G3_C1400`1<class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.B.T<class BaseClass0,class G3_C1400`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.B.A<class G3_C1400`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.T<class BaseClass0,class G3_C1400`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.A<class G3_C1400`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G3_C1400::ClassMethod4192.15977()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.G3_C1400.T<class BaseClass1,class G3_C1400`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G3_C1400::ClassMethod4192.15977()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.G3_C1400.B<class G3_C1400`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass1,class BaseClass0,class G3_C1400`1<class BaseClass1>>(!!2,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.B.T<class BaseClass0,class G3_C1400`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.B.A<class G3_C1400`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G3_C1400`1<class BaseClass1>>(!!2,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass0,class G3_C1400`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.A.A<class G3_C1400`1<class BaseClass1>>(!!0,string) newobj instance void class G2_C429`2<class BaseClass0,class BaseClass0>::.ctor() stloc.0 ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.T.T<class BaseClass1,class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.T<class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.B<class G2_C429`2<class BaseClass0,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.B.T<class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.B.B<class G2_C429`2<class BaseClass0,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method0.MI.4824()#G1_C8::Method1.4825()#G1_C8::Method2.MI.4827<System.Object>()#G1_C8::Method3.4828<System.Object>()#" call void Generated928::M.IBase0<class G2_C429`2<class BaseClass0,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.B<class G2_C429`2<class BaseClass0,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.T.T<class BaseClass0,class BaseClass0,class G2_C429`2<class BaseClass0,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.A.T<class BaseClass0,class G2_C429`2<class BaseClass0,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.A.A<class G2_C429`2<class BaseClass0,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G2_C429`2<class BaseClass0,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass0,class G2_C429`2<class BaseClass0,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.A<class G2_C429`2<class BaseClass0,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.T<class BaseClass0,class G2_C429`2<class BaseClass0,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.A<class G2_C429`2<class BaseClass0,class BaseClass0>>(!!0,string) newobj instance void class G2_C429`2<class BaseClass0,class BaseClass1>::.ctor() stloc.0 ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.T.T<class BaseClass1,class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.T<class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.B<class G2_C429`2<class BaseClass0,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.B.T<class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.B.B<class G2_C429`2<class BaseClass0,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::Method0.MI.4824()#G1_C8::Method1.4825()#G1_C8::Method2.MI.4827<System.Object>()#G1_C8::Method3.4828<System.Object>()#" call void Generated928::M.IBase0<class G2_C429`2<class BaseClass0,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.B<class G2_C429`2<class BaseClass0,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.T.T<class BaseClass0,class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.A.T<class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.A.B<class G2_C429`2<class BaseClass0,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G2_C429`2<class BaseClass0,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass0,class G2_C429`2<class BaseClass0,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.A<class G2_C429`2<class BaseClass0,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.T<class BaseClass0,class G2_C429`2<class BaseClass0,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.A<class G2_C429`2<class BaseClass0,class BaseClass1>>(!!0,string) newobj instance void class G2_C429`2<class BaseClass1,class BaseClass0>::.ctor() stloc.0 ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.T.T<class BaseClass1,class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.T<class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.B<class G2_C429`2<class BaseClass1,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.B.T<class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.B.B<class G2_C429`2<class BaseClass1,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method0.MI.4824()#G1_C8::Method1.4825()#G1_C8::Method2.MI.4827<System.Object>()#G1_C8::Method3.4828<System.Object>()#" call void Generated928::M.IBase0<class G2_C429`2<class BaseClass1,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.B<class G2_C429`2<class BaseClass1,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.T.T<class BaseClass1,class BaseClass0,class G2_C429`2<class BaseClass1,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.B.T<class BaseClass0,class G2_C429`2<class BaseClass1,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.B.A<class G2_C429`2<class BaseClass1,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.T<class BaseClass0,class G2_C429`2<class BaseClass1,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.A<class G2_C429`2<class BaseClass1,class BaseClass0>>(!!0,string) newobj instance void class G2_C429`2<class BaseClass1,class BaseClass1>::.ctor() stloc.0 ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.T.T<class BaseClass1,class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.T<class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.B<class G2_C429`2<class BaseClass1,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.B.T<class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.B.B<class G2_C429`2<class BaseClass1,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::Method0.MI.4824()#G1_C8::Method1.4825()#G1_C8::Method2.MI.4827<System.Object>()#G1_C8::Method3.4828<System.Object>()#" call void Generated928::M.IBase0<class G2_C429`2<class BaseClass1,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.B<class G2_C429`2<class BaseClass1,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.T.T<class BaseClass1,class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.B.T<class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.B.B<class G2_C429`2<class BaseClass1,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.T<class BaseClass0,class G2_C429`2<class BaseClass1,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.A<class G2_C429`2<class BaseClass1,class BaseClass1>>(!!0,string) newobj instance void class G1_C8`2<class BaseClass0,class BaseClass0>::.ctor() stloc.0 ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.T.T<class BaseClass0,class BaseClass0,class G1_C8`2<class BaseClass0,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.A.T<class BaseClass0,class G1_C8`2<class BaseClass0,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.A.A<class G1_C8`2<class BaseClass0,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G1_C8`2<class BaseClass0,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass0,class G1_C8`2<class BaseClass0,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.A<class G1_C8`2<class BaseClass0,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method0.MI.4824()#G1_C8::Method1.4825()#G1_C8::Method2.MI.4827<System.Object>()#G1_C8::Method3.4828<System.Object>()#" call void Generated928::M.IBase0<class G1_C8`2<class BaseClass0,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G1_C8`2<class BaseClass0,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass1,class G1_C8`2<class BaseClass0,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.B<class G1_C8`2<class BaseClass0,class BaseClass0>>(!!0,string) newobj instance void class G1_C8`2<class BaseClass0,class BaseClass1>::.ctor() stloc.0 ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.T.T<class BaseClass0,class BaseClass1,class G1_C8`2<class BaseClass0,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.A.T<class BaseClass1,class G1_C8`2<class BaseClass0,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.A.B<class G1_C8`2<class BaseClass0,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G1_C8`2<class BaseClass0,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass1,class G1_C8`2<class BaseClass0,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.B<class G1_C8`2<class BaseClass0,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::Method0.MI.4824()#G1_C8::Method1.4825()#G1_C8::Method2.MI.4827<System.Object>()#G1_C8::Method3.4828<System.Object>()#" call void Generated928::M.IBase0<class G1_C8`2<class BaseClass0,class BaseClass1>>(!!0,string) newobj instance void class G1_C8`2<class BaseClass1,class BaseClass0>::.ctor() stloc.0 ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.T.T<class BaseClass1,class BaseClass0,class G1_C8`2<class BaseClass1,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.T<class BaseClass0,class G1_C8`2<class BaseClass1,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.A<class G1_C8`2<class BaseClass1,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass1,class BaseClass0,class G1_C8`2<class BaseClass1,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.B.T<class BaseClass0,class G1_C8`2<class BaseClass1,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.B.A<class G1_C8`2<class BaseClass1,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method0.MI.4824()#G1_C8::Method1.4825()#G1_C8::Method2.MI.4827<System.Object>()#G1_C8::Method3.4828<System.Object>()#" call void Generated928::M.IBase0<class G1_C8`2<class BaseClass1,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G1_C8`2<class BaseClass1,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass0,class G1_C8`2<class BaseClass1,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.A<class G1_C8`2<class BaseClass1,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G1_C8`2<class BaseClass1,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass1,class G1_C8`2<class BaseClass1,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.B<class G1_C8`2<class BaseClass1,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G1_C8`2<class BaseClass1,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.B.T<class BaseClass1,class G1_C8`2<class BaseClass1,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.B.B<class G1_C8`2<class BaseClass1,class BaseClass0>>(!!0,string) newobj instance void class G1_C8`2<class BaseClass1,class BaseClass1>::.ctor() stloc.0 ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.T.T<class BaseClass1,class BaseClass1,class G1_C8`2<class BaseClass1,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.T<class BaseClass1,class G1_C8`2<class BaseClass1,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.B<class G1_C8`2<class BaseClass1,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G1_C8`2<class BaseClass1,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.B.T<class BaseClass1,class G1_C8`2<class BaseClass1,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.B.B<class G1_C8`2<class BaseClass1,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::Method0.MI.4824()#G1_C8::Method1.4825()#G1_C8::Method2.MI.4827<System.Object>()#G1_C8::Method3.4828<System.Object>()#" call void Generated928::M.IBase0<class G1_C8`2<class BaseClass1,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G1_C8`2<class BaseClass1,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass1,class G1_C8`2<class BaseClass1,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.B<class G1_C8`2<class BaseClass1,class BaseClass1>>(!!0,string) ldstr "========================================================================\n\n" call void [mscorlib]System.Console::WriteLine(string) ret } .method public hidebysig static void StructConstrainedInterfaceCallsTest() cil managed { .maxstack 10 ldstr "===================== Struct Constrained Interface Calls Test =====================" call void [mscorlib]System.Console::WriteLine(string) ldstr "========================================================================\n\n" call void [mscorlib]System.Console::WriteLine(string) ret } .method public hidebysig static void CalliTest() cil managed { .maxstack 10 .locals init (object V_0) ldstr "========================== Method Calli Test ==========================" call void [mscorlib]System.Console::WriteLine(string) newobj instance void class G3_C1400`1<class BaseClass0>::.ctor() stloc.0 ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod2218<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method6<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method5() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method4() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1335<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1334<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1333() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1332() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method3<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method2<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method1() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method0() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::ClassMethod4192() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G3_C1400::ClassMethod4192.15977()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::ClassMethod2218<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::Method6<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::Method5() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::Method5.8862()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::Method4() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::Method4.8861()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::ClassMethod1335<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::ClassMethod1334<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::ClassMethod1333() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::ClassMethod1332() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::Method3<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::Method2<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::Method1() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::Method0() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method0.4823()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) newobj instance void class G3_C1400`1<class BaseClass1>::.ctor() stloc.0 ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod2218<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method6<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method5() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method4() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1335<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1334<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1333() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1332() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method3<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method2<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method1() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method0() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::ClassMethod4192() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G3_C1400::ClassMethod4192.15977()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::ClassMethod2218<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::Method6<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::Method5() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::Method5.8862()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::Method4() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::Method4.8861()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::ClassMethod1335<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::ClassMethod1334<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::ClassMethod1333() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::ClassMethod1332() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::Method3<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::Method2<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::Method1() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::Method0() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method0.4823()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) newobj instance void class G2_C429`2<class BaseClass0,class BaseClass0>::.ctor() stloc.0 ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod2218<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method6<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method5() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method4() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method7<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1335<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1334<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1333() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1332() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method3<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method2<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method1() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method0() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) newobj instance void class G2_C429`2<class BaseClass0,class BaseClass1>::.ctor() stloc.0 ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod2218<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method6<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method5() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method4() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1335<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1334<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1333() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1332() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method3<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method2<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method1() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method0() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) newobj instance void class G2_C429`2<class BaseClass1,class BaseClass0>::.ctor() stloc.0 ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod2218<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method6<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method5() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method4() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method7<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1335<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1334<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1333() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1332() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method3<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method2<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method1() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method0() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) newobj instance void class G2_C429`2<class BaseClass1,class BaseClass1>::.ctor() stloc.0 ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod2218<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method6<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method5() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method4() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1333() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1332() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method3<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method2<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method1() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method0() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) newobj instance void class G1_C8`2<class BaseClass0,class BaseClass0>::.ctor() stloc.0 ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1335<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1334<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::ClassMethod1334.4831<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1333() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1332() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method3<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method2<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method1() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method0() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method7<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) newobj instance void class G1_C8`2<class BaseClass0,class BaseClass1>::.ctor() stloc.0 ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1335<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1334<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::ClassMethod1334.4831<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1333() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1332() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method3<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method2<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method1() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method0() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) newobj instance void class G1_C8`2<class BaseClass1,class BaseClass0>::.ctor() stloc.0 ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1335<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1334<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::ClassMethod1334.4831<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1333() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1332() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method3<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method2<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method1() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method0() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method7<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) newobj instance void class G1_C8`2<class BaseClass1,class BaseClass1>::.ctor() stloc.0 ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::ClassMethod1334.4831<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldstr "========================================================================\n\n" call void [mscorlib]System.Console::WriteLine(string) ret } .method public hidebysig static int32 Main() cil managed { .custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = ( 01 00 00 00 ) .entrypoint .maxstack 10 call void Generated928::MethodCallingTest() call void Generated928::ConstrainedCallsTest() call void Generated928::StructConstrainedInterfaceCallsTest() call void Generated928::CalliTest() ldc.i4 100 ret } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. .assembly extern mscorlib { .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) .ver 4:0:0:0 } .assembly extern TestFramework { .publickeytoken = ( B0 3F 5F 7F 11 D5 0A 3A ) } //TYPES IN FORWARDER ASSEMBLIES: //TEST ASSEMBLY: .assembly Generated928 { .hash algorithm 0x00008004 } .assembly extern xunit.core {} .class public BaseClass0 { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void [mscorlib]System.Object::.ctor() ret } } .class public BaseClass1 extends BaseClass0 { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void BaseClass0::.ctor() ret } } .class public G3_C1400`1<T0> extends class G2_C429`2<!T0,class BaseClass0> implements class IBase2`2<class BaseClass1,class BaseClass0> { .method public hidebysig newslot virtual instance string Method7<M0>() cil managed noinlining { ldstr "G3_C1400::Method7.15976<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string ClassMethod4192() cil managed noinlining { ldstr "G3_C1400::ClassMethod4192.15977()" ret } .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void class G2_C429`2<!T0,class BaseClass0>::.ctor() ret } } .class public G2_C429`2<T0, T1> extends class G1_C8`2<class BaseClass1,class BaseClass1> implements class IBase2`2<!T0,!T0>, class IBase1`1<class BaseClass0> { .method public hidebysig newslot virtual instance string Method7<M0>() cil managed noinlining { ldstr "G2_C429::Method7.8859<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string 'IBase2<T0,T0>.Method7'<M0>() cil managed noinlining { .override method instance string class IBase2`2<!T0,!T0>::Method7<[1]>() ldstr "G2_C429::Method7.MI.8860<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig virtual instance string Method4() cil managed noinlining { ldstr "G2_C429::Method4.8861()" ret } .method public hidebysig newslot virtual instance string Method5() cil managed noinlining { ldstr "G2_C429::Method5.8862()" ret } .method public hidebysig newslot virtual instance string Method6<M0>() cil managed noinlining { ldstr "G2_C429::Method6.8863<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string ClassMethod2218<M0>() cil managed noinlining { ldstr "G2_C429::ClassMethod2218.8864<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string 'G1_C8<class BaseClass1,class BaseClass1>.ClassMethod1334'<M0>() cil managed noinlining { .override method instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<[1]>() ldstr "G2_C429::ClassMethod1334.MI.8865<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void class G1_C8`2<class BaseClass1,class BaseClass1>::.ctor() ret } } .class interface public abstract IBase2`2<+T0, -T1> { .method public hidebysig newslot abstract virtual instance string Method7<M0>() cil managed { } } .class public G1_C8`2<T0, T1> implements class IBase2`2<!T0,!T1>, IBase0 { .method public hidebysig virtual instance string Method7<M0>() cil managed noinlining { ldstr "G1_C8::Method7.4821<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string 'IBase2<T0,T1>.Method7'<M0>() cil managed noinlining { .override method instance string class IBase2`2<!T0,!T1>::Method7<[1]>() ldstr "G1_C8::Method7.MI.4822<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string Method0() cil managed noinlining { ldstr "G1_C8::Method0.4823()" ret } .method public hidebysig newslot virtual instance string 'IBase0.Method0'() cil managed noinlining { .override method instance string IBase0::Method0() ldstr "G1_C8::Method0.MI.4824()" ret } .method public hidebysig virtual instance string Method1() cil managed noinlining { ldstr "G1_C8::Method1.4825()" ret } .method public hidebysig newslot virtual instance string Method2<M0>() cil managed noinlining { ldstr "G1_C8::Method2.4826<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string 'IBase0.Method2'<M0>() cil managed noinlining { .override method instance string IBase0::Method2<[1]>() ldstr "G1_C8::Method2.MI.4827<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string Method3<M0>() cil managed noinlining { ldstr "G1_C8::Method3.4828<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string ClassMethod1332() cil managed noinlining { ldstr "G1_C8::ClassMethod1332.4829()" ret } .method public hidebysig newslot virtual instance string ClassMethod1333() cil managed noinlining { ldstr "G1_C8::ClassMethod1333.4830()" ret } .method public hidebysig newslot virtual instance string ClassMethod1334<M0>() cil managed noinlining { ldstr "G1_C8::ClassMethod1334.4831<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string ClassMethod1335<M0>() cil managed noinlining { ldstr "G1_C8::ClassMethod1335.4832<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void [mscorlib]System.Object::.ctor() ret } } .class interface public abstract IBase1`1<+T0> { .method public hidebysig newslot abstract virtual instance string Method4() cil managed { } .method public hidebysig newslot abstract virtual instance string Method5() cil managed { } .method public hidebysig newslot abstract virtual instance string Method6<M0>() cil managed { } } .class interface public abstract IBase0 { .method public hidebysig newslot abstract virtual instance string Method0() cil managed { } .method public hidebysig newslot abstract virtual instance string Method1() cil managed { } .method public hidebysig newslot abstract virtual instance string Method2<M0>() cil managed { } .method public hidebysig newslot abstract virtual instance string Method3<M0>() cil managed { } } .class public auto ansi beforefieldinit Generated928 { .method static void M.BaseClass0<(BaseClass0)W>(!!W inst, string exp) cil managed { .maxstack 5 .locals init (string[] actualResults) ldc.i4.s 0 newarr string stloc.s actualResults ldarg.1 ldstr "M.BaseClass0<(BaseClass0)W>(!!W inst, string exp)" ldc.i4.s 0 ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.BaseClass1<(BaseClass1)W>(!!W inst, string exp) cil managed { .maxstack 5 .locals init (string[] actualResults) ldc.i4.s 0 newarr string stloc.s actualResults ldarg.1 ldstr "M.BaseClass1<(BaseClass1)W>(!!W inst, string exp)" ldc.i4.s 0 ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G3_C1400.T<T0,(class G3_C1400`1<!!T0>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G3_C1400.T<T0,(class G3_C1400`1<!!T0>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::ClassMethod2218<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::ClassMethod4192() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<!!T0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G3_C1400.A<(class G3_C1400`1<class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G3_C1400.A<(class G3_C1400`1<class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod2218<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod4192() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G3_C1400.B<(class G3_C1400`1<class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G3_C1400.B<(class G3_C1400`1<class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod2218<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod4192() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1400`1<class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C429.T.T<T0,T1,(class G2_C429`2<!!T0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 18 .locals init (string[] actualResults) ldc.i4.s 13 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C429.T.T<T0,T1,(class G2_C429`2<!!T0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 13 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::ClassMethod2218<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<!!T0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C429.A.T<T1,(class G2_C429`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 18 .locals init (string[] actualResults) ldc.i4.s 13 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C429.A.T<T1,(class G2_C429`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 13 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::ClassMethod2218<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C429.A.A<(class G2_C429`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 18 .locals init (string[] actualResults) ldc.i4.s 13 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C429.A.A<(class G2_C429`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 13 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod2218<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C429.A.B<(class G2_C429`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 18 .locals init (string[] actualResults) ldc.i4.s 13 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C429.A.B<(class G2_C429`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 13 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod2218<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C429.B.T<T1,(class G2_C429`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 18 .locals init (string[] actualResults) ldc.i4.s 13 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C429.B.T<T1,(class G2_C429`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 13 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::ClassMethod2218<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C429.B.A<(class G2_C429`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 18 .locals init (string[] actualResults) ldc.i4.s 13 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C429.B.A<(class G2_C429`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 13 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod2218<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C429.B.B<(class G2_C429`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 18 .locals init (string[] actualResults) ldc.i4.s 13 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C429.B.B<(class G2_C429`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 13 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod2218<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.T.T<T0,T1,(class IBase2`2<!!T0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.T.T<T0,T1,(class IBase2`2<!!T0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<!!T0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.A.T<T1,(class IBase2`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.A.T<T1,(class IBase2`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.A.A<(class IBase2`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.A.A<(class IBase2`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.A.B<(class IBase2`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.A.B<(class IBase2`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.B.T<T1,(class IBase2`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.B.T<T1,(class IBase2`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass1,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.B.A<(class IBase2`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.B.A<(class IBase2`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.B.B<(class IBase2`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.B.B<(class IBase2`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C8.T.T<T0,T1,(class G1_C8`2<!!T0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 14 .locals init (string[] actualResults) ldc.i4.s 9 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C8.T.T<T0,T1,(class G1_C8`2<!!T0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 9 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<!!T0,!!T1>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<!!T0,!!T1>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<!!T0,!!T1>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<!!T0,!!T1>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<!!T0,!!T1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<!!T0,!!T1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<!!T0,!!T1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<!!T0,!!T1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<!!T0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C8.A.T<T1,(class G1_C8`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 14 .locals init (string[] actualResults) ldc.i4.s 9 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C8.A.T<T1,(class G1_C8`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 9 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,!!T1>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,!!T1>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,!!T1>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,!!T1>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,!!T1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,!!T1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,!!T1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,!!T1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C8.A.A<(class G1_C8`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 14 .locals init (string[] actualResults) ldc.i4.s 9 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C8.A.A<(class G1_C8`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 9 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C8.A.B<(class G1_C8`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 14 .locals init (string[] actualResults) ldc.i4.s 9 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C8.A.B<(class G1_C8`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 9 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C8.B.T<T1,(class G1_C8`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 14 .locals init (string[] actualResults) ldc.i4.s 9 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C8.B.T<T1,(class G1_C8`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 9 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,!!T1>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,!!T1>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,!!T1>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,!!T1>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,!!T1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,!!T1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,!!T1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,!!T1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C8.B.A<(class G1_C8`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 14 .locals init (string[] actualResults) ldc.i4.s 9 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C8.B.A<(class G1_C8`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 9 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C8.B.B<(class G1_C8`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 14 .locals init (string[] actualResults) ldc.i4.s 9 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C8.B.B<(class G1_C8`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 9 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase1.T<T0,(class IBase1`1<!!T0>)W>(!!W 'inst', string exp) cil managed { .maxstack 8 .locals init (string[] actualResults) ldc.i4.s 3 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase1.T<T0,(class IBase1`1<!!T0>)W>(!!W 'inst', string exp)" ldc.i4.s 3 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<!!T0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<!!T0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<!!T0>::Method6<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase1.A<(class IBase1`1<class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 8 .locals init (string[] actualResults) ldc.i4.s 3 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase1.A<(class IBase1`1<class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 3 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase1.B<(class IBase1`1<class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 8 .locals init (string[] actualResults) ldc.i4.s 3 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase1.B<(class IBase1`1<class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 3 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass1>::Method6<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase0<(IBase0)W>(!!W inst, string exp) cil managed { .maxstack 9 .locals init (string[] actualResults) ldc.i4.s 4 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase0<(IBase0)W>(!!W inst, string exp)" ldc.i4.s 4 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string IBase0::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string IBase0::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string IBase0::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string IBase0::Method3<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method public hidebysig static void MethodCallingTest() cil managed { .maxstack 10 .locals init (object V_0) ldstr "========================== Method Calling Test ==========================" call void [mscorlib]System.Console::WriteLine(string) newobj instance void class G3_C1400`1<class BaseClass0>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod2218<object>() ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method7<object>() ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase1`1<class BaseClass0>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod4192() ldstr "G3_C1400::ClassMethod4192.15977()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::Method7<object>() ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod2218<object>() ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass0> callvirt instance string class G3_C1400`1<class BaseClass0>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>() ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop newobj instance void class G3_C1400`1<class BaseClass1>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod2218<object>() ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method7<object>() ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase1`1<class BaseClass0>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod4192() ldstr "G3_C1400::ClassMethod4192.15977()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::Method7<object>() ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod2218<object>() ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1400`1<class BaseClass1> callvirt instance string class G3_C1400`1<class BaseClass1>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>() ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop newobj instance void class G2_C429`2<class BaseClass0,class BaseClass0>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod2218<object>() ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method7<object>() ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase1`1<class BaseClass0>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop newobj instance void class G2_C429`2<class BaseClass0,class BaseClass1>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod2218<object>() ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase1`1<class BaseClass0>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop newobj instance void class G2_C429`2<class BaseClass1,class BaseClass0>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod2218<object>() ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method7<object>() ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass0> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase1`1<class BaseClass0>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop newobj instance void class G2_C429`2<class BaseClass1,class BaseClass1>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod2218<object>() ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C429`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase1`1<class BaseClass0>::Method4() ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method5() ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>() ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop newobj instance void class G1_C8`2<class BaseClass0,class BaseClass0>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C8`2<class BaseClass0,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1334<object>() ldstr "G1_C8::ClassMethod1334.4831<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method7<object>() ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop newobj instance void class G1_C8`2<class BaseClass0,class BaseClass1>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C8`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1334<object>() ldstr "G1_C8::ClassMethod1334.4831<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop newobj instance void class G1_C8`2<class BaseClass1,class BaseClass0>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C8`2<class BaseClass1,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1334<object>() ldstr "G1_C8::ClassMethod1334.4831<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass0> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method7<object>() ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>() ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop newobj instance void class G1_C8`2<class BaseClass1,class BaseClass1>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() ldstr "G1_C8::ClassMethod1334.4831<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C8`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldstr "========================================================================\n\n" call void [mscorlib]System.Console::WriteLine(string) ret } .method public hidebysig static void ConstrainedCallsTest() cil managed { .maxstack 10 .locals init (object V_0) ldstr "========================== Constrained Calls Test ==========================" call void [mscorlib]System.Console::WriteLine(string) newobj instance void class G3_C1400`1<class BaseClass0>::.ctor() stloc.0 ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.T.T<class BaseClass1,class BaseClass1,class G3_C1400`1<class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.T<class BaseClass1,class G3_C1400`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.B<class G3_C1400`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G3_C1400`1<class BaseClass0>>(!!2,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.B.T<class BaseClass1,class G3_C1400`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.B.B<class G3_C1400`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method0.MI.4824()#G1_C8::Method1.4825()#G1_C8::Method2.MI.4827<System.Object>()#G1_C8::Method3.4828<System.Object>()#" call void Generated928::M.IBase0<class G3_C1400`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G3_C1400`1<class BaseClass0>>(!!2,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass1,class G3_C1400`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.A.B<class G3_C1400`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.T.T<class BaseClass0,class BaseClass0,class G3_C1400`1<class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.A.T<class BaseClass0,class G3_C1400`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.A.A<class G3_C1400`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G3_C1400`1<class BaseClass0>>(!!2,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass0,class G3_C1400`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.A.A<class G3_C1400`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.T<class BaseClass0,class G3_C1400`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.A<class G3_C1400`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G3_C1400::ClassMethod4192.15977()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.G3_C1400.T<class BaseClass0,class G3_C1400`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G3_C1400::ClassMethod4192.15977()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.G3_C1400.A<class G3_C1400`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass1,class BaseClass0,class G3_C1400`1<class BaseClass0>>(!!2,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.B.T<class BaseClass0,class G3_C1400`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.B.A<class G3_C1400`1<class BaseClass0>>(!!0,string) newobj instance void class G3_C1400`1<class BaseClass1>::.ctor() stloc.0 ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.T.T<class BaseClass1,class BaseClass1,class G3_C1400`1<class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.T<class BaseClass1,class G3_C1400`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.B<class G3_C1400`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G3_C1400`1<class BaseClass1>>(!!2,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.B.T<class BaseClass1,class G3_C1400`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.B.B<class G3_C1400`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::Method0.MI.4824()#G1_C8::Method1.4825()#G1_C8::Method2.MI.4827<System.Object>()#G1_C8::Method3.4828<System.Object>()#" call void Generated928::M.IBase0<class G3_C1400`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G3_C1400`1<class BaseClass1>>(!!2,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass1,class G3_C1400`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.A.B<class G3_C1400`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.T.T<class BaseClass1,class BaseClass0,class G3_C1400`1<class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.B.T<class BaseClass0,class G3_C1400`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.B.A<class G3_C1400`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.T<class BaseClass0,class G3_C1400`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.A<class G3_C1400`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G3_C1400::ClassMethod4192.15977()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.G3_C1400.T<class BaseClass1,class G3_C1400`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G3_C1400::ClassMethod4192.15977()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.G3_C1400.B<class G3_C1400`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass1,class BaseClass0,class G3_C1400`1<class BaseClass1>>(!!2,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.B.T<class BaseClass0,class G3_C1400`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.B.A<class G3_C1400`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G3_C1400`1<class BaseClass1>>(!!2,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass0,class G3_C1400`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G3_C1400::Method7.15976<System.Object>()#" call void Generated928::M.IBase2.A.A<class G3_C1400`1<class BaseClass1>>(!!0,string) newobj instance void class G2_C429`2<class BaseClass0,class BaseClass0>::.ctor() stloc.0 ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.T.T<class BaseClass1,class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.T<class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.B<class G2_C429`2<class BaseClass0,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.B.T<class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.B.B<class G2_C429`2<class BaseClass0,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method0.MI.4824()#G1_C8::Method1.4825()#G1_C8::Method2.MI.4827<System.Object>()#G1_C8::Method3.4828<System.Object>()#" call void Generated928::M.IBase0<class G2_C429`2<class BaseClass0,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.B<class G2_C429`2<class BaseClass0,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.T.T<class BaseClass0,class BaseClass0,class G2_C429`2<class BaseClass0,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.A.T<class BaseClass0,class G2_C429`2<class BaseClass0,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.A.A<class G2_C429`2<class BaseClass0,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G2_C429`2<class BaseClass0,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass0,class G2_C429`2<class BaseClass0,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.A<class G2_C429`2<class BaseClass0,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.T<class BaseClass0,class G2_C429`2<class BaseClass0,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.A<class G2_C429`2<class BaseClass0,class BaseClass0>>(!!0,string) newobj instance void class G2_C429`2<class BaseClass0,class BaseClass1>::.ctor() stloc.0 ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.T.T<class BaseClass1,class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.T<class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.B<class G2_C429`2<class BaseClass0,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.B.T<class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.B.B<class G2_C429`2<class BaseClass0,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::Method0.MI.4824()#G1_C8::Method1.4825()#G1_C8::Method2.MI.4827<System.Object>()#G1_C8::Method3.4828<System.Object>()#" call void Generated928::M.IBase0<class G2_C429`2<class BaseClass0,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.B<class G2_C429`2<class BaseClass0,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.T.T<class BaseClass0,class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.A.T<class BaseClass1,class G2_C429`2<class BaseClass0,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.A.B<class G2_C429`2<class BaseClass0,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G2_C429`2<class BaseClass0,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass0,class G2_C429`2<class BaseClass0,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.A<class G2_C429`2<class BaseClass0,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.T<class BaseClass0,class G2_C429`2<class BaseClass0,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.A<class G2_C429`2<class BaseClass0,class BaseClass1>>(!!0,string) newobj instance void class G2_C429`2<class BaseClass1,class BaseClass0>::.ctor() stloc.0 ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.T.T<class BaseClass1,class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.T<class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.B<class G2_C429`2<class BaseClass1,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.B.T<class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.B.B<class G2_C429`2<class BaseClass1,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method0.MI.4824()#G1_C8::Method1.4825()#G1_C8::Method2.MI.4827<System.Object>()#G1_C8::Method3.4828<System.Object>()#" call void Generated928::M.IBase0<class G2_C429`2<class BaseClass1,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.B<class G2_C429`2<class BaseClass1,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.T.T<class BaseClass1,class BaseClass0,class G2_C429`2<class BaseClass1,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.B.T<class BaseClass0,class G2_C429`2<class BaseClass1,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.B.A<class G2_C429`2<class BaseClass1,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.T<class BaseClass0,class G2_C429`2<class BaseClass1,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.A<class G2_C429`2<class BaseClass1,class BaseClass0>>(!!0,string) newobj instance void class G2_C429`2<class BaseClass1,class BaseClass1>::.ctor() stloc.0 ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.T.T<class BaseClass1,class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.T<class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.B<class G2_C429`2<class BaseClass1,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.B.T<class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.B.B<class G2_C429`2<class BaseClass1,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::Method0.MI.4824()#G1_C8::Method1.4825()#G1_C8::Method2.MI.4827<System.Object>()#G1_C8::Method3.4828<System.Object>()#" call void Generated928::M.IBase0<class G2_C429`2<class BaseClass1,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G2_C429::Method7.MI.8860<System.Object>()#" call void Generated928::M.IBase2.A.B<class G2_C429`2<class BaseClass1,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.T.T<class BaseClass1,class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.B.T<class BaseClass1,class G2_C429`2<class BaseClass1,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G2_C429::ClassMethod1334.MI.8865<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G2_C429::ClassMethod2218.8864<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#G2_C429::Method7.8859<System.Object>()#" call void Generated928::M.G2_C429.B.B<class G2_C429`2<class BaseClass1,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.T<class BaseClass0,class G2_C429`2<class BaseClass1,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G2_C429::Method4.8861()#G2_C429::Method5.8862()#G2_C429::Method6.8863<System.Object>()#" call void Generated928::M.IBase1.A<class G2_C429`2<class BaseClass1,class BaseClass1>>(!!0,string) newobj instance void class G1_C8`2<class BaseClass0,class BaseClass0>::.ctor() stloc.0 ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.T.T<class BaseClass0,class BaseClass0,class G1_C8`2<class BaseClass0,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.A.T<class BaseClass0,class G1_C8`2<class BaseClass0,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.A.A<class G1_C8`2<class BaseClass0,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G1_C8`2<class BaseClass0,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass0,class G1_C8`2<class BaseClass0,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.A<class G1_C8`2<class BaseClass0,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method0.MI.4824()#G1_C8::Method1.4825()#G1_C8::Method2.MI.4827<System.Object>()#G1_C8::Method3.4828<System.Object>()#" call void Generated928::M.IBase0<class G1_C8`2<class BaseClass0,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G1_C8`2<class BaseClass0,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass1,class G1_C8`2<class BaseClass0,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.B<class G1_C8`2<class BaseClass0,class BaseClass0>>(!!0,string) newobj instance void class G1_C8`2<class BaseClass0,class BaseClass1>::.ctor() stloc.0 ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.T.T<class BaseClass0,class BaseClass1,class G1_C8`2<class BaseClass0,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.A.T<class BaseClass1,class G1_C8`2<class BaseClass0,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.A.B<class G1_C8`2<class BaseClass0,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G1_C8`2<class BaseClass0,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass1,class G1_C8`2<class BaseClass0,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.B<class G1_C8`2<class BaseClass0,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::Method0.MI.4824()#G1_C8::Method1.4825()#G1_C8::Method2.MI.4827<System.Object>()#G1_C8::Method3.4828<System.Object>()#" call void Generated928::M.IBase0<class G1_C8`2<class BaseClass0,class BaseClass1>>(!!0,string) newobj instance void class G1_C8`2<class BaseClass1,class BaseClass0>::.ctor() stloc.0 ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.T.T<class BaseClass1,class BaseClass0,class G1_C8`2<class BaseClass1,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.T<class BaseClass0,class G1_C8`2<class BaseClass1,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.A<class G1_C8`2<class BaseClass1,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass1,class BaseClass0,class G1_C8`2<class BaseClass1,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.B.T<class BaseClass0,class G1_C8`2<class BaseClass1,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.B.A<class G1_C8`2<class BaseClass1,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method0.MI.4824()#G1_C8::Method1.4825()#G1_C8::Method2.MI.4827<System.Object>()#G1_C8::Method3.4828<System.Object>()#" call void Generated928::M.IBase0<class G1_C8`2<class BaseClass1,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G1_C8`2<class BaseClass1,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass0,class G1_C8`2<class BaseClass1,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.A<class G1_C8`2<class BaseClass1,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G1_C8`2<class BaseClass1,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass1,class G1_C8`2<class BaseClass1,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.B<class G1_C8`2<class BaseClass1,class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G1_C8`2<class BaseClass1,class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.B.T<class BaseClass1,class G1_C8`2<class BaseClass1,class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.B.B<class G1_C8`2<class BaseClass1,class BaseClass0>>(!!0,string) newobj instance void class G1_C8`2<class BaseClass1,class BaseClass1>::.ctor() stloc.0 ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.T.T<class BaseClass1,class BaseClass1,class G1_C8`2<class BaseClass1,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.T<class BaseClass1,class G1_C8`2<class BaseClass1,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::ClassMethod1332.4829()#G1_C8::ClassMethod1333.4830()#G1_C8::ClassMethod1334.4831<System.Object>()#G1_C8::ClassMethod1335.4832<System.Object>()#G1_C8::Method0.4823()#G1_C8::Method1.4825()#G1_C8::Method2.4826<System.Object>()#G1_C8::Method3.4828<System.Object>()#G1_C8::Method7.4821<System.Object>()#" call void Generated928::M.G1_C8.B.B<class G1_C8`2<class BaseClass1,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G1_C8`2<class BaseClass1,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.B.T<class BaseClass1,class G1_C8`2<class BaseClass1,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.B.B<class G1_C8`2<class BaseClass1,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::Method0.MI.4824()#G1_C8::Method1.4825()#G1_C8::Method2.MI.4827<System.Object>()#G1_C8::Method3.4828<System.Object>()#" call void Generated928::M.IBase0<class G1_C8`2<class BaseClass1,class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G1_C8`2<class BaseClass1,class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.T<class BaseClass1,class G1_C8`2<class BaseClass1,class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C8::Method7.MI.4822<System.Object>()#" call void Generated928::M.IBase2.A.B<class G1_C8`2<class BaseClass1,class BaseClass1>>(!!0,string) ldstr "========================================================================\n\n" call void [mscorlib]System.Console::WriteLine(string) ret } .method public hidebysig static void StructConstrainedInterfaceCallsTest() cil managed { .maxstack 10 ldstr "===================== Struct Constrained Interface Calls Test =====================" call void [mscorlib]System.Console::WriteLine(string) ldstr "========================================================================\n\n" call void [mscorlib]System.Console::WriteLine(string) ret } .method public hidebysig static void CalliTest() cil managed { .maxstack 10 .locals init (object V_0) ldstr "========================== Method Calli Test ==========================" call void [mscorlib]System.Console::WriteLine(string) newobj instance void class G3_C1400`1<class BaseClass0>::.ctor() stloc.0 ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod2218<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method6<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method5() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method4() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1335<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1334<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1333() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1332() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method3<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method2<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method1() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method0() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::ClassMethod4192() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G3_C1400::ClassMethod4192.15977()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::ClassMethod2218<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::Method6<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::Method5() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::Method5.8862()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::Method4() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::Method4.8861()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::ClassMethod1335<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::ClassMethod1334<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::ClassMethod1333() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::ClassMethod1332() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::Method3<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::Method2<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::Method1() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass0>::Method0() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G1_C8::Method0.4823()" ldstr "class G3_C1400`1<class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass0>) ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) newobj instance void class G3_C1400`1<class BaseClass1>::.ctor() stloc.0 ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod2218<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method6<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method5() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method4() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1335<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1334<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1333() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1332() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method3<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method2<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method1() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method0() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::ClassMethod4192() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G3_C1400::ClassMethod4192.15977()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::ClassMethod2218<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::Method6<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::Method5() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::Method5.8862()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::Method4() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::Method4.8861()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::ClassMethod1335<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::ClassMethod1334<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::ClassMethod1333() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::ClassMethod1332() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::Method3<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::Method2<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::Method1() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1400`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1400`1<class BaseClass1>::Method0() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G1_C8::Method0.4823()" ldstr "class G3_C1400`1<class BaseClass1> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() calli default string(class G3_C1400`1<class BaseClass1>) ldstr "G3_C1400::Method7.15976<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G3_C1400`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) newobj instance void class G2_C429`2<class BaseClass0,class BaseClass0>::.ctor() stloc.0 ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod2218<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method6<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method5() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method4() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method7<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1335<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1334<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1333() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::ClassMethod1332() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method3<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method2<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method1() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass0>::Method0() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass0>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) newobj instance void class G2_C429`2<class BaseClass0,class BaseClass1>::.ctor() stloc.0 ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod2218<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method6<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method5() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method4() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1335<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1334<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1333() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::ClassMethod1332() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method3<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method2<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method1() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass0,class BaseClass1>::Method0() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>() calli default string(class G2_C429`2<class BaseClass0,class BaseClass1>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) newobj instance void class G2_C429`2<class BaseClass1,class BaseClass0>::.ctor() stloc.0 ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod2218<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method6<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method5() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method4() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method7<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1335<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1334<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1333() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::ClassMethod1332() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method3<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method2<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method1() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass0>::Method0() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass0>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) newobj instance void class G2_C429`2<class BaseClass1,class BaseClass1>::.ctor() stloc.0 ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::Method7.MI.8860<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod2218<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::ClassMethod2218.8864<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method6<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method5() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::Method5.8862()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method4() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::Method4.8861()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::Method7.8859<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::ClassMethod1334.MI.8865<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1333() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::ClassMethod1332() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method3<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method2<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method1() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C429`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C429`2<class BaseClass1,class BaseClass1>::Method0() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method0.4823()" ldstr "class G2_C429`2<class BaseClass1,class BaseClass1> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::Method4.8861()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::Method5.8862()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>() calli default string(class G2_C429`2<class BaseClass1,class BaseClass1>) ldstr "G2_C429::Method6.8863<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G2_C429`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) newobj instance void class G1_C8`2<class BaseClass0,class BaseClass0>::.ctor() stloc.0 ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1335<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1334<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::ClassMethod1334.4831<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1333() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass0>::ClassMethod1332() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method3<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method2<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method1() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method0() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass0>::Method7<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass0>) ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) newobj instance void class G1_C8`2<class BaseClass0,class BaseClass1>::.ctor() stloc.0 ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1335<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1334<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::ClassMethod1334.4831<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1333() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass1>::ClassMethod1332() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method3<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method2<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method1() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method0() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G1_C8`2<class BaseClass0,class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass0,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) newobj instance void class G1_C8`2<class BaseClass1,class BaseClass0>::.ctor() stloc.0 ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1335<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1334<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::ClassMethod1334.4831<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1333() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass0>::ClassMethod1332() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method3<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method2<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method1() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method0() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass0> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass0>::Method7<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass0>) ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) newobj instance void class G1_C8`2<class BaseClass1,class BaseClass1>::.ctor() stloc.0 ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1335<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::ClassMethod1335.4832<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1334<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::ClassMethod1334.4831<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1333() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::ClassMethod1333.4830()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::ClassMethod1332() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::ClassMethod1332.4829()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method3<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method2<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method2.4826<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method1() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method0() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method0.4823()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C8`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C8`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method7.4821<System.Object>()" ldstr "class G1_C8`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method0.MI.4824()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method1.4825()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method2.MI.4827<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method3.4828<System.Object>()" ldstr "IBase0 on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G1_C8`2<class BaseClass1,class BaseClass1>) ldstr "G1_C8::Method7.MI.4822<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G1_C8`2<class BaseClass1,class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldstr "========================================================================\n\n" call void [mscorlib]System.Console::WriteLine(string) ret } .method public hidebysig static int32 Main() cil managed { .custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = ( 01 00 00 00 ) .entrypoint .maxstack 10 call void Generated928::MethodCallingTest() call void Generated928::ConstrainedCallsTest() call void Generated928::StructConstrainedInterfaceCallsTest() call void Generated928::CalliTest() ldc.i4 100 ret } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/libraries/System.Text.RegularExpressions/System.Text.RegularExpressions.sln
Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{63551298-BFD4-43FC-8465-AC454228B83C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{08F0E5F4-BBD5-45CC-BB12-BA37A83AD7B6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{77CDA838-6489-4816-8847-DE2C7F5E1DCE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.RegularExpressions.Generator", "gen\System.Text.RegularExpressions.Generator.csproj", "{3699C8E2-C354-4AED-81DC-ECBAC3EFEB4B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.RegularExpressions", "ref\System.Text.RegularExpressions.csproj", "{C043B00D-8662-43E4-9E87-8BB317059111}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.RegularExpressions", "src\System.Text.RegularExpressions.csproj", "{0409C086-D7CC-43F8-9762-C94FB1E47F5B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.RegularExpressions.Generators.Tests", "tests\System.Text.RegularExpressions.Generators.Tests\System.Text.RegularExpressions.Generators.Tests.csproj", "{32ABFCDA-10FD-4A98-A429-145C28021EBE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.RegularExpressions.Tests", "tests\System.Text.RegularExpressions.Tests.csproj", "{8EE1A7C4-3630-4900-8976-9B3ADAFF10DC}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{2ACCCAAB-F0CE-4839-82BD-F174861DEA78}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{0D20E771-24BD-4F9E-BBD0-60156E8C44FC}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{15319A22-BC91-407B-A795-334DD05C82A0}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{D8FD137E-6961-4629-A71A-53394897FE6B}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {63551298-BFD4-43FC-8465-AC454228B83C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {63551298-BFD4-43FC-8465-AC454228B83C}.Debug|Any CPU.Build.0 = Debug|Any CPU {63551298-BFD4-43FC-8465-AC454228B83C}.Release|Any CPU.ActiveCfg = Release|Any CPU {63551298-BFD4-43FC-8465-AC454228B83C}.Release|Any CPU.Build.0 = Release|Any CPU {08F0E5F4-BBD5-45CC-BB12-BA37A83AD7B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {08F0E5F4-BBD5-45CC-BB12-BA37A83AD7B6}.Debug|Any CPU.Build.0 = Debug|Any CPU {08F0E5F4-BBD5-45CC-BB12-BA37A83AD7B6}.Release|Any CPU.ActiveCfg = Release|Any CPU {08F0E5F4-BBD5-45CC-BB12-BA37A83AD7B6}.Release|Any CPU.Build.0 = Release|Any CPU {77CDA838-6489-4816-8847-DE2C7F5E1DCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {77CDA838-6489-4816-8847-DE2C7F5E1DCE}.Debug|Any CPU.Build.0 = Debug|Any CPU {77CDA838-6489-4816-8847-DE2C7F5E1DCE}.Release|Any CPU.ActiveCfg = Release|Any CPU {77CDA838-6489-4816-8847-DE2C7F5E1DCE}.Release|Any CPU.Build.0 = Release|Any CPU {3699C8E2-C354-4AED-81DC-ECBAC3EFEB4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3699C8E2-C354-4AED-81DC-ECBAC3EFEB4B}.Debug|Any CPU.Build.0 = Debug|Any CPU {3699C8E2-C354-4AED-81DC-ECBAC3EFEB4B}.Release|Any CPU.ActiveCfg = Release|Any CPU {3699C8E2-C354-4AED-81DC-ECBAC3EFEB4B}.Release|Any CPU.Build.0 = Release|Any CPU {C043B00D-8662-43E4-9E87-8BB317059111}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C043B00D-8662-43E4-9E87-8BB317059111}.Debug|Any CPU.Build.0 = Debug|Any CPU {C043B00D-8662-43E4-9E87-8BB317059111}.Release|Any CPU.ActiveCfg = Release|Any CPU {C043B00D-8662-43E4-9E87-8BB317059111}.Release|Any CPU.Build.0 = Release|Any CPU {0409C086-D7CC-43F8-9762-C94FB1E47F5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0409C086-D7CC-43F8-9762-C94FB1E47F5B}.Debug|Any CPU.Build.0 = Debug|Any CPU {0409C086-D7CC-43F8-9762-C94FB1E47F5B}.Release|Any CPU.ActiveCfg = Release|Any CPU {0409C086-D7CC-43F8-9762-C94FB1E47F5B}.Release|Any CPU.Build.0 = Release|Any CPU {32ABFCDA-10FD-4A98-A429-145C28021EBE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {32ABFCDA-10FD-4A98-A429-145C28021EBE}.Debug|Any CPU.Build.0 = Debug|Any CPU {32ABFCDA-10FD-4A98-A429-145C28021EBE}.Release|Any CPU.ActiveCfg = Release|Any CPU {32ABFCDA-10FD-4A98-A429-145C28021EBE}.Release|Any CPU.Build.0 = Release|Any CPU {8EE1A7C4-3630-4900-8976-9B3ADAFF10DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8EE1A7C4-3630-4900-8976-9B3ADAFF10DC}.Debug|Any CPU.Build.0 = Debug|Any CPU {8EE1A7C4-3630-4900-8976-9B3ADAFF10DC}.Release|Any CPU.ActiveCfg = Release|Any CPU {8EE1A7C4-3630-4900-8976-9B3ADAFF10DC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {63551298-BFD4-43FC-8465-AC454228B83C} = {2ACCCAAB-F0CE-4839-82BD-F174861DEA78} {32ABFCDA-10FD-4A98-A429-145C28021EBE} = {2ACCCAAB-F0CE-4839-82BD-F174861DEA78} {8EE1A7C4-3630-4900-8976-9B3ADAFF10DC} = {2ACCCAAB-F0CE-4839-82BD-F174861DEA78} {08F0E5F4-BBD5-45CC-BB12-BA37A83AD7B6} = {0D20E771-24BD-4F9E-BBD0-60156E8C44FC} {77CDA838-6489-4816-8847-DE2C7F5E1DCE} = {0D20E771-24BD-4F9E-BBD0-60156E8C44FC} {3699C8E2-C354-4AED-81DC-ECBAC3EFEB4B} = {0D20E771-24BD-4F9E-BBD0-60156E8C44FC} {C043B00D-8662-43E4-9E87-8BB317059111} = {15319A22-BC91-407B-A795-334DD05C82A0} {0409C086-D7CC-43F8-9762-C94FB1E47F5B} = {D8FD137E-6961-4629-A71A-53394897FE6B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1ED4AB32-B7AA-478F-A96B-F725ACD0AABB} EndGlobalSection EndGlobal
Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{63551298-BFD4-43FC-8465-AC454228B83C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DllImportGenerator", "..\System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj", "{08F0E5F4-BBD5-45CC-BB12-BA37A83AD7B6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{77CDA838-6489-4816-8847-DE2C7F5E1DCE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.RegularExpressions.Generator", "gen\System.Text.RegularExpressions.Generator.csproj", "{3699C8E2-C354-4AED-81DC-ECBAC3EFEB4B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.RegularExpressions", "ref\System.Text.RegularExpressions.csproj", "{C043B00D-8662-43E4-9E87-8BB317059111}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.RegularExpressions", "src\System.Text.RegularExpressions.csproj", "{0409C086-D7CC-43F8-9762-C94FB1E47F5B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.RegularExpressions.Tests", "tests\FunctionalTests\System.Text.RegularExpressions.Tests.csproj", "{8EE1A7C4-3630-4900-8976-9B3ADAFF10DC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.RegularExpressions.UnitTests", "tests\UnitTests\System.Text.RegularExpressions.UnitTests.csproj", "{A86931EC-34DC-40A8-BD8C-F5E13BDBA903}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{2ACCCAAB-F0CE-4839-82BD-F174861DEA78}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{0D20E771-24BD-4F9E-BBD0-60156E8C44FC}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{15319A22-BC91-407B-A795-334DD05C82A0}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{D8FD137E-6961-4629-A71A-53394897FE6B}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {63551298-BFD4-43FC-8465-AC454228B83C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {63551298-BFD4-43FC-8465-AC454228B83C}.Debug|Any CPU.Build.0 = Debug|Any CPU {63551298-BFD4-43FC-8465-AC454228B83C}.Release|Any CPU.ActiveCfg = Release|Any CPU {63551298-BFD4-43FC-8465-AC454228B83C}.Release|Any CPU.Build.0 = Release|Any CPU {08F0E5F4-BBD5-45CC-BB12-BA37A83AD7B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {08F0E5F4-BBD5-45CC-BB12-BA37A83AD7B6}.Debug|Any CPU.Build.0 = Debug|Any CPU {08F0E5F4-BBD5-45CC-BB12-BA37A83AD7B6}.Release|Any CPU.ActiveCfg = Release|Any CPU {08F0E5F4-BBD5-45CC-BB12-BA37A83AD7B6}.Release|Any CPU.Build.0 = Release|Any CPU {77CDA838-6489-4816-8847-DE2C7F5E1DCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {77CDA838-6489-4816-8847-DE2C7F5E1DCE}.Debug|Any CPU.Build.0 = Debug|Any CPU {77CDA838-6489-4816-8847-DE2C7F5E1DCE}.Release|Any CPU.ActiveCfg = Release|Any CPU {77CDA838-6489-4816-8847-DE2C7F5E1DCE}.Release|Any CPU.Build.0 = Release|Any CPU {3699C8E2-C354-4AED-81DC-ECBAC3EFEB4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3699C8E2-C354-4AED-81DC-ECBAC3EFEB4B}.Debug|Any CPU.Build.0 = Debug|Any CPU {3699C8E2-C354-4AED-81DC-ECBAC3EFEB4B}.Release|Any CPU.ActiveCfg = Release|Any CPU {3699C8E2-C354-4AED-81DC-ECBAC3EFEB4B}.Release|Any CPU.Build.0 = Release|Any CPU {C043B00D-8662-43E4-9E87-8BB317059111}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C043B00D-8662-43E4-9E87-8BB317059111}.Debug|Any CPU.Build.0 = Debug|Any CPU {C043B00D-8662-43E4-9E87-8BB317059111}.Release|Any CPU.ActiveCfg = Release|Any CPU {C043B00D-8662-43E4-9E87-8BB317059111}.Release|Any CPU.Build.0 = Release|Any CPU {0409C086-D7CC-43F8-9762-C94FB1E47F5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0409C086-D7CC-43F8-9762-C94FB1E47F5B}.Debug|Any CPU.Build.0 = Debug|Any CPU {0409C086-D7CC-43F8-9762-C94FB1E47F5B}.Release|Any CPU.ActiveCfg = Release|Any CPU {0409C086-D7CC-43F8-9762-C94FB1E47F5B}.Release|Any CPU.Build.0 = Release|Any CPU {8EE1A7C4-3630-4900-8976-9B3ADAFF10DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8EE1A7C4-3630-4900-8976-9B3ADAFF10DC}.Debug|Any CPU.Build.0 = Debug|Any CPU {8EE1A7C4-3630-4900-8976-9B3ADAFF10DC}.Release|Any CPU.ActiveCfg = Release|Any CPU {8EE1A7C4-3630-4900-8976-9B3ADAFF10DC}.Release|Any CPU.Build.0 = Release|Any CPU {A86931EC-34DC-40A8-BD8C-F5E13BDBA903}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A86931EC-34DC-40A8-BD8C-F5E13BDBA903}.Debug|Any CPU.Build.0 = Debug|Any CPU {A86931EC-34DC-40A8-BD8C-F5E13BDBA903}.Release|Any CPU.ActiveCfg = Release|Any CPU {A86931EC-34DC-40A8-BD8C-F5E13BDBA903}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {63551298-BFD4-43FC-8465-AC454228B83C} = {2ACCCAAB-F0CE-4839-82BD-F174861DEA78} {8EE1A7C4-3630-4900-8976-9B3ADAFF10DC} = {2ACCCAAB-F0CE-4839-82BD-F174861DEA78} {A86931EC-34DC-40A8-BD8C-F5E13BDBA903} = {2ACCCAAB-F0CE-4839-82BD-F174861DEA78} {08F0E5F4-BBD5-45CC-BB12-BA37A83AD7B6} = {0D20E771-24BD-4F9E-BBD0-60156E8C44FC} {77CDA838-6489-4816-8847-DE2C7F5E1DCE} = {0D20E771-24BD-4F9E-BBD0-60156E8C44FC} {3699C8E2-C354-4AED-81DC-ECBAC3EFEB4B} = {0D20E771-24BD-4F9E-BBD0-60156E8C44FC} {C043B00D-8662-43E4-9E87-8BB317059111} = {15319A22-BC91-407B-A795-334DD05C82A0} {0409C086-D7CC-43F8-9762-C94FB1E47F5B} = {D8FD137E-6961-4629-A71A-53394897FE6B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1ED4AB32-B7AA-478F-A96B-F725ACD0AABB} EndGlobalSection EndGlobal
1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexFindOptimizations.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Diagnostics; using System.Globalization; namespace System.Text.RegularExpressions { /// <summary>Contains state and provides operations related to finding the next location a match could possibly begin.</summary> internal sealed class RegexFindOptimizations { /// <summary>The minimum required length an input need be to match the pattern.</summary> /// <remarks>0 is a valid minimum length. This value may also be the max (and hence fixed) length of the expression.</remarks> private readonly int _minRequiredLength; /// <summary>True if the input should be processed right-to-left rather than left-to-right.</summary> private readonly bool _rightToLeft; /// <summary>Provides the ToLower routine for lowercasing characters.</summary> private readonly TextInfo _textInfo; /// <summary>Lookup table used for optimizing ASCII when doing set queries.</summary> private readonly uint[]?[]? _asciiLookups; public RegexFindOptimizations(RegexTree tree, CultureInfo culture) { _rightToLeft = (tree.Options & RegexOptions.RightToLeft) != 0; _minRequiredLength = tree.MinRequiredLength; _textInfo = culture.TextInfo; // Compute any anchor starting the expression. If there is one, we won't need to search for anything, // as we can just match at that single location. LeadingAnchor = RegexPrefixAnalyzer.FindLeadingAnchor(tree.Root); if (_rightToLeft && LeadingAnchor == RegexNodeKind.Bol) { // Filter out Bol for RightToLeft, as we don't currently optimize for it. LeadingAnchor = RegexNodeKind.Unknown; } if (LeadingAnchor is RegexNodeKind.Beginning or RegexNodeKind.Start or RegexNodeKind.EndZ or RegexNodeKind.End) { FindMode = (LeadingAnchor, _rightToLeft) switch { (RegexNodeKind.Beginning, false) => FindNextStartingPositionMode.LeadingAnchor_LeftToRight_Beginning, (RegexNodeKind.Beginning, true) => FindNextStartingPositionMode.LeadingAnchor_RightToLeft_Beginning, (RegexNodeKind.Start, false) => FindNextStartingPositionMode.LeadingAnchor_LeftToRight_Start, (RegexNodeKind.Start, true) => FindNextStartingPositionMode.LeadingAnchor_RightToLeft_Start, (RegexNodeKind.End, false) => FindNextStartingPositionMode.LeadingAnchor_LeftToRight_End, (RegexNodeKind.End, true) => FindNextStartingPositionMode.LeadingAnchor_RightToLeft_End, (_, false) => FindNextStartingPositionMode.LeadingAnchor_LeftToRight_EndZ, (_, true) => FindNextStartingPositionMode.LeadingAnchor_RightToLeft_EndZ, }; return; } // Compute any anchor trailing the expression. If there is one, and we can also compute a fixed length // for the whole expression, we can use that to quickly jump to the right location in the input. if (!_rightToLeft) // haven't added FindNextStartingPositionMode support for RTL { bool triedToComputeMaxLength = false; TrailingAnchor = RegexPrefixAnalyzer.FindTrailingAnchor(tree.Root); if (TrailingAnchor is RegexNodeKind.End or RegexNodeKind.EndZ) { triedToComputeMaxLength = true; if (tree.Root.ComputeMaxLength() is int maxLength) { Debug.Assert(maxLength >= _minRequiredLength, $"{maxLength} should have been greater than {_minRequiredLength} minimum"); MaxPossibleLength = maxLength; if (_minRequiredLength == maxLength) { FindMode = TrailingAnchor == RegexNodeKind.End ? FindNextStartingPositionMode.TrailingAnchor_FixedLength_LeftToRight_End : FindNextStartingPositionMode.TrailingAnchor_FixedLength_LeftToRight_EndZ; return; } } } if ((tree.Options & RegexOptions.NonBacktracking) != 0 && !triedToComputeMaxLength) { // NonBacktracking also benefits from knowing whether the pattern is a fixed length, as it can use that // knowledge to avoid multiple match phases in some situations. MaxPossibleLength = tree.Root.ComputeMaxLength(); } } // If there's a leading case-sensitive substring, just use IndexOf and inherit all of its optimizations. string caseSensitivePrefix = RegexPrefixAnalyzer.FindCaseSensitivePrefix(tree.Root); if (caseSensitivePrefix.Length > 1) { LeadingCaseSensitivePrefix = caseSensitivePrefix; FindMode = _rightToLeft ? FindNextStartingPositionMode.LeadingPrefix_RightToLeft_CaseSensitive : FindNextStartingPositionMode.LeadingPrefix_LeftToRight_CaseSensitive; return; } // At this point there are no fast-searchable anchors or case-sensitive prefixes. We can now analyze the // pattern for sets and then use any found sets to determine what kind of search to perform. // If we're compiling, then the compilation process already handles sets that reduce to a single literal, // so we can simplify and just always go for the sets. bool dfa = (tree.Options & RegexOptions.NonBacktracking) != 0; bool compiled = (tree.Options & RegexOptions.Compiled) != 0 && !dfa; // for now, we never generate code for NonBacktracking, so treat it as non-compiled bool interpreter = !compiled && !dfa; // For interpreter, we want to employ optimizations, but we don't want to make construction significantly // more expensive; someone who wants to pay to do more work can specify Compiled. So for the interpreter // we focus only on creating a set for the first character. Same for right-to-left, which is used very // rarely and thus we don't need to invest in special-casing it. if (_rightToLeft) { // Determine a set for anything that can possibly start the expression. if (RegexPrefixAnalyzer.FindFirstCharClass(tree, culture) is (string CharClass, bool CaseInsensitive) set) { // See if the set is limited to holding only a few characters. Span<char> scratch = stackalloc char[5]; // max optimized by IndexOfAny today int scratchCount; char[]? chars = null; if (!RegexCharClass.IsNegated(set.CharClass) && (scratchCount = RegexCharClass.GetSetChars(set.CharClass, scratch)) > 0) { chars = scratch.Slice(0, scratchCount).ToArray(); } if (!compiled && chars is { Length: 1 }) { // The set contains one and only one character, meaning every match starts // with the same literal value (potentially case-insensitive). Search for that. FixedDistanceLiteral = (chars[0], 0); FindMode = (_rightToLeft, set.CaseInsensitive) switch { (false, false) => FindNextStartingPositionMode.FixedLiteral_LeftToRight_CaseSensitive, (false, true) => FindNextStartingPositionMode.FixedLiteral_LeftToRight_CaseInsensitive, (true, false) => FindNextStartingPositionMode.LeadingLiteral_RightToLeft_CaseSensitive, (true, true) => FindNextStartingPositionMode.LeadingLiteral_RightToLeft_CaseInsensitive, }; } else { // The set may match multiple characters. Search for that. FixedDistanceSets = new() { (chars, set.CharClass, 0, set.CaseInsensitive) }; FindMode = (_rightToLeft, set.CaseInsensitive) switch { (false, false) => FindNextStartingPositionMode.LeadingSet_LeftToRight_CaseSensitive, (false, true) => FindNextStartingPositionMode.LeadingSet_LeftToRight_CaseInsensitive, (true, false) => FindNextStartingPositionMode.LeadingSet_RightToLeft_CaseSensitive, (true, true) => FindNextStartingPositionMode.LeadingSet_RightToLeft_CaseInsensitive, }; _asciiLookups = new uint[1][]; } } return; } // We're now left-to-right only and looking for sets. // As a backup, see if we can find a literal after a leading atomic loop. That might be better than whatever sets we find, so // we want to know whether we have one in our pocket before deciding whether to use a leading set. (RegexNode LoopNode, (char Char, string? String, char[]? Chars) Literal)? literalAfterLoop = RegexPrefixAnalyzer.FindLiteralFollowingLeadingLoop(tree); // Build up a list of all of the sets that are a fixed distance from the start of the expression. List<(char[]? Chars, string Set, int Distance, bool CaseInsensitive)>? fixedDistanceSets = RegexPrefixAnalyzer.FindFixedDistanceSets(tree, culture, thorough: !interpreter); Debug.Assert(fixedDistanceSets is null || fixedDistanceSets.Count != 0); // If we got such sets, we'll likely use them. However, if the best of them is something that doesn't support a vectorized // search and we did successfully find a literal after an atomic loop we could search instead, we prefer the vectorizable search. if (fixedDistanceSets is not null && (fixedDistanceSets[0].Chars is not null || literalAfterLoop is null)) { // Determine whether to do searching based on one or more sets or on a single literal. Compiled engines // don't need to special-case literals as they already do codegen to create the optimal lookup based on // the set's characteristics. if (!compiled && fixedDistanceSets.Count == 1 && fixedDistanceSets[0].Chars is { Length: 1 }) { FixedDistanceLiteral = (fixedDistanceSets[0].Chars![0], fixedDistanceSets[0].Distance); FindMode = fixedDistanceSets[0].CaseInsensitive ? FindNextStartingPositionMode.FixedLiteral_LeftToRight_CaseInsensitive : FindNextStartingPositionMode.FixedLiteral_LeftToRight_CaseSensitive; } else { // Limit how many sets we use to avoid doing lots of unnecessary work. The list was already // sorted from best to worst, so just keep the first ones up to our limit. const int MaxSetsToUse = 3; // arbitrary tuned limit if (fixedDistanceSets.Count > MaxSetsToUse) { fixedDistanceSets.RemoveRange(MaxSetsToUse, fixedDistanceSets.Count - MaxSetsToUse); } // Store the sets, and compute which mode to use. FixedDistanceSets = fixedDistanceSets; FindMode = (fixedDistanceSets.Count == 1 && fixedDistanceSets[0].Distance == 0, fixedDistanceSets[0].CaseInsensitive) switch { (true, true) => FindNextStartingPositionMode.LeadingSet_LeftToRight_CaseInsensitive, (true, false) => FindNextStartingPositionMode.LeadingSet_LeftToRight_CaseSensitive, (false, true) => FindNextStartingPositionMode.FixedSets_LeftToRight_CaseInsensitive, (false, false) => FindNextStartingPositionMode.FixedSets_LeftToRight_CaseSensitive, }; _asciiLookups = new uint[fixedDistanceSets.Count][]; } return; } // If we found a literal we can search for after a leading set loop, use it. if (literalAfterLoop is not null) { FindMode = FindNextStartingPositionMode.LiteralAfterLoop_LeftToRight_CaseSensitive; LiteralAfterLoop = literalAfterLoop; _asciiLookups = new uint[1][]; return; } } /// <summary>Gets the selected mode for performing the next <see cref="TryFindNextStartingPosition"/> operation</summary> public FindNextStartingPositionMode FindMode { get; } = FindNextStartingPositionMode.NoSearch; /// <summary>Gets the leading anchor (e.g. RegexNodeKind.Bol) if one exists and was computed.</summary> public RegexNodeKind LeadingAnchor { get; } /// <summary>Gets the trailing anchor (e.g. RegexNodeKind.Bol) if one exists and was computed.</summary> public RegexNodeKind TrailingAnchor { get; } /// <summary>The maximum possible length an input could be to match the pattern.</summary> /// <remarks> /// This is currently only set when <see cref="TrailingAnchor"/> is found to be an end anchor. /// That can be expanded in the future as needed. /// </remarks> public int? MaxPossibleLength { get; } /// <summary>Gets the leading prefix. May be an empty string.</summary> public string LeadingCaseSensitivePrefix { get; } = string.Empty; /// <summary>When in fixed distance literal mode, gets the literal and how far it is from the start of the pattern.</summary> public (char Literal, int Distance) FixedDistanceLiteral { get; } /// <summary>When in fixed distance set mode, gets the set and how far it is from the start of the pattern.</summary> /// <remarks>The case-insensitivity of the 0th entry will always match the mode selected, but subsequent entries may not.</remarks> public List<(char[]? Chars, string Set, int Distance, bool CaseInsensitive)>? FixedDistanceSets { get; } /// <summary>When in literal after set loop node, gets the literal to search for and the RegexNode representing the leading loop.</summary> public (RegexNode LoopNode, (char Char, string? String, char[]? Chars) Literal)? LiteralAfterLoop { get; } /// <summary>Try to advance to the next starting position that might be a location for a match.</summary> /// <param name="textSpan">The text to search.</param> /// <param name="pos">The position in <paramref name="textSpan"/>. This is updated with the found position.</param> /// <param name="beginning">The index in <paramref name="textSpan"/> to consider the beginning for beginning anchor purposes.</param> /// <param name="start">The index in <paramref name="textSpan"/> to consider the start for start anchor purposes.</param> /// <param name="end">The index in <paramref name="textSpan"/> to consider the non-inclusive end of the string.</param> /// <returns>true if a position to attempt a match was found; false if none was found.</returns> public bool TryFindNextStartingPosition(ReadOnlySpan<char> textSpan, ref int pos, int beginning, int start, int end) { // Return early if we know there's not enough input left to match. if (!_rightToLeft) { if (pos > end - _minRequiredLength) { pos = end; return false; } } else { if (pos - _minRequiredLength < beginning) { pos = beginning; return false; } } // Optimize the handling of a Beginning-Of-Line (BOL) anchor (only for left-to-right). BOL is special, in that unlike // other anchors like Beginning, there are potentially multiple places a BOL can match. So unlike // the other anchors, which all skip all subsequent processing if found, with BOL we just use it // to boost our position to the next line, and then continue normally with any searches. if (LeadingAnchor == RegexNodeKind.Bol) { // If we're not currently positioned at the beginning of a line (either // the beginning of the string or just after a line feed), find the next // newline and position just after it. Debug.Assert(!_rightToLeft); if (pos > beginning && textSpan[pos - 1] != '\n') { int newline = textSpan.Slice(pos).IndexOf('\n'); if (newline == -1 || newline + 1 + pos > end) { pos = end; return false; } pos = newline + 1 + pos; } } switch (FindMode) { // There's an anchor. For some, we can simply compare against the current position. // For others, we can jump to the relevant location. case FindNextStartingPositionMode.LeadingAnchor_LeftToRight_Beginning: if (pos > beginning) { pos = end; return false; } return true; case FindNextStartingPositionMode.LeadingAnchor_LeftToRight_Start: if (pos > start) { pos = end; return false; } return true; case FindNextStartingPositionMode.LeadingAnchor_LeftToRight_EndZ: if (pos < end - 1) { pos = end - 1; } return true; case FindNextStartingPositionMode.LeadingAnchor_LeftToRight_End: if (pos < end) { pos = end; } return true; case FindNextStartingPositionMode.LeadingAnchor_RightToLeft_Beginning: if (pos > beginning) { pos = beginning; } return true; case FindNextStartingPositionMode.LeadingAnchor_RightToLeft_Start: if (pos < start) { pos = beginning; return false; } return true; case FindNextStartingPositionMode.LeadingAnchor_RightToLeft_EndZ: if (pos < end - 1 || (pos == end - 1 && textSpan[pos] != '\n')) { pos = beginning; return false; } return true; case FindNextStartingPositionMode.LeadingAnchor_RightToLeft_End: if (pos < end) { pos = beginning; return false; } return true; case FindNextStartingPositionMode.TrailingAnchor_FixedLength_LeftToRight_EndZ: if (pos < end - _minRequiredLength - 1) { pos = end - _minRequiredLength - 1; } return true; case FindNextStartingPositionMode.TrailingAnchor_FixedLength_LeftToRight_End: if (pos < end - _minRequiredLength) { pos = end - _minRequiredLength; } return true; // There's a case-sensitive prefix. Search for it with ordinal IndexOf. case FindNextStartingPositionMode.LeadingPrefix_LeftToRight_CaseSensitive: { int i = textSpan.Slice(pos, end - pos).IndexOf(LeadingCaseSensitivePrefix.AsSpan()); if (i >= 0) { pos += i; return true; } pos = end; return false; } case FindNextStartingPositionMode.LeadingPrefix_RightToLeft_CaseSensitive: { int i = textSpan.Slice(beginning, pos - beginning).LastIndexOf(LeadingCaseSensitivePrefix.AsSpan()); if (i >= 0) { pos = beginning + i + LeadingCaseSensitivePrefix.Length; return true; } pos = beginning; return false; } // There's a literal at the beginning of the pattern. Search for it. case FindNextStartingPositionMode.LeadingLiteral_RightToLeft_CaseSensitive: { int i = textSpan.Slice(beginning, pos - beginning).LastIndexOf(FixedDistanceLiteral.Literal); if (i >= 0) { pos = beginning + i + 1; return true; } pos = beginning; return false; } case FindNextStartingPositionMode.LeadingLiteral_RightToLeft_CaseInsensitive: { char ch = FixedDistanceLiteral.Literal; TextInfo ti = _textInfo; ReadOnlySpan<char> span = textSpan.Slice(beginning, pos - beginning); for (int i = span.Length - 1; i >= 0; i--) { if (ti.ToLower(span[i]) == ch) { pos = beginning + i + 1; return true; } } pos = beginning; return false; } // There's a set at the beginning of the pattern. Search for it. case FindNextStartingPositionMode.LeadingSet_LeftToRight_CaseSensitive: { (char[]? chars, string set, _, _) = FixedDistanceSets![0]; ReadOnlySpan<char> span = textSpan.Slice(pos, end - pos); if (chars is not null) { int i = span.IndexOfAny(chars); if (i >= 0) { pos += i; return true; } } else { ref uint[]? startingAsciiLookup = ref _asciiLookups![0]; for (int i = 0; i < span.Length; i++) { if (RegexCharClass.CharInClass(span[i], set, ref startingAsciiLookup)) { pos += i; return true; } } } pos = end; return false; } case FindNextStartingPositionMode.LeadingSet_LeftToRight_CaseInsensitive: { ref uint[]? startingAsciiLookup = ref _asciiLookups![0]; string set = FixedDistanceSets![0].Set; TextInfo ti = _textInfo; ReadOnlySpan<char> span = textSpan.Slice(pos, end - pos); for (int i = 0; i < span.Length; i++) { if (RegexCharClass.CharInClass(ti.ToLower(span[i]), set, ref startingAsciiLookup)) { pos += i; return true; } } pos = end; return false; } case FindNextStartingPositionMode.LeadingSet_RightToLeft_CaseSensitive: { ref uint[]? startingAsciiLookup = ref _asciiLookups![0]; string set = FixedDistanceSets![0].Set; ReadOnlySpan<char> span = textSpan.Slice(beginning, pos - beginning); for (int i = span.Length - 1; i >= 0; i--) { if (RegexCharClass.CharInClass(span[i], set, ref startingAsciiLookup)) { pos = beginning + i + 1; return true; } } pos = beginning; return false; } case FindNextStartingPositionMode.LeadingSet_RightToLeft_CaseInsensitive: { ref uint[]? startingAsciiLookup = ref _asciiLookups![0]; string set = FixedDistanceSets![0].Set; TextInfo ti = _textInfo; ReadOnlySpan<char> span = textSpan.Slice(beginning, pos - beginning); for (int i = span.Length - 1; i >= 0; i--) { if (RegexCharClass.CharInClass(ti.ToLower(span[i]), set, ref startingAsciiLookup)) { pos = beginning + i + 1; return true; } } pos = beginning; return false; } // There's a literal at a fixed offset from the beginning of the pattern. Search for it. case FindNextStartingPositionMode.FixedLiteral_LeftToRight_CaseSensitive: { Debug.Assert(FixedDistanceLiteral.Distance <= _minRequiredLength); int i = textSpan.Slice(pos + FixedDistanceLiteral.Distance, end - pos - FixedDistanceLiteral.Distance).IndexOf(FixedDistanceLiteral.Literal); if (i >= 0) { pos += i; return true; } pos = end; return false; } case FindNextStartingPositionMode.FixedLiteral_LeftToRight_CaseInsensitive: { Debug.Assert(FixedDistanceLiteral.Distance <= _minRequiredLength); char ch = FixedDistanceLiteral.Literal; TextInfo ti = _textInfo; ReadOnlySpan<char> span = textSpan.Slice(pos + FixedDistanceLiteral.Distance, end - pos - FixedDistanceLiteral.Distance); for (int i = 0; i < span.Length; i++) { if (ti.ToLower(span[i]) == ch) { pos += i; return true; } } pos = end; return false; } // There are one or more sets at fixed offsets from the start of the pattern. case FindNextStartingPositionMode.FixedSets_LeftToRight_CaseSensitive: { List<(char[]? Chars, string Set, int Distance, bool CaseInsensitive)> sets = FixedDistanceSets!; (char[]? primaryChars, string primarySet, int primaryDistance, _) = sets[0]; int endMinusRequiredLength = end - Math.Max(1, _minRequiredLength); if (primaryChars is not null) { for (int inputPosition = pos; inputPosition <= endMinusRequiredLength; inputPosition++) { int offset = inputPosition + primaryDistance; int index = textSpan.Slice(offset, end - offset).IndexOfAny(primaryChars); if (index < 0) { break; } index += offset; // The index here will be offset indexed due to the use of span, so we add offset to get // real position on the string. inputPosition = index - primaryDistance; if (inputPosition > endMinusRequiredLength) { break; } for (int i = 1; i < sets.Count; i++) { (_, string nextSet, int nextDistance, bool nextCaseInsensitive) = sets[i]; char c = textSpan[inputPosition + nextDistance]; if (!RegexCharClass.CharInClass(nextCaseInsensitive ? _textInfo.ToLower(c) : c, nextSet, ref _asciiLookups![i])) { goto Bumpalong; } } pos = inputPosition; return true; Bumpalong:; } } else { ref uint[]? startingAsciiLookup = ref _asciiLookups![0]; for (int inputPosition = pos; inputPosition <= endMinusRequiredLength; inputPosition++) { char c = textSpan[inputPosition + primaryDistance]; if (!RegexCharClass.CharInClass(c, primarySet, ref startingAsciiLookup)) { goto Bumpalong; } for (int i = 1; i < sets.Count; i++) { (_, string nextSet, int nextDistance, bool nextCaseInsensitive) = sets[i]; c = textSpan[inputPosition + nextDistance]; if (!RegexCharClass.CharInClass(nextCaseInsensitive ? _textInfo.ToLower(c) : c, nextSet, ref _asciiLookups![i])) { goto Bumpalong; } } pos = inputPosition; return true; Bumpalong:; } } pos = end; return false; } case FindNextStartingPositionMode.FixedSets_LeftToRight_CaseInsensitive: { List<(char[]? Chars, string Set, int Distance, bool CaseInsensitive)> sets = FixedDistanceSets!; (_, string primarySet, int primaryDistance, _) = sets[0]; int endMinusRequiredLength = end - Math.Max(1, _minRequiredLength); TextInfo ti = _textInfo; ref uint[]? startingAsciiLookup = ref _asciiLookups![0]; for (int inputPosition = pos; inputPosition <= endMinusRequiredLength; inputPosition++) { char c = textSpan[inputPosition + primaryDistance]; if (!RegexCharClass.CharInClass(ti.ToLower(c), primarySet, ref startingAsciiLookup)) { goto Bumpalong; } for (int i = 1; i < sets.Count; i++) { (_, string nextSet, int nextDistance, bool nextCaseInsensitive) = sets[i]; c = textSpan[inputPosition + nextDistance]; if (!RegexCharClass.CharInClass(nextCaseInsensitive ? _textInfo.ToLower(c) : c, nextSet, ref _asciiLookups![i])) { goto Bumpalong; } } pos = inputPosition; return true; Bumpalong:; } pos = end; return false; } // There's a literal after a leading set loop. Find the literal, then walk backwards through the loop to find the starting position. case FindNextStartingPositionMode.LiteralAfterLoop_LeftToRight_CaseSensitive: { Debug.Assert(LiteralAfterLoop is not null); (RegexNode loopNode, (char Char, string? String, char[]? Chars) literal) = LiteralAfterLoop.GetValueOrDefault(); Debug.Assert(loopNode.Kind is RegexNodeKind.Setloop or RegexNodeKind.Setlazy or RegexNodeKind.Setloopatomic); Debug.Assert(loopNode.N == int.MaxValue); int startingPos = pos; while (true) { ReadOnlySpan<char> slice = textSpan.Slice(startingPos, end - startingPos); // Find the literal. If we can't find it, we're done searching. int i = literal.String is not null ? slice.IndexOf(literal.String.AsSpan()) : literal.Chars is not null ? slice.IndexOfAny(literal.Chars.AsSpan()) : slice.IndexOf(literal.Char); if (i < 0) { break; } // We found the literal. Walk backwards from it finding as many matches as we can against the loop. int prev = i; while ((uint)--prev < (uint)slice.Length && RegexCharClass.CharInClass(slice[prev], loopNode.Str!, ref _asciiLookups![0])) ; // If we found fewer than needed, loop around to try again. The loop doesn't overlap with the literal, // so we can start from after the last place the literal matched. if ((i - prev - 1) < loopNode.M) { startingPos += i + 1; continue; } // We have a winner. The starting position is just after the last position that failed to match the loop. // TODO: It'd be nice to be able to communicate literalPos as a place the matching engine can start matching // after the loop, so that it doesn't need to re-match the loop. This might only be feasible for RegexCompiler // and the source generator after we refactor them to generate a single Scan method rather than separate // FindFirstChar / Go methods. pos = startingPos + prev + 1; return true; } pos = end; return false; } // Nothing special to look for. Just return true indicating this is a valid position to try to match. default: Debug.Assert(FindMode == FindNextStartingPositionMode.NoSearch); return true; } } } /// <summary>Mode to use for searching for the next location of a possible match.</summary> internal enum FindNextStartingPositionMode { /// <summary>A "beginning" anchor at the beginning of the pattern.</summary> LeadingAnchor_LeftToRight_Beginning, /// <summary>A "start" anchor at the beginning of the pattern.</summary> LeadingAnchor_LeftToRight_Start, /// <summary>An "endz" anchor at the beginning of the pattern. This is rare.</summary> LeadingAnchor_LeftToRight_EndZ, /// <summary>An "end" anchor at the beginning of the pattern. This is rare.</summary> LeadingAnchor_LeftToRight_End, /// <summary>A "beginning" anchor at the beginning of the right-to-left pattern.</summary> LeadingAnchor_RightToLeft_Beginning, /// <summary>A "start" anchor at the beginning of the right-to-left pattern.</summary> LeadingAnchor_RightToLeft_Start, /// <summary>An "endz" anchor at the beginning of the right-to-left pattern. This is rare.</summary> LeadingAnchor_RightToLeft_EndZ, /// <summary>An "end" anchor at the beginning of the right-to-left pattern. This is rare.</summary> LeadingAnchor_RightToLeft_End, /// <summary>An "end" anchor at the end of the pattern, with the pattern always matching a fixed-length expression.</summary> TrailingAnchor_FixedLength_LeftToRight_End, /// <summary>An "endz" anchor at the end of the pattern, with the pattern always matching a fixed-length expression.</summary> TrailingAnchor_FixedLength_LeftToRight_EndZ, /// <summary>A case-sensitive multi-character substring at the beginning of the pattern.</summary> LeadingPrefix_LeftToRight_CaseSensitive, /// <summary>A case-sensitive multi-character substring at the beginning of the right-to-left pattern.</summary> LeadingPrefix_RightToLeft_CaseSensitive, /// <summary>A case-sensitive set starting the pattern.</summary> LeadingSet_LeftToRight_CaseSensitive, /// <summary>A case-insensitive set starting the pattern.</summary> LeadingSet_LeftToRight_CaseInsensitive, /// <summary>A case-sensitive set starting the right-to-left pattern.</summary> LeadingSet_RightToLeft_CaseSensitive, /// <summary>A case-insensitive set starting the right-to-left pattern.</summary> LeadingSet_RightToLeft_CaseInsensitive, /// <summary>A case-sensitive single character at a fixed distance from the start of the right-to-left pattern.</summary> LeadingLiteral_RightToLeft_CaseSensitive, /// <summary>A case-insensitive single character at a fixed distance from the start of the right-to-left pattern.</summary> LeadingLiteral_RightToLeft_CaseInsensitive, /// <summary>A case-sensitive single character at a fixed distance from the start of the pattern.</summary> FixedLiteral_LeftToRight_CaseSensitive, /// <summary>A case-insensitive single character at a fixed distance from the start of the pattern.</summary> FixedLiteral_LeftToRight_CaseInsensitive, /// <summary>One or more sets at a fixed distance from the start of the pattern. At least the first set is case-sensitive.</summary> FixedSets_LeftToRight_CaseSensitive, /// <summary>One or more sets at a fixed distance from the start of the pattern. At least the first set is case-insensitive.</summary> FixedSets_LeftToRight_CaseInsensitive, /// <summary>A literal after a non-overlapping set loop at the start of the pattern. The literal is case-sensitive.</summary> LiteralAfterLoop_LeftToRight_CaseSensitive, /// <summary>Nothing to search for. Nop.</summary> NoSearch, } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Diagnostics; using System.Globalization; namespace System.Text.RegularExpressions { /// <summary>Contains state and provides operations related to finding the next location a match could possibly begin.</summary> internal sealed class RegexFindOptimizations { /// <summary>The minimum required length an input need be to match the pattern.</summary> /// <remarks>0 is a valid minimum length. This value may also be the max (and hence fixed) length of the expression.</remarks> private readonly int _minRequiredLength; /// <summary>True if the input should be processed right-to-left rather than left-to-right.</summary> private readonly bool _rightToLeft; /// <summary>Provides the ToLower routine for lowercasing characters.</summary> private readonly TextInfo _textInfo; /// <summary>Lookup table used for optimizing ASCII when doing set queries.</summary> private readonly uint[]?[]? _asciiLookups; public RegexFindOptimizations(RegexTree tree, CultureInfo culture) { _rightToLeft = (tree.Options & RegexOptions.RightToLeft) != 0; _minRequiredLength = tree.MinRequiredLength; _textInfo = culture.TextInfo; // Compute any anchor starting the expression. If there is one, we won't need to search for anything, // as we can just match at that single location. LeadingAnchor = RegexPrefixAnalyzer.FindLeadingAnchor(tree.Root); if (_rightToLeft && LeadingAnchor == RegexNodeKind.Bol) { // Filter out Bol for RightToLeft, as we don't currently optimize for it. LeadingAnchor = RegexNodeKind.Unknown; } if (LeadingAnchor is RegexNodeKind.Beginning or RegexNodeKind.Start or RegexNodeKind.EndZ or RegexNodeKind.End) { FindMode = (LeadingAnchor, _rightToLeft) switch { (RegexNodeKind.Beginning, false) => FindNextStartingPositionMode.LeadingAnchor_LeftToRight_Beginning, (RegexNodeKind.Beginning, true) => FindNextStartingPositionMode.LeadingAnchor_RightToLeft_Beginning, (RegexNodeKind.Start, false) => FindNextStartingPositionMode.LeadingAnchor_LeftToRight_Start, (RegexNodeKind.Start, true) => FindNextStartingPositionMode.LeadingAnchor_RightToLeft_Start, (RegexNodeKind.End, false) => FindNextStartingPositionMode.LeadingAnchor_LeftToRight_End, (RegexNodeKind.End, true) => FindNextStartingPositionMode.LeadingAnchor_RightToLeft_End, (_, false) => FindNextStartingPositionMode.LeadingAnchor_LeftToRight_EndZ, (_, true) => FindNextStartingPositionMode.LeadingAnchor_RightToLeft_EndZ, }; return; } // Compute any anchor trailing the expression. If there is one, and we can also compute a fixed length // for the whole expression, we can use that to quickly jump to the right location in the input. if (!_rightToLeft) // haven't added FindNextStartingPositionMode support for RTL { bool triedToComputeMaxLength = false; TrailingAnchor = RegexPrefixAnalyzer.FindTrailingAnchor(tree.Root); if (TrailingAnchor is RegexNodeKind.End or RegexNodeKind.EndZ) { triedToComputeMaxLength = true; if (tree.Root.ComputeMaxLength() is int maxLength) { Debug.Assert(maxLength >= _minRequiredLength, $"{maxLength} should have been greater than {_minRequiredLength} minimum"); MaxPossibleLength = maxLength; if (_minRequiredLength == maxLength) { FindMode = TrailingAnchor == RegexNodeKind.End ? FindNextStartingPositionMode.TrailingAnchor_FixedLength_LeftToRight_End : FindNextStartingPositionMode.TrailingAnchor_FixedLength_LeftToRight_EndZ; return; } } } if ((tree.Options & RegexOptions.NonBacktracking) != 0 && !triedToComputeMaxLength) { // NonBacktracking also benefits from knowing whether the pattern is a fixed length, as it can use that // knowledge to avoid multiple match phases in some situations. MaxPossibleLength = tree.Root.ComputeMaxLength(); } } // If there's a leading case-sensitive substring, just use IndexOf and inherit all of its optimizations. string caseSensitivePrefix = RegexPrefixAnalyzer.FindCaseSensitivePrefix(tree.Root); if (caseSensitivePrefix.Length > 1) { LeadingCaseSensitivePrefix = caseSensitivePrefix; FindMode = _rightToLeft ? FindNextStartingPositionMode.LeadingPrefix_RightToLeft_CaseSensitive : FindNextStartingPositionMode.LeadingPrefix_LeftToRight_CaseSensitive; return; } // At this point there are no fast-searchable anchors or case-sensitive prefixes. We can now analyze the // pattern for sets and then use any found sets to determine what kind of search to perform. // If we're compiling, then the compilation process already handles sets that reduce to a single literal, // so we can simplify and just always go for the sets. bool dfa = (tree.Options & RegexOptions.NonBacktracking) != 0; bool compiled = (tree.Options & RegexOptions.Compiled) != 0 && !dfa; // for now, we never generate code for NonBacktracking, so treat it as non-compiled bool interpreter = !compiled && !dfa; // For interpreter, we want to employ optimizations, but we don't want to make construction significantly // more expensive; someone who wants to pay to do more work can specify Compiled. So for the interpreter // we focus only on creating a set for the first character. Same for right-to-left, which is used very // rarely and thus we don't need to invest in special-casing it. if (_rightToLeft) { // Determine a set for anything that can possibly start the expression. if (RegexPrefixAnalyzer.FindFirstCharClass(tree, culture) is (string CharClass, bool CaseInsensitive) set) { // See if the set is limited to holding only a few characters. Span<char> scratch = stackalloc char[5]; // max optimized by IndexOfAny today int scratchCount; char[]? chars = null; if (!RegexCharClass.IsNegated(set.CharClass) && (scratchCount = RegexCharClass.GetSetChars(set.CharClass, scratch)) > 0) { chars = scratch.Slice(0, scratchCount).ToArray(); } if (!compiled && chars is { Length: 1 }) { // The set contains one and only one character, meaning every match starts // with the same literal value (potentially case-insensitive). Search for that. FixedDistanceLiteral = (chars[0], 0); FindMode = set.CaseInsensitive ? FindNextStartingPositionMode.LeadingLiteral_RightToLeft_CaseInsensitive : FindNextStartingPositionMode.LeadingLiteral_RightToLeft_CaseSensitive; } else { // The set may match multiple characters. Search for that. FixedDistanceSets = new() { (chars, set.CharClass, 0, set.CaseInsensitive) }; FindMode = set.CaseInsensitive ? FindNextStartingPositionMode.LeadingSet_RightToLeft_CaseInsensitive : FindNextStartingPositionMode.LeadingSet_RightToLeft_CaseSensitive; _asciiLookups = new uint[1][]; } } return; } // We're now left-to-right only and looking for sets. // As a backup, see if we can find a literal after a leading atomic loop. That might be better than whatever sets we find, so // we want to know whether we have one in our pocket before deciding whether to use a leading set. (RegexNode LoopNode, (char Char, string? String, char[]? Chars) Literal)? literalAfterLoop = RegexPrefixAnalyzer.FindLiteralFollowingLeadingLoop(tree); // Build up a list of all of the sets that are a fixed distance from the start of the expression. List<(char[]? Chars, string Set, int Distance, bool CaseInsensitive)>? fixedDistanceSets = RegexPrefixAnalyzer.FindFixedDistanceSets(tree, culture, thorough: !interpreter); Debug.Assert(fixedDistanceSets is null || fixedDistanceSets.Count != 0); // If we got such sets, we'll likely use them. However, if the best of them is something that doesn't support a vectorized // search and we did successfully find a literal after an atomic loop we could search instead, we prefer the vectorizable search. if (fixedDistanceSets is not null && (fixedDistanceSets[0].Chars is not null || literalAfterLoop is null)) { // Determine whether to do searching based on one or more sets or on a single literal. Compiled engines // don't need to special-case literals as they already do codegen to create the optimal lookup based on // the set's characteristics. if (!compiled && fixedDistanceSets.Count == 1 && fixedDistanceSets[0].Chars is { Length: 1 }) { FixedDistanceLiteral = (fixedDistanceSets[0].Chars![0], fixedDistanceSets[0].Distance); FindMode = fixedDistanceSets[0].CaseInsensitive ? FindNextStartingPositionMode.FixedLiteral_LeftToRight_CaseInsensitive : FindNextStartingPositionMode.FixedLiteral_LeftToRight_CaseSensitive; } else { // Limit how many sets we use to avoid doing lots of unnecessary work. The list was already // sorted from best to worst, so just keep the first ones up to our limit. const int MaxSetsToUse = 3; // arbitrary tuned limit if (fixedDistanceSets.Count > MaxSetsToUse) { fixedDistanceSets.RemoveRange(MaxSetsToUse, fixedDistanceSets.Count - MaxSetsToUse); } // Store the sets, and compute which mode to use. FixedDistanceSets = fixedDistanceSets; FindMode = (fixedDistanceSets.Count == 1 && fixedDistanceSets[0].Distance == 0, fixedDistanceSets[0].CaseInsensitive) switch { (true, true) => FindNextStartingPositionMode.LeadingSet_LeftToRight_CaseInsensitive, (true, false) => FindNextStartingPositionMode.LeadingSet_LeftToRight_CaseSensitive, (false, true) => FindNextStartingPositionMode.FixedSets_LeftToRight_CaseInsensitive, (false, false) => FindNextStartingPositionMode.FixedSets_LeftToRight_CaseSensitive, }; _asciiLookups = new uint[fixedDistanceSets.Count][]; } return; } // If we found a literal we can search for after a leading set loop, use it. if (literalAfterLoop is not null) { FindMode = FindNextStartingPositionMode.LiteralAfterLoop_LeftToRight_CaseSensitive; LiteralAfterLoop = literalAfterLoop; _asciiLookups = new uint[1][]; return; } } /// <summary>Gets the selected mode for performing the next <see cref="TryFindNextStartingPosition"/> operation</summary> public FindNextStartingPositionMode FindMode { get; } = FindNextStartingPositionMode.NoSearch; /// <summary>Gets the leading anchor (e.g. RegexNodeKind.Bol) if one exists and was computed.</summary> public RegexNodeKind LeadingAnchor { get; } /// <summary>Gets the trailing anchor (e.g. RegexNodeKind.Bol) if one exists and was computed.</summary> public RegexNodeKind TrailingAnchor { get; } /// <summary>The maximum possible length an input could be to match the pattern.</summary> /// <remarks> /// This is currently only set when <see cref="TrailingAnchor"/> is found to be an end anchor. /// That can be expanded in the future as needed. /// </remarks> public int? MaxPossibleLength { get; } /// <summary>Gets the leading prefix. May be an empty string.</summary> public string LeadingCaseSensitivePrefix { get; } = string.Empty; /// <summary>When in fixed distance literal mode, gets the literal and how far it is from the start of the pattern.</summary> public (char Literal, int Distance) FixedDistanceLiteral { get; } /// <summary>When in fixed distance set mode, gets the set and how far it is from the start of the pattern.</summary> /// <remarks>The case-insensitivity of the 0th entry will always match the mode selected, but subsequent entries may not.</remarks> public List<(char[]? Chars, string Set, int Distance, bool CaseInsensitive)>? FixedDistanceSets { get; } /// <summary>When in literal after set loop node, gets the literal to search for and the RegexNode representing the leading loop.</summary> public (RegexNode LoopNode, (char Char, string? String, char[]? Chars) Literal)? LiteralAfterLoop { get; } /// <summary>Try to advance to the next starting position that might be a location for a match.</summary> /// <param name="textSpan">The text to search.</param> /// <param name="pos">The position in <paramref name="textSpan"/>. This is updated with the found position.</param> /// <param name="beginning">The index in <paramref name="textSpan"/> to consider the beginning for beginning anchor purposes.</param> /// <param name="start">The index in <paramref name="textSpan"/> to consider the start for start anchor purposes.</param> /// <param name="end">The index in <paramref name="textSpan"/> to consider the non-inclusive end of the string.</param> /// <returns>true if a position to attempt a match was found; false if none was found.</returns> public bool TryFindNextStartingPosition(ReadOnlySpan<char> textSpan, ref int pos, int beginning, int start, int end) { // Return early if we know there's not enough input left to match. if (!_rightToLeft) { if (pos > end - _minRequiredLength) { pos = end; return false; } } else { if (pos - _minRequiredLength < beginning) { pos = beginning; return false; } } // Optimize the handling of a Beginning-Of-Line (BOL) anchor (only for left-to-right). BOL is special, in that unlike // other anchors like Beginning, there are potentially multiple places a BOL can match. So unlike // the other anchors, which all skip all subsequent processing if found, with BOL we just use it // to boost our position to the next line, and then continue normally with any searches. if (LeadingAnchor == RegexNodeKind.Bol) { // If we're not currently positioned at the beginning of a line (either // the beginning of the string or just after a line feed), find the next // newline and position just after it. Debug.Assert(!_rightToLeft); if (pos > beginning && textSpan[pos - 1] != '\n') { int newline = textSpan.Slice(pos).IndexOf('\n'); if (newline == -1 || newline + 1 + pos > end) { pos = end; return false; } pos = newline + 1 + pos; } } switch (FindMode) { // There's an anchor. For some, we can simply compare against the current position. // For others, we can jump to the relevant location. case FindNextStartingPositionMode.LeadingAnchor_LeftToRight_Beginning: if (pos > beginning) { pos = end; return false; } return true; case FindNextStartingPositionMode.LeadingAnchor_LeftToRight_Start: if (pos > start) { pos = end; return false; } return true; case FindNextStartingPositionMode.LeadingAnchor_LeftToRight_EndZ: if (pos < end - 1) { pos = end - 1; } return true; case FindNextStartingPositionMode.LeadingAnchor_LeftToRight_End: if (pos < end) { pos = end; } return true; case FindNextStartingPositionMode.LeadingAnchor_RightToLeft_Beginning: if (pos > beginning) { pos = beginning; } return true; case FindNextStartingPositionMode.LeadingAnchor_RightToLeft_Start: if (pos < start) { pos = beginning; return false; } return true; case FindNextStartingPositionMode.LeadingAnchor_RightToLeft_EndZ: if (pos < end - 1 || (pos == end - 1 && textSpan[pos] != '\n')) { pos = beginning; return false; } return true; case FindNextStartingPositionMode.LeadingAnchor_RightToLeft_End: if (pos < end) { pos = beginning; return false; } return true; case FindNextStartingPositionMode.TrailingAnchor_FixedLength_LeftToRight_EndZ: if (pos < end - _minRequiredLength - 1) { pos = end - _minRequiredLength - 1; } return true; case FindNextStartingPositionMode.TrailingAnchor_FixedLength_LeftToRight_End: if (pos < end - _minRequiredLength) { pos = end - _minRequiredLength; } return true; // There's a case-sensitive prefix. Search for it with ordinal IndexOf. case FindNextStartingPositionMode.LeadingPrefix_LeftToRight_CaseSensitive: { int i = textSpan.Slice(pos, end - pos).IndexOf(LeadingCaseSensitivePrefix.AsSpan()); if (i >= 0) { pos += i; return true; } pos = end; return false; } case FindNextStartingPositionMode.LeadingPrefix_RightToLeft_CaseSensitive: { int i = textSpan.Slice(beginning, pos - beginning).LastIndexOf(LeadingCaseSensitivePrefix.AsSpan()); if (i >= 0) { pos = beginning + i + LeadingCaseSensitivePrefix.Length; return true; } pos = beginning; return false; } // There's a literal at the beginning of the pattern. Search for it. case FindNextStartingPositionMode.LeadingLiteral_RightToLeft_CaseSensitive: { int i = textSpan.Slice(beginning, pos - beginning).LastIndexOf(FixedDistanceLiteral.Literal); if (i >= 0) { pos = beginning + i + 1; return true; } pos = beginning; return false; } case FindNextStartingPositionMode.LeadingLiteral_RightToLeft_CaseInsensitive: { char ch = FixedDistanceLiteral.Literal; TextInfo ti = _textInfo; ReadOnlySpan<char> span = textSpan.Slice(beginning, pos - beginning); for (int i = span.Length - 1; i >= 0; i--) { if (ti.ToLower(span[i]) == ch) { pos = beginning + i + 1; return true; } } pos = beginning; return false; } // There's a set at the beginning of the pattern. Search for it. case FindNextStartingPositionMode.LeadingSet_LeftToRight_CaseSensitive: { (char[]? chars, string set, _, _) = FixedDistanceSets![0]; ReadOnlySpan<char> span = textSpan.Slice(pos, end - pos); if (chars is not null) { int i = span.IndexOfAny(chars); if (i >= 0) { pos += i; return true; } } else { ref uint[]? startingAsciiLookup = ref _asciiLookups![0]; for (int i = 0; i < span.Length; i++) { if (RegexCharClass.CharInClass(span[i], set, ref startingAsciiLookup)) { pos += i; return true; } } } pos = end; return false; } case FindNextStartingPositionMode.LeadingSet_LeftToRight_CaseInsensitive: { ref uint[]? startingAsciiLookup = ref _asciiLookups![0]; string set = FixedDistanceSets![0].Set; TextInfo ti = _textInfo; ReadOnlySpan<char> span = textSpan.Slice(pos, end - pos); for (int i = 0; i < span.Length; i++) { if (RegexCharClass.CharInClass(ti.ToLower(span[i]), set, ref startingAsciiLookup)) { pos += i; return true; } } pos = end; return false; } case FindNextStartingPositionMode.LeadingSet_RightToLeft_CaseSensitive: { ref uint[]? startingAsciiLookup = ref _asciiLookups![0]; string set = FixedDistanceSets![0].Set; ReadOnlySpan<char> span = textSpan.Slice(beginning, pos - beginning); for (int i = span.Length - 1; i >= 0; i--) { if (RegexCharClass.CharInClass(span[i], set, ref startingAsciiLookup)) { pos = beginning + i + 1; return true; } } pos = beginning; return false; } case FindNextStartingPositionMode.LeadingSet_RightToLeft_CaseInsensitive: { ref uint[]? startingAsciiLookup = ref _asciiLookups![0]; string set = FixedDistanceSets![0].Set; TextInfo ti = _textInfo; ReadOnlySpan<char> span = textSpan.Slice(beginning, pos - beginning); for (int i = span.Length - 1; i >= 0; i--) { if (RegexCharClass.CharInClass(ti.ToLower(span[i]), set, ref startingAsciiLookup)) { pos = beginning + i + 1; return true; } } pos = beginning; return false; } // There's a literal at a fixed offset from the beginning of the pattern. Search for it. case FindNextStartingPositionMode.FixedLiteral_LeftToRight_CaseSensitive: { Debug.Assert(FixedDistanceLiteral.Distance <= _minRequiredLength); int i = textSpan.Slice(pos + FixedDistanceLiteral.Distance, end - pos - FixedDistanceLiteral.Distance).IndexOf(FixedDistanceLiteral.Literal); if (i >= 0) { pos += i; return true; } pos = end; return false; } case FindNextStartingPositionMode.FixedLiteral_LeftToRight_CaseInsensitive: { Debug.Assert(FixedDistanceLiteral.Distance <= _minRequiredLength); char ch = FixedDistanceLiteral.Literal; TextInfo ti = _textInfo; ReadOnlySpan<char> span = textSpan.Slice(pos + FixedDistanceLiteral.Distance, end - pos - FixedDistanceLiteral.Distance); for (int i = 0; i < span.Length; i++) { if (ti.ToLower(span[i]) == ch) { pos += i; return true; } } pos = end; return false; } // There are one or more sets at fixed offsets from the start of the pattern. case FindNextStartingPositionMode.FixedSets_LeftToRight_CaseSensitive: { List<(char[]? Chars, string Set, int Distance, bool CaseInsensitive)> sets = FixedDistanceSets!; (char[]? primaryChars, string primarySet, int primaryDistance, _) = sets[0]; int endMinusRequiredLength = end - Math.Max(1, _minRequiredLength); if (primaryChars is not null) { for (int inputPosition = pos; inputPosition <= endMinusRequiredLength; inputPosition++) { int offset = inputPosition + primaryDistance; int index = textSpan.Slice(offset, end - offset).IndexOfAny(primaryChars); if (index < 0) { break; } index += offset; // The index here will be offset indexed due to the use of span, so we add offset to get // real position on the string. inputPosition = index - primaryDistance; if (inputPosition > endMinusRequiredLength) { break; } for (int i = 1; i < sets.Count; i++) { (_, string nextSet, int nextDistance, bool nextCaseInsensitive) = sets[i]; char c = textSpan[inputPosition + nextDistance]; if (!RegexCharClass.CharInClass(nextCaseInsensitive ? _textInfo.ToLower(c) : c, nextSet, ref _asciiLookups![i])) { goto Bumpalong; } } pos = inputPosition; return true; Bumpalong:; } } else { ref uint[]? startingAsciiLookup = ref _asciiLookups![0]; for (int inputPosition = pos; inputPosition <= endMinusRequiredLength; inputPosition++) { char c = textSpan[inputPosition + primaryDistance]; if (!RegexCharClass.CharInClass(c, primarySet, ref startingAsciiLookup)) { goto Bumpalong; } for (int i = 1; i < sets.Count; i++) { (_, string nextSet, int nextDistance, bool nextCaseInsensitive) = sets[i]; c = textSpan[inputPosition + nextDistance]; if (!RegexCharClass.CharInClass(nextCaseInsensitive ? _textInfo.ToLower(c) : c, nextSet, ref _asciiLookups![i])) { goto Bumpalong; } } pos = inputPosition; return true; Bumpalong:; } } pos = end; return false; } case FindNextStartingPositionMode.FixedSets_LeftToRight_CaseInsensitive: { List<(char[]? Chars, string Set, int Distance, bool CaseInsensitive)> sets = FixedDistanceSets!; (_, string primarySet, int primaryDistance, _) = sets[0]; int endMinusRequiredLength = end - Math.Max(1, _minRequiredLength); TextInfo ti = _textInfo; ref uint[]? startingAsciiLookup = ref _asciiLookups![0]; for (int inputPosition = pos; inputPosition <= endMinusRequiredLength; inputPosition++) { char c = textSpan[inputPosition + primaryDistance]; if (!RegexCharClass.CharInClass(ti.ToLower(c), primarySet, ref startingAsciiLookup)) { goto Bumpalong; } for (int i = 1; i < sets.Count; i++) { (_, string nextSet, int nextDistance, bool nextCaseInsensitive) = sets[i]; c = textSpan[inputPosition + nextDistance]; if (!RegexCharClass.CharInClass(nextCaseInsensitive ? _textInfo.ToLower(c) : c, nextSet, ref _asciiLookups![i])) { goto Bumpalong; } } pos = inputPosition; return true; Bumpalong:; } pos = end; return false; } // There's a literal after a leading set loop. Find the literal, then walk backwards through the loop to find the starting position. case FindNextStartingPositionMode.LiteralAfterLoop_LeftToRight_CaseSensitive: { Debug.Assert(LiteralAfterLoop is not null); (RegexNode loopNode, (char Char, string? String, char[]? Chars) literal) = LiteralAfterLoop.GetValueOrDefault(); Debug.Assert(loopNode.Kind is RegexNodeKind.Setloop or RegexNodeKind.Setlazy or RegexNodeKind.Setloopatomic); Debug.Assert(loopNode.N == int.MaxValue); int startingPos = pos; while (true) { ReadOnlySpan<char> slice = textSpan.Slice(startingPos, end - startingPos); // Find the literal. If we can't find it, we're done searching. int i = literal.String is not null ? slice.IndexOf(literal.String.AsSpan()) : literal.Chars is not null ? slice.IndexOfAny(literal.Chars.AsSpan()) : slice.IndexOf(literal.Char); if (i < 0) { break; } // We found the literal. Walk backwards from it finding as many matches as we can against the loop. int prev = i; while ((uint)--prev < (uint)slice.Length && RegexCharClass.CharInClass(slice[prev], loopNode.Str!, ref _asciiLookups![0])) ; // If we found fewer than needed, loop around to try again. The loop doesn't overlap with the literal, // so we can start from after the last place the literal matched. if ((i - prev - 1) < loopNode.M) { startingPos += i + 1; continue; } // We have a winner. The starting position is just after the last position that failed to match the loop. // TODO: It'd be nice to be able to communicate literalPos as a place the matching engine can start matching // after the loop, so that it doesn't need to re-match the loop. This might only be feasible for RegexCompiler // and the source generator after we refactor them to generate a single Scan method rather than separate // FindFirstChar / Go methods. pos = startingPos + prev + 1; return true; } pos = end; return false; } // Nothing special to look for. Just return true indicating this is a valid position to try to match. default: Debug.Assert(FindMode == FindNextStartingPositionMode.NoSearch); return true; } } } /// <summary>Mode to use for searching for the next location of a possible match.</summary> internal enum FindNextStartingPositionMode { /// <summary>A "beginning" anchor at the beginning of the pattern.</summary> LeadingAnchor_LeftToRight_Beginning, /// <summary>A "start" anchor at the beginning of the pattern.</summary> LeadingAnchor_LeftToRight_Start, /// <summary>An "endz" anchor at the beginning of the pattern. This is rare.</summary> LeadingAnchor_LeftToRight_EndZ, /// <summary>An "end" anchor at the beginning of the pattern. This is rare.</summary> LeadingAnchor_LeftToRight_End, /// <summary>A "beginning" anchor at the beginning of the right-to-left pattern.</summary> LeadingAnchor_RightToLeft_Beginning, /// <summary>A "start" anchor at the beginning of the right-to-left pattern.</summary> LeadingAnchor_RightToLeft_Start, /// <summary>An "endz" anchor at the beginning of the right-to-left pattern. This is rare.</summary> LeadingAnchor_RightToLeft_EndZ, /// <summary>An "end" anchor at the beginning of the right-to-left pattern. This is rare.</summary> LeadingAnchor_RightToLeft_End, /// <summary>An "end" anchor at the end of the pattern, with the pattern always matching a fixed-length expression.</summary> TrailingAnchor_FixedLength_LeftToRight_End, /// <summary>An "endz" anchor at the end of the pattern, with the pattern always matching a fixed-length expression.</summary> TrailingAnchor_FixedLength_LeftToRight_EndZ, /// <summary>A case-sensitive multi-character substring at the beginning of the pattern.</summary> LeadingPrefix_LeftToRight_CaseSensitive, /// <summary>A case-sensitive multi-character substring at the beginning of the right-to-left pattern.</summary> LeadingPrefix_RightToLeft_CaseSensitive, /// <summary>A case-sensitive set starting the pattern.</summary> LeadingSet_LeftToRight_CaseSensitive, /// <summary>A case-insensitive set starting the pattern.</summary> LeadingSet_LeftToRight_CaseInsensitive, /// <summary>A case-sensitive set starting the right-to-left pattern.</summary> LeadingSet_RightToLeft_CaseSensitive, /// <summary>A case-insensitive set starting the right-to-left pattern.</summary> LeadingSet_RightToLeft_CaseInsensitive, /// <summary>A case-sensitive single character at a fixed distance from the start of the right-to-left pattern.</summary> LeadingLiteral_RightToLeft_CaseSensitive, /// <summary>A case-insensitive single character at a fixed distance from the start of the right-to-left pattern.</summary> LeadingLiteral_RightToLeft_CaseInsensitive, /// <summary>A case-sensitive single character at a fixed distance from the start of the pattern.</summary> FixedLiteral_LeftToRight_CaseSensitive, /// <summary>A case-insensitive single character at a fixed distance from the start of the pattern.</summary> FixedLiteral_LeftToRight_CaseInsensitive, /// <summary>One or more sets at a fixed distance from the start of the pattern. At least the first set is case-sensitive.</summary> FixedSets_LeftToRight_CaseSensitive, /// <summary>One or more sets at a fixed distance from the start of the pattern. At least the first set is case-insensitive.</summary> FixedSets_LeftToRight_CaseInsensitive, /// <summary>A literal after a non-overlapping set loop at the start of the pattern. The literal is case-sensitive.</summary> LiteralAfterLoop_LeftToRight_CaseSensitive, /// <summary>Nothing to search for. Nop.</summary> NoSearch, } }
1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexTreeAnalyzer.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Threading; namespace System.Text.RegularExpressions { /// <summary>Analyzes a <see cref="RegexTree"/> of <see cref="RegexNode"/>s to produce data on the tree structure, in particular in support of code generation.</summary> internal static class RegexTreeAnalyzer { /// <summary>Analyzes a <see cref="RegexCode"/> to learn about the structure of the tree.</summary> public static AnalysisResults Analyze(RegexCode code) { var results = new AnalysisResults(code); results._complete = TryAnalyze(code.Tree.Root, results, isAtomicBySelfOrParent: true); return results; static bool TryAnalyze(RegexNode node, AnalysisResults results, bool isAtomicBySelfOrParent) { if (!StackHelper.TryEnsureSufficientExecutionStack()) { return false; } if (isAtomicBySelfOrParent) { // We've been told by our parent that we should be considered atomic, so add ourselves // to the atomic collection. results._isAtomicByAncestor.Add(node); } else { // Certain kinds of nodes incur backtracking logic themselves: add them to the backtracking collection. // We may later find that a node contains another that has backtracking; we'll add nodes based on that // after examining the children. switch (node.Kind) { case RegexNodeKind.Alternate: case RegexNodeKind.Loop or RegexNodeKind.Lazyloop when node.M != node.N: case RegexNodeKind.Oneloop or RegexNodeKind.Notoneloop or RegexNodeKind.Setloop or RegexNodeKind.Onelazy or RegexNodeKind.Notonelazy or RegexNodeKind.Setlazy when node.M != node.N: (results._mayBacktrack ??= new()).Add(node); break; } } // Update state for certain node types. switch (node.Kind) { // Some node types add atomicity around what they wrap. Set isAtomicBySelfOrParent to true for such nodes // even if it was false upon entering the method. case RegexNodeKind.Atomic: case RegexNodeKind.NegativeLookaround: case RegexNodeKind.PositiveLookaround: isAtomicBySelfOrParent = true; break; // Track any nodes that are themselves captures. case RegexNodeKind.Capture: results._containsCapture.Add(node); break; } // Process each child. int childCount = node.ChildCount(); for (int i = 0; i < childCount; i++) { RegexNode child = node.Child(i); // Determine whether the child should be treated as atomic (whether anything // can backtrack into it), which is influenced by whether this node (the child's // parent) is considered atomic by itself or by its parent. bool treatChildAsAtomic = isAtomicBySelfOrParent && node.Kind switch { // If the parent is atomic, so is the child. That's the whole purpose // of the Atomic node, and lookarounds are also implicitly atomic. RegexNodeKind.Atomic or RegexNodeKind.NegativeLookaround or RegexNodeKind.PositiveLookaround => true, // Each branch is considered independently, so any atomicity applied to the alternation also applies // to each individual branch. This is true as well for conditionals. RegexNodeKind.Alternate or RegexNodeKind.BackreferenceConditional or RegexNodeKind.ExpressionConditional => true, // Captures don't impact atomicity: if the parent of a capture is atomic, the capture is also atomic. RegexNodeKind.Capture => true, // If the parent is a concatenation and this is the last node, any atomicity // applying to the concatenation applies to this node, too. RegexNodeKind.Concatenate => i == childCount - 1, // For loops with a max iteration count of 1, they themselves can be considered // atomic as can whatever they wrap, as they won't ever iterate more than once // and thus we don't need to worry about one iteration consuming input destined // for a subsequent iteration. RegexNodeKind.Loop or RegexNodeKind.Lazyloop when node.N == 1 => true, // For any other parent type, give up on trying to prove atomicity. _ => false, }; // Now analyze the child. if (!TryAnalyze(child, results, treatChildAsAtomic)) { return false; } // If the child contains captures, so too does this parent. if (results.MayContainCapture(child)) { results._containsCapture.Add(node); } // If the child might require backtracking into it, so too might the parent, // unless the parent is itself considered atomic. if (!isAtomicBySelfOrParent && results.MayBacktrack(child)) { (results._mayBacktrack ??= new()).Add(node); } } // Successfully analyzed the node. return true; } } } /// <summary>Provides results of a tree analysis.</summary> internal sealed class AnalysisResults { /// <summary>Indicates whether the whole tree was successfully processed.</summary> /// <remarks> /// If it wasn't successfully processed, we have to assume the "worst", e.g. if it's /// false, we need to assume we didn't fully determine which nodes contain captures, /// and thus we need to assume they all do and not discard logic necessary to support /// captures. It should be exceedingly rare that this is false. /// </remarks> internal bool _complete; /// <summary>Set of nodes that are considered to be atomic based on themselves or their ancestry.</summary> internal readonly HashSet<RegexNode> _isAtomicByAncestor = new(); // since the root is implicitly atomic, every tree will contain atomic-by-ancestor nodes /// <summary>Set of nodes that directly or indirectly contain capture groups.</summary> internal readonly HashSet<RegexNode> _containsCapture = new(); // the root is a capture, so this will always contain at least the root node /// <summary>Set of nodes that directly or indirectly contain backtracking constructs that aren't hidden internaly by atomic constructs.</summary> internal HashSet<RegexNode>? _mayBacktrack; /// <summary>Initializes the instance.</summary> /// <param name="code">The code being analyzed.</param> internal AnalysisResults(RegexCode code) => Code = code; /// <summary>Gets the code that was analyzed.</summary> public RegexCode Code { get; } /// <summary>Gets whether a node is considered atomic based on itself or its ancestry.</summary> public bool IsAtomicByAncestor(RegexNode node) => _isAtomicByAncestor.Contains(node); /// <summary>Gets whether a node directly or indirectly contains captures.</summary> public bool MayContainCapture(RegexNode node) => !_complete || _containsCapture.Contains(node); /// <summary>Gets whether a node is or directory or indirectly contains a backtracking construct that isn't hidden by an internal atomic construct.</summary> /// <remarks> /// In most code generation situations, we only need to know after we emit the child code whether /// the child may backtrack, and that we can see with 100% certainty. This method is useful in situations /// where we need to predict without traversing the child at code generation time whether it may /// incur backtracking. This method may have (few) false positives, but won't have any false negatives, /// meaning it might claim a node requires backtracking even if it doesn't, but it will always return /// true for any node that requires backtracking. /// </remarks> public bool MayBacktrack(RegexNode node) => !_complete || (_mayBacktrack?.Contains(node) ?? false); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Threading; namespace System.Text.RegularExpressions { /// <summary>Analyzes a <see cref="RegexTree"/> of <see cref="RegexNode"/>s to produce data on the tree structure, in particular in support of code generation.</summary> internal static class RegexTreeAnalyzer { /// <summary>Analyzes a <see cref="RegexCode"/> to learn about the structure of the tree.</summary> public static AnalysisResults Analyze(RegexCode code) { var results = new AnalysisResults(code); results._complete = TryAnalyze(code.Tree.Root, results, isAtomicByAncestor: true); return results; static bool TryAnalyze(RegexNode node, AnalysisResults results, bool isAtomicByAncestor) { if (!StackHelper.TryEnsureSufficientExecutionStack()) { return false; } if (isAtomicByAncestor) { // We've been told by our parent that we should be considered atomic, so add ourselves // to the atomic collection. results._isAtomicByAncestor.Add(node); } else { // Certain kinds of nodes incur backtracking logic themselves: add them to the backtracking collection. // We may later find that a node contains another that has backtracking; we'll add nodes based on that // after examining the children. switch (node.Kind) { case RegexNodeKind.Alternate: case RegexNodeKind.Loop or RegexNodeKind.Lazyloop when node.M != node.N: case RegexNodeKind.Oneloop or RegexNodeKind.Notoneloop or RegexNodeKind.Setloop or RegexNodeKind.Onelazy or RegexNodeKind.Notonelazy or RegexNodeKind.Setlazy when node.M != node.N: (results._mayBacktrack ??= new()).Add(node); break; } } // Update state for certain node types. bool isAtomicBySelf = false; switch (node.Kind) { // Some node types add atomicity around what they wrap. Set isAtomicBySelfOrParent to true for such nodes // even if it was false upon entering the method. case RegexNodeKind.Atomic: case RegexNodeKind.NegativeLookaround: case RegexNodeKind.PositiveLookaround: isAtomicBySelf = true; break; // Track any nodes that are themselves captures. case RegexNodeKind.Capture: results._containsCapture.Add(node); break; } // Process each child. int childCount = node.ChildCount(); for (int i = 0; i < childCount; i++) { RegexNode child = node.Child(i); // Determine whether the child should be treated as atomic (whether anything // can backtrack into it), which is influenced by whether this node (the child's // parent) is considered atomic by itself or by its parent. bool treatChildAsAtomic = (isAtomicByAncestor | isAtomicBySelf) && node.Kind switch { // If the parent is atomic, so is the child. That's the whole purpose // of the Atomic node, and lookarounds are also implicitly atomic. RegexNodeKind.Atomic or RegexNodeKind.NegativeLookaround or RegexNodeKind.PositiveLookaround => true, // Each branch is considered independently, so any atomicity applied to the alternation also applies // to each individual branch. This is true as well for conditionals. RegexNodeKind.Alternate or RegexNodeKind.BackreferenceConditional or RegexNodeKind.ExpressionConditional => true, // Captures don't impact atomicity: if the parent of a capture is atomic, the capture is also atomic. RegexNodeKind.Capture => true, // If the parent is a concatenation and this is the last node, any atomicity // applying to the concatenation applies to this node, too. RegexNodeKind.Concatenate => i == childCount - 1, // For loops with a max iteration count of 1, they themselves can be considered // atomic as can whatever they wrap, as they won't ever iterate more than once // and thus we don't need to worry about one iteration consuming input destined // for a subsequent iteration. RegexNodeKind.Loop or RegexNodeKind.Lazyloop when node.N == 1 => true, // For any other parent type, give up on trying to prove atomicity. _ => false, }; // Now analyze the child. if (!TryAnalyze(child, results, treatChildAsAtomic)) { return false; } // If the child contains captures, so too does this parent. if (results._containsCapture.Contains(child)) { results._containsCapture.Add(node); } // If the child might require backtracking into it, so too might the parent, // unless the parent is itself considered atomic. Here we don't consider parental // atomicity, as we need to surface upwards to the parent whether any backtracking // will be visible from this node to it. if (!isAtomicBySelf && (results._mayBacktrack?.Contains(child) == true)) { (results._mayBacktrack ??= new()).Add(node); } } // Successfully analyzed the node. return true; } } } /// <summary>Provides results of a tree analysis.</summary> internal sealed class AnalysisResults { /// <summary>Indicates whether the whole tree was successfully processed.</summary> /// <remarks> /// If it wasn't successfully processed, we have to assume the "worst", e.g. if it's /// false, we need to assume we didn't fully determine which nodes contain captures, /// and thus we need to assume they all do and not discard logic necessary to support /// captures. It should be exceedingly rare that this is false. /// </remarks> internal bool _complete; /// <summary>Set of nodes that are considered to be atomic based on themselves or their ancestry.</summary> internal readonly HashSet<RegexNode> _isAtomicByAncestor = new(); // since the root is implicitly atomic, every tree will contain atomic-by-ancestor nodes /// <summary>Set of nodes that directly or indirectly contain capture groups.</summary> internal readonly HashSet<RegexNode> _containsCapture = new(); // the root is a capture, so this will always contain at least the root node /// <summary>Set of nodes that directly or indirectly contain backtracking constructs that aren't hidden internaly by atomic constructs.</summary> internal HashSet<RegexNode>? _mayBacktrack; /// <summary>Initializes the instance.</summary> /// <param name="code">The code being analyzed.</param> internal AnalysisResults(RegexCode code) => Code = code; /// <summary>Gets the code that was analyzed.</summary> public RegexCode Code { get; } /// <summary>Gets whether a node is considered atomic based on its ancestry.</summary> public bool IsAtomicByAncestor(RegexNode node) => _isAtomicByAncestor.Contains(node); /// <summary>Gets whether a node directly or indirectly contains captures.</summary> public bool MayContainCapture(RegexNode node) => !_complete || _containsCapture.Contains(node); /// <summary>Gets whether a node is or directory or indirectly contains a backtracking construct that isn't hidden by an internal atomic construct.</summary> /// <remarks> /// In most code generation situations, we only need to know after we emit the child code whether /// the child may backtrack, and that we can see with 100% certainty. This method is useful in situations /// where we need to predict without traversing the child at code generation time whether it may /// incur backtracking. This method may have (few) false positives, but won't have any false negatives, /// meaning it might claim a node requires backtracking even if it doesn't, but it will always return /// true for any node that requires backtracking. /// </remarks> public bool MayBacktrack(RegexNode node) => !_complete || (_mayBacktrack?.Contains(node) ?? false); } }
1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/tests/Regressions/coreclr/72162/test72162.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Globalization; public class Test72162 { // Bug 72162 dealt with the number of significant digits being incorrectly done on the Mac public static int Main() { int iRetVal = 100; Double[] dblTestValues = { -1000.54, -100.999, -10.999, 10.999, 100.999, 1000.999, }; String[] strExpectedValues = { "-1001", "-101", "-11", "11", "101", "1001" }; for (int i = 0; i < dblTestValues.Length; i++) { String strOut = dblTestValues[i].ToString("G4"); if (!strOut.Equals(strExpectedValues[i])) { TestLibrary.Logging.WriteLine("Error: Formatting number '"+dblTestValues[i].ToString()+"', with G4 formatting should generate '"+strExpectedValues[i]+"' but instead generated '"+strOut+"'"); iRetVal = 0; } } return iRetVal; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Globalization; public class Test72162 { // Bug 72162 dealt with the number of significant digits being incorrectly done on the Mac public static int Main() { int iRetVal = 100; Double[] dblTestValues = { -1000.54, -100.999, -10.999, 10.999, 100.999, 1000.999, }; String[] strExpectedValues = { "-1001", "-101", "-11", "11", "101", "1001" }; for (int i = 0; i < dblTestValues.Length; i++) { String strOut = dblTestValues[i].ToString("G4"); if (!strOut.Equals(strExpectedValues[i])) { TestLibrary.Logging.WriteLine("Error: Formatting number '"+dblTestValues[i].ToString()+"', with G4 formatting should generate '"+strExpectedValues[i]+"' but instead generated '"+strOut+"'"); iRetVal = 0; } } return iRetVal; } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/libraries/System.ComponentModel.Composition/tests/System/ComponentModel/Composition/CompositionContainerTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel.Composition.Factories; using System.ComponentModel.Composition.Hosting; using System.ComponentModel.Composition.Primitives; using System.Linq; using System.Linq.Expressions; using System.UnitTesting; using Xunit; namespace System.ComponentModel.Composition { public class CompositionContainerTests { [Fact] public void Constructor2_ArrayWithNullElementAsProvidersArgument_ShouldThrowArgumentException() { Assert.Throws<ArgumentException>("providers", () => { new CompositionContainer(new ExportProvider[] { null }); }); } [Fact] public void Constructor3_ArrayWithNullElementAsProvidersArgument_ShouldThrowArgumentException() { var catalog = CatalogFactory.Create(); Assert.Throws<ArgumentException>("providers", () => { new CompositionContainer(catalog, new ExportProvider[] { null }); }); } [Fact] public void Constructor2_ArrayAsProvidersArgument_ShouldNotAllowModificationAfterConstruction() { var providers = new ExportProvider[] { ExportProviderFactory.Create() }; var container = new CompositionContainer(providers); providers[0] = null; Assert.NotNull(container.Providers[0]); } [Fact] public void Constructor3_ArrayAsProvidersArgument_ShouldNotAllowModificationAfterConstruction() { var providers = new ExportProvider[] { ExportProviderFactory.Create() }; var container = new CompositionContainer(CatalogFactory.Create(), providers); providers[0] = null; Assert.NotNull(container.Providers[0]); } [Fact] public void Constructor1_ShouldSetProvidersPropertyToEmptyCollection() { var container = new CompositionContainer(); Assert.Empty(container.Providers); } [Fact] public void Constructor2_EmptyArrayAsProvidersArgument_ShouldSetProvidersPropertyToEmpty() { var container = new CompositionContainer(new ExportProvider[0]); Assert.Empty(container.Providers); } [Fact] public void Constructor3_EmptyArrayAsProvidersArgument_ShouldSetProvidersPropertyToEmpty() { var container = new CompositionContainer(CatalogFactory.Create(), new ExportProvider[0]); Assert.Empty(container.Providers); } [Fact] public void Constructor1_ShouldSetCatalogPropertyToNull() { var container = new CompositionContainer(); Assert.Null(container.Catalog); } [Fact] public void Constructor2_ShouldSetCatalogPropertyToNull() { var container = new CompositionContainer(new ExportProvider[0]); Assert.Null(container.Catalog); } [Fact] public void Constructor3_NullAsCatalogArgument_ShouldSetCatalogPropertyToNull() { var container = new CompositionContainer((ComposablePartCatalog)null, new ExportProvider[0]); Assert.Null(container.Catalog); } [Fact] public void Constructor3_ValueAsCatalogArgument_ShouldSetCatalogProperty() { var expectations = Expectations.GetCatalogs(); foreach (var e in expectations) { var container = new CompositionContainer(e, new ExportProvider[0]); Assert.Same(e, container.Catalog); } } [Fact] public void Catalog_WhenDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { var catalog = container.Catalog; }); } [Fact] public void Providers_WhenDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { var providers = container.Providers; }); } [Fact] public void AddPart1_ImportOnlyPart_ShouldNotGetGarbageCollected() { var container = CreateCompositionContainer(); var import = PartFactory.CreateImporter("Value", ImportCardinality.ZeroOrMore); CompositionBatch batch = new CompositionBatch(); batch.AddPart(import); container.Compose(batch); var weakRef = new WeakReference(import); import = null; GC.Collect(); GC.WaitForPendingFinalizers(); Assert.NotNull(weakRef.Target); GC.KeepAlive(container); } [Fact] public void Compose_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); CompositionBatch batch = new CompositionBatch(); ExceptionAssert.ThrowsDisposed(container, () => { container.Compose(batch); }); } [Fact] public void GetExportOfT1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExport<string>(); }); } [Fact] public void GetExportOfT2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExport<string>("Contract"); }); } [Fact] public void GetExportOfTTMetadataView1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExport<string, object>(); }); } [Fact] public void GetExportOfTTMetadataView2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExport<string, object>("Contract"); }); } [Fact] public void GetExports1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); var definition = ImportDefinitionFactory.Create(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports(definition); }); } [Fact] public void GetExports2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports(typeof(string), typeof(object), "Contract"); }); } [Fact] public void GetExportsOfT1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports<string>(); }); } [Fact] public void GetExportsOfT2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports<string>("Contract"); }); } [Fact] public void GetExportsOfTTMetadataView1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports<string, object>(); }); } [Fact] public void GetExportsOfTTMetadataView2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports<string, object>("Contract"); }); } [Fact] public void GetExportedValueOfT1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValue<string>(); }); } [Fact] public void GetExportedValueOfT2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValue<string>("Contract"); }); } [Fact] public void GetExportedValueOrDefaultOfT1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValueOrDefault<string>(); }); } [Fact] public void GetExportedValueOrDefaultOfT2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValueOrDefault<string>("Contract"); }); } [Fact] public void GetExportedValuesOfT1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValues<string>(); }); } [Fact] public void GetExportedValuesOfT2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValues<string>("Contract"); }); } [Fact] public void GetExports1_NullAsImportDefinitionArgument_ShouldThrowArgumentNull() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentNullException>("definition", () => { container.GetExports((ImportDefinition)null); }); } [Fact] public void GetExports2_NullAsTypeArgument_ShouldThrowArgumentNull() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentNullException>("type", () => { container.GetExports((Type)null, typeof(string), "ContractName"); }); } [Fact] public void GetExportOfT1_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string>(); }); } [Fact] public void GetExportOfT2_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string>("Contract"); }); } [Fact] public void GetExportOfTTMetadataView1_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string, object>(); }); } [Fact] public void GetExportOfTTMetadataView2_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string, object>("Contract"); }); } [Fact] public void GetExports1_DefinitionAskingForExactlyOneContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ExactlyOne); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExports(definition); }); } [Fact] public void GetExports1_DefinitionAskingForExactlyZeroOrOneContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrOne); var exports = container.GetExports(definition); Assert.Empty(exports); } [Fact] public void GetExports1_DefinitionAskingForExactlyZeroOrMoreContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrMore); var exports = container.GetExports(definition); Assert.Empty(exports); } [Fact] public void GetExports2_AskingForContractThatDoesNotExist_ShouldReturnNoExports() { var container = CreateCompositionContainer(); var exports = container.GetExports(typeof(string), (Type)null, "Contract"); Assert.Empty(exports); } [Fact] public void GetExportsOfT1_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExports<string>(); Assert.Empty(exports); } [Fact] public void GetExportsOfT2_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExports<string>("Contract"); Assert.Empty(exports); } [Fact] public void GetExportsOfTTMetadataView1_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExports<string, object>(); Assert.Empty(exports); } [Fact] public void GetExportsOfTTMetadataView2_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExports<string, object>("Contract"); Assert.Empty(exports); } [Fact] public void GetExportedValueOfT1_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<string>(); }); } [Fact] public void GetExportedValueOfT2_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<string>("Contract"); }); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForStringContractThatDoesNotExist_ShouldReturnNull() { var container = CreateCompositionContainer(); var exportedValue = container.GetExportedValueOrDefault<string>(); Assert.Null(exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForStringContractThatDoesNotExist_ShouldReturnNull() { var container = CreateCompositionContainer(); var exportedValue = container.GetExportedValueOrDefault<string>("Contract"); Assert.Null(exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForInt32ContractThatDoesNotExist_ShouldReturnZero() { var container = CreateCompositionContainer(); var exportedValue = container.GetExportedValueOrDefault<int>(); Assert.Equal(0, exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForInt32ContractThatDoesNotExist_ShouldReturnZero() { var container = CreateCompositionContainer(); var exportedValue = container.GetExportedValueOrDefault<int>("Contract"); Assert.Equal(0, exportedValue); } [Fact] public void GetExportedValuesOfT1_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExportedValues<string>(); Assert.Empty(exports); } [Fact] public void GetExportedValuesOfT2_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExports<string>("Contract"); Assert.Empty(exports); } [Fact] public void GetExportOfT1_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport(ContractFromType(typeof(string)), "Value")); var export = container.GetExport<string>(); Assert.Equal("Value", export.Value); } [Fact] public void GetExportOfT2_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var export = container.GetExport<string>("Contract"); Assert.Equal("Value", export.Value); } [Fact] public void GetExportOfTTMetadataView1_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport(ContractFromType(typeof(string)), "Value")); var export = container.GetExport<string, object>(); Assert.Equal("Value", export.Value); } [Fact] public void GetExportOfTTMetadataView2_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var export = container.GetExport<string, object>("Contract"); Assert.Equal("Value", export.Value); } [Fact] public void GetExports1_AskingForExactlyOneContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ExactlyOne); var exports = container.GetExports(definition); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExports1_AskingForZeroOrOneContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrOne); var exports = container.GetExports(definition); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExports1_AskingForZeroOrMoreContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrMore); var exports = container.GetExports(definition); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExports2_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exports = container.GetExports(typeof(string), (Type)null, "Contract"); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExportsOfT1_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value")); var exports = container.GetExports<string>(); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExportsOfT2_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exports = container.GetExports<string>("Contract"); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExportsOfTTMetadataView1_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value")); var exports = container.GetExports<string, object>(); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExportsOfTTMetadataView2_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exports = container.GetExports<string, object>("Contract"); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExportedValueOfT1_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value")); var exportedValue = container.GetExportedValue<string>(); Assert.Equal("Value", exportedValue); } [Fact] public void GetExportedValueOfT2_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exportedValue = container.GetExportedValue<string>("Contract"); Assert.Equal("Value", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value")); var exportedValue = container.GetExportedValueOrDefault<string>(); Assert.Equal("Value", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exportedValue = container.GetExportedValueOrDefault<string>("Contract"); Assert.Equal("Value", exportedValue); } [Fact] public void GetExportedValuesOfT1_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value")); var exportedValues = container.GetExportedValues<string>(); EnumerableAssert.AreEqual(exportedValues, "Value"); } [Fact] public void GetExportedValuesOfT2_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exportedValues = container.GetExportedValues<string>("Contract"); EnumerableAssert.AreEqual(exportedValues, "Value"); } [Fact] public void GetExportOfT1_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport(ContractFromType(typeof(string)), "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string>(); }); } [Fact] public void GetExportOfT2_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string>("Contract"); }); } [Fact] public void GetExportOfTTMetadataView1_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport(ContractFromType(typeof(string)), "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string, object>(); }); } [Fact] public void GetExportOfTTMetadataView2_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string, object>("Contract"); }); } [Fact] public void GetExports1_AskingForExactlyOneContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ExactlyOne); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExports(definition); }); } [Fact] public void GetExports1_AskingForZeroOrOneContractWithMultipleExports_ShouldReturnZero() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrOne); Assert.Equal(0, container.GetExports(definition).Count()); } [Fact] public void GetExports1_AskingForZeroOrMoreContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrMore); var exports = container.GetExports(definition); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExports2_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var exports = container.GetExports(typeof(string), (Type)null, "Contract"); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExportsOfT1_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value1", "Value2")); var exports = container.GetExports<string>(); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExportsOfT2_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var exports = container.GetExports<string>("Contract"); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExportsOfTTMetadataView1_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value1", "Value2")); var exports = container.GetExports<string, object>(); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExportsOfTTMetadataView2_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var exports = container.GetExports<string, object>("Contract"); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExportedValueOfT1_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<string>(); }); } [Fact] public void GetExportedValueOfT2_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<string>("Contract"); }); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForContractWithMultipleExports_ShouldReturnZero() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value1", "Value2")); Assert.Null(container.GetExportedValueOrDefault<string>()); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForContractWithMultipleExports_ShouldReturnZero() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); Assert.Null(container.GetExportedValueOrDefault<string>("Contract")); } [Fact] public void GetExportedValuesOfT1_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value1", "Value2")); var exportedValues = container.GetExportedValues<string>(); EnumerableAssert.AreEqual(exportedValues, "Value1", "Value2"); } [Fact] public void GetExportedValuesOfT2_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), "Value1", "Value2")); var exportedValues = container.GetExportedValues<string>("Contract"); EnumerableAssert.AreEqual(exportedValues, "Value1", "Value2"); } [Fact] public void GetExports1_AskingForExactlyOneAndAll_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract1", "Value1", "Value2", "Value3"), new MicroExport("Contract2", "Value4", "Value5", "Value6")); var definition = ImportDefinitionFactory.Create(import => true, ImportCardinality.ExactlyOne); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExports(definition); }); } [Fact] public void GetExports1_AskingForZeroOrOneAndAll_ShouldReturnZero() { var container = ContainerFactory.Create(new MicroExport("Contract1", "Value1", "Value2", "Value3"), new MicroExport("Contract2", "Value4", "Value5", "Value6")); var definition = ImportDefinitionFactory.Create(import => true, ImportCardinality.ZeroOrOne); Assert.Equal(0, container.GetExports(definition).Count()); } [Fact] public void GetExports1_AskingForZeroOrMoreAndAll_ShouldReturnAll() { var container = ContainerFactory.Create(new MicroExport("Contract1", "Value1", "Value2", "Value3"), new MicroExport("Contract2", "Value4", "Value5", "Value6")); var definition = ImportDefinitionFactory.Create(import => true, ImportCardinality.ZeroOrMore); var exports = container.GetExports(definition); ExportsAssert.AreEqual(exports, "Value1", "Value2", "Value3", "Value4", "Value5", "Value6"); } [Fact] public void GetExportOfT1_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); var export = container.GetExport<string>(); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportOfT2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); var export = container.GetExport<string>("Contract"); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportOfTTMetadataView1_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); var export = container.GetExport<string, object>(); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportOfTTMetadataView2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); var export = container.GetExport<string, object>("Contract"); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExports2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); var exports = container.GetExports(typeof(string), (Type)null, "Contract"); Assert.Equal(1, exports.Count()); var export = exports.ElementAt(0); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportsOfT1_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); var exports = container.GetExports<string>(); Assert.Equal(1, exports.Count()); var export = exports.ElementAt(0); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportsOfT2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); var exports = container.GetExports<string>("Contract"); Assert.Equal(1, exports.Count()); var export = exports.ElementAt(0); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportsOfTTMetadataView1_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); var exports = container.GetExports<string, object>(); Assert.Equal(1, exports.Count()); var export = exports.ElementAt(0); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportsOfTTMetadataView2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); var exports = container.GetExports<string, object>("Contract"); Assert.Equal(1, exports.Count()); var export = exports.ElementAt(0); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportedValueOfT1_StringAsTTypeArgumentAskingForContractWithObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValue<string>(); }); } [Fact] public void GetExportedValueOfT2_StringAsTTypeArgumentAskingForContractWithObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValue<string>("Contract"); }); } [Fact] public void GetExportedValueOrDefaultOfT1_StringAsTTypeArgumentAskingForContractWithObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValueOrDefault<string>(); }); } [Fact] public void GetExportedValueOrDefaultOfT2_StringAsTTypeArgumentAskingForContractWithObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValueOrDefault<string>("Contract"); }); } [Fact] public void GetExportedValuesOfT1_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValues<string>(); }); } [Fact] public void GetExportedValuesOfT2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValues<string>("Contract"); }); } [Fact] public void GetExportOfT1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var export = child.GetExport<string>(); Assert.Equal("Parent", export.Value); } [Fact] public void GetExportOfT2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var export = child.GetExport<string>("Contract"); Assert.Equal("Parent", export.Value); } [Fact] public void GetExportOfTTMetadataView1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var export = child.GetExport<string, object>(); Assert.Equal("Parent", export.Value); } [Fact] public void GetExportOfTTMetadataView2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var export = child.GetExport<string, object>("Contract"); Assert.Equal("Parent", export.Value); } [Fact] public void GetExports1_AskingForExactlyOneContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ExactlyOne); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExports1_AskingForZeroOrOneContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrOne); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExports1_AskingForZeroOrMoreContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrMore); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExports2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exports = child.GetExports(typeof(string), (Type)null, "Contract"); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExportsOfT1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var exports = child.GetExports<string>(); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExportsOfT2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exports = child.GetExports<string>("Contract"); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExportsOfTTMetadataView1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var exports = child.GetExports<string, object>(); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExportsOfTTMetadataView2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exports = child.GetExports<string, object>("Contract"); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExportedValueOfT1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var exportedValue = child.GetExportedValue<string>(); Assert.Equal("Parent", exportedValue); } [Fact] public void GetExportedValueOfT2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exportedValue = child.GetExportedValue<string>("Contract"); Assert.Equal("Parent", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var exportedValue = child.GetExportedValueOrDefault<string>(); Assert.Equal("Parent", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exportedValue = child.GetExportedValueOrDefault<string>("Contract"); Assert.Equal("Parent", exportedValue); } [Fact] public void GetExportedValuesOfT1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var exportedValues = child.GetExportedValues<string>(); EnumerableAssert.AreEqual(exportedValues, "Parent"); } [Fact] public void GetExportedValuesOfT2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exportedValues = child.GetExportedValues<string>("Contract"); EnumerableAssert.AreEqual(exportedValues, "Parent"); } [Fact] public void GetExportOfT1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var export = child.GetExport<string>(); Assert.Equal("Child", export.Value); } [Fact] public void GetExportOfT2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var export = child.GetExport<string>("Contract"); Assert.Equal("Child", export.Value); } [Fact] public void GetExportOfTTMetadataView1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var export = child.GetExport<string, object>(); Assert.Equal("Child", export.Value); } [Fact] public void GetExportOfTTMetadataView2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var export = child.GetExport<string, object>("Contract"); Assert.Equal("Child", export.Value); } [Fact] public void GetExports1_AskingForExactlyOneContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ExactlyOne); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Child"); } [Fact] public void GetExports1_AskingForZeroOrOneContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrOne); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Child"); } [Fact] public void GetExports1_AskingForZeroOrMoreContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrMore); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExports2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exports = child.GetExports(typeof(string), (Type)null, "Contract"); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExportsOfT1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var exports = child.GetExports<string>(); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExportsOfT2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exports = child.GetExports<string>("Contract"); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExportsOfTTMetadataView1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var exports = child.GetExports<string, object>(); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExportsOfTTMetadataView2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exports = child.GetExports<string, object>("Contract"); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExportedValueOfT1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var exportedValue = child.GetExportedValue<string>(); Assert.Equal("Child", exportedValue); } [Fact] public void GetExportedValueOfT2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exportedValue = child.GetExportedValue<string>("Contract"); Assert.Equal("Child", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var exportedValue = child.GetExportedValueOrDefault<string>(); Assert.Equal("Child", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exportedValue = child.GetExportedValueOrDefault<string>("Contract"); Assert.Equal("Child", exportedValue); } [Fact] public void GetExportedValuesOfT1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var exportedValues = child.GetExportedValues<string>(); EnumerableAssert.AreEqual(exportedValues, "Child", "Parent"); } [Fact] public void GetExportedValuesOfT2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exportedValues = child.GetExportedValues<string>("Contract"); EnumerableAssert.AreEqual(exportedValues, "Child", "Parent"); } [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/32295", TestRuntimes.Mono)] public void GetExportOfTTMetadataView1_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport(typeof(string), metadata, "Value1"), new MicroExport(typeof(string), "Value2")); var export = container.GetExport<string, IMetadataView>(); var metadataExport = (Lazy<string, IMetadataView>)export; Assert.Equal("Value1", metadataExport.Value); Assert.Equal("MetadataValue1", metadataExport.Metadata.Metadata1); Assert.Equal("MetadataValue2", metadataExport.Metadata.Metadata2); Assert.Equal("MetadataValue3", metadataExport.Metadata.Metadata3); } [Fact] public void GetExportOfTTMetadataView2_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport("Contract", metadata, "Value1"), new MicroExport("Contract", "Value2")); var export = container.GetExport<string, IMetadataView>("Contract"); var metadataExport = (Lazy<string, IMetadataView>)export; Assert.Equal("Value1", metadataExport.Value); Assert.Equal("MetadataValue1", metadataExport.Metadata.Metadata1); Assert.Equal("MetadataValue2", metadataExport.Metadata.Metadata2); Assert.Equal("MetadataValue3", metadataExport.Metadata.Metadata3); } [Fact] public void GetExports1_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport("Contract", metadata, "Value1"), new MicroExport("Contract", "Value2")); var definition = ImportDefinitionFactory.Create( "Contract", new Dictionary<string, Type> { { "Metadata1", typeof(object) }, { "Metadata2", typeof(object) }, { "Metadata3", typeof(object) } } ); var exports = container.GetExports(definition); Assert.Equal(1, exports.Count()); var export = exports.First(); Assert.Equal("Value1", export.Value); EnumerableAssert.AreEqual(metadata, export.Metadata); } [Fact] public void GetExports2_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport("Contract", metadata, "Value1"), new MicroExport("Contract", "Value2")); var exports = container.GetExports(typeof(string), typeof(IMetadataView), "Contract"); Assert.Equal(1, exports.Count()); var export = exports.First(); IMetadataView exportMetadata = export.Metadata as IMetadataView; Assert.Equal("Value1", export.Value); Assert.NotNull(exportMetadata); Assert.Equal("MetadataValue1", exportMetadata.Metadata1); Assert.Equal("MetadataValue2", exportMetadata.Metadata2); Assert.Equal("MetadataValue3", exportMetadata.Metadata3); } [Fact] public void GetExportsOfTTMetadataView1_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport(typeof(string), metadata, "Value1"), new MicroExport(typeof(string), "Value2")); var exports = container.GetExports<string, IMetadataView>(); Assert.Equal(1, exports.Count()); var export = (Lazy<string, IMetadataView>)exports.First(); Assert.Equal("Value1", export.Value); Assert.Equal("MetadataValue1", export.Metadata.Metadata1); Assert.Equal("MetadataValue2", export.Metadata.Metadata2); Assert.Equal("MetadataValue3", export.Metadata.Metadata3); } [Fact] public void GetExportsOfTTMetadataView2_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport("Contract", metadata, "Value1"), new MicroExport("Contract", "Value2")); var exports = container.GetExports<string, IMetadataView>("Contract"); Assert.Equal(1, exports.Count()); var export = (Lazy<string, IMetadataView>)exports.First(); Assert.Equal("Value1", export.Value); Assert.Equal("MetadataValue1", export.Metadata.Metadata1); Assert.Equal("MetadataValue2", export.Metadata.Metadata2); Assert.Equal("MetadataValue3", export.Metadata.Metadata3); } [Fact] public void GetExports1_AskingForExactlyOneAndAllWhenContainerEmpty_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create(export => true, ImportCardinality.ExactlyOne); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExports(definition); }); } [Fact] public void GetExports1_AskingForZeroOrOneAndAllWhenContainerEmpty_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create(export => true, ImportCardinality.ZeroOrOne); var exports = container.GetExports(definition); Assert.Empty(exports); } [Fact] public void GetExports1_AskingForExactlyOneAndAllWhenContainerEmpty_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create(export => true, ImportCardinality.ZeroOrMore); var exports = container.GetExports(definition); Assert.Empty(exports); } [Fact] public void RemovePart_PartNotInContainerAsPartArgument_ShouldNotCauseImportsToBeRebound() { const string contractName = "Contract"; var exporter = PartFactory.CreateExporter(new MicroExport(contractName, 1)); var importer = PartFactory.CreateImporter(contractName); var container = ContainerFactory.Create(exporter, importer); Assert.Equal(1, importer.Value); Assert.Equal(1, importer.ImportSatisfiedCount); var doesNotExistInContainer = PartFactory.CreateExporter(new MicroExport(contractName, 2)); CompositionBatch batch = new CompositionBatch(); batch.RemovePart(doesNotExistInContainer); container.Compose(batch); Assert.Equal(1, importer.ImportSatisfiedCount); } [Fact] public void RemovePart_PartInContainerQueueAsPartArgument_ShouldNotLeavePartInContainer() { const string contractName = "Contract"; var exporter = PartFactory.CreateExporter(new MicroExport(contractName, 1)); var importer = PartFactory.CreateImporter(true, contractName); var container = ContainerFactory.Create(exporter, importer); CompositionBatch batch = new CompositionBatch(); batch.RemovePart(exporter); container.Compose(batch); Assert.Null(importer.Value); Assert.Equal(2, importer.ImportSatisfiedCount); } [Fact] public void RemovePart_PartAlreadyRemovedAsPartArgument_ShouldNotThrow() { var exporter = PartFactory.CreateExporter(new MicroExport("Contract", 1)); var container = ContainerFactory.Create(exporter); Assert.Equal(1, container.GetExportedValue<int>("Contract")); CompositionBatch batch = new CompositionBatch(); batch.RemovePart(exporter); container.Compose(batch); Assert.False(container.IsPresent("Contract")); batch = new CompositionBatch(); batch.RemovePart(exporter); container.Compose(batch); Assert.False(container.IsPresent("Contract")); } [Fact] public void TryComposeSimple() { var container = CreateCompositionContainer(); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.Equal(42, importer.Value); } [Fact] public void TryComposeSimpleFail() { var container = CreateCompositionContainer(); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer); CompositionAssert.ThrowsChangeRejectedError(ErrorId.ImportEngine_PartCannotSetImport, ErrorId.ImportEngine_ImportCardinalityMismatch, RetryMode.DoNotRetry, () => { container.Compose(batch); }); Assert.Equal(0, importer.Value); } [Fact] public void ComposeDisposableChildContainer() { var outerContainer = CreateCompositionContainer(); Int32Importer outerImporter = new Int32Importer(); CompositionBatch outerBatch = new CompositionBatch(); var key = outerBatch.AddExportedValue("Value", 42); outerBatch.AddPart(outerImporter); outerContainer.Compose(outerBatch); Assert.Equal(42, outerImporter.Value); Int32Importer innerImporter = new Int32Importer(); var innerContainer = new CompositionContainer(outerContainer); CompositionBatch innerBatch = new CompositionBatch(); innerBatch.AddPart(innerImporter); innerContainer.Compose(innerBatch); Assert.Equal(42, innerImporter.Value); Assert.Equal(42, outerImporter.Value); outerBatch = new CompositionBatch(); outerBatch.RemovePart(key); key = outerBatch.AddExportedValue("Value", -5); outerContainer.Compose(outerBatch); Assert.Equal(-5, innerImporter.Value); Assert.Equal(-5, outerImporter.Value); innerContainer.Dispose(); outerBatch = new CompositionBatch(); outerBatch.RemovePart(key); key = outerBatch.AddExportedValue("Value", 500); outerContainer.Compose(outerBatch); Assert.Equal(500, outerImporter.Value); Assert.Equal(-5, innerImporter.Value); } [Fact] public void RemoveValueTest() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); var key = batch.AddExportedValue("foo", "hello"); container.Compose(batch); var result = container.GetExportedValue<string>("foo"); Assert.Equal("hello", result); batch = new CompositionBatch(); batch.RemovePart(key); container.Compose(batch); Assert.False(container.IsPresent("foo")); batch = new CompositionBatch(); batch.RemovePart(key); // Remove should be idempotent container.Compose(batch); } [Fact] [Trait("Type", "Integration")] public void OptionalImportsOfValueTypeBoundToDefaultValueShouldNotAffectAvailableValues() { var container = CreateCompositionContainer(); var importer = new OptionalImporter(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(importer); container.Compose(batch); Assert.Equal(0, importer.ValueType); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<int>("ValueType"); }); } [Fact] [Trait("Type", "Integration")] public void OptionalImportsOfNullableValueTypeBoundToDefaultValueShouldNotAffectAvailableValues() { var container = CreateCompositionContainer(); var importer = new OptionalImporter(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(importer); container.Compose(batch); Assert.Null(importer.NullableValueType); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<int>("NullableValueType"); }); } [Fact] [Trait("Type", "Integration")] public void OptionalImportsOfReferenceTypeBoundToDefaultValueShouldNotAffectAvailableValues() { var container = CreateCompositionContainer(); var importer = new OptionalImporter(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(importer); container.Compose(batch); Assert.Null(importer.ReferenceType); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<int>("ReferenceType"); }); } [Fact] public void ExportsChanged_ExportNothing_ShouldNotFireExportsChanged() { var container = CreateCompositionContainer(); container.ExportsChanged += (sender, args) => { throw new NotImplementedException(); }; CompositionBatch batch = new CompositionBatch(); container.Compose(batch); } [Fact] public void ExportsChanged_ExportAdded_ShouldFireExportsChanged() { var container = CreateCompositionContainer(); IEnumerable<string> changedNames = null; container.ExportsChanged += (sender, args) => { Assert.Same(container, sender); Assert.Null(changedNames); Assert.NotNull(args.AddedExports); Assert.NotNull(args.RemovedExports); Assert.NotNull(args.ChangedContractNames); changedNames = args.ChangedContractNames; }; CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("MyExport", new object()); container.Compose(batch); EnumerableAssert.AreEqual(changedNames, "MyExport"); } [Fact] public void ExportsChanged_ExportRemoved_ShouldFireExportsChanged() { var container = CreateCompositionContainer(); IEnumerable<string> changedNames = null; CompositionBatch batch = new CompositionBatch(); var part = batch.AddExportedValue("MyExport", new object()); container.Compose(batch); container.ExportsChanged += (sender, args) => { Assert.Same(container, sender); Assert.Null(changedNames); Assert.NotNull(args.AddedExports); Assert.NotNull(args.RemovedExports); Assert.NotNull(args.ChangedContractNames); changedNames = args.ChangedContractNames; }; batch = new CompositionBatch(); batch.RemovePart(part); container.Compose(batch); EnumerableAssert.AreEqual(changedNames, "MyExport"); } [Fact] public void ExportsChanged_ExportAddAnother_ShouldFireExportsChanged() { var container = CreateCompositionContainer(); IEnumerable<string> changedNames = null; CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("MyExport", new object()); container.Compose(batch); container.ExportsChanged += (sender, args) => { Assert.Same(container, sender); Assert.Null(changedNames); Assert.NotNull(args.AddedExports); Assert.NotNull(args.RemovedExports); Assert.NotNull(args.ChangedContractNames); changedNames = args.ChangedContractNames; }; batch = new CompositionBatch(); // Adding another should cause an update. batch.AddExportedValue("MyExport", new object()); container.Compose(batch); EnumerableAssert.AreEqual(changedNames, "MyExport"); } [Fact] public void ExportsChanged_AddExportOnParent_ShouldFireExportsChangedOnBoth() { var parent = CreateCompositionContainer(); var child = new CompositionContainer(parent); IEnumerable<string> parentNames = null; parent.ExportsChanged += (sender, args) => { Assert.Same(parent, sender); parentNames = args.ChangedContractNames; }; IEnumerable<string> childNames = null; child.ExportsChanged += (sender, args) => { Assert.Same(child, sender); childNames = args.ChangedContractNames; }; CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("MyExport", new object()); parent.Compose(batch); EnumerableAssert.AreEqual(parentNames, "MyExport"); EnumerableAssert.AreEqual(childNames, "MyExport"); } [Fact] public void ExportsChanged_AddExportOnChild_ShouldFireExportsChangedOnChildOnly() { var parent = CreateCompositionContainer(); var child = new CompositionContainer(parent); parent.ExportsChanged += (sender, args) => { throw new NotImplementedException(); }; IEnumerable<string> childNames = null; child.ExportsChanged += (sender, args) => { Assert.Same(child, sender); childNames = args.ChangedContractNames; }; CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("MyExport2", new object()); child.Compose(batch); EnumerableAssert.AreEqual(childNames, "MyExport2"); } [Fact] public void ExportsChanged_FromAggregateCatalog_ShouldFireExportsChangedOnce() { var cat = new AggregateCatalog(); var container = new CompositionContainer(cat); IEnumerable<string> changedNames = null; container.ExportsChanged += (sender, args) => { Assert.Same(container, sender); Assert.Null(changedNames); Assert.NotNull(args.AddedExports); Assert.NotNull(args.RemovedExports); Assert.NotNull(args.ChangedContractNames); changedNames = args.ChangedContractNames; }; var typeCatalog = new TypeCatalog(typeof(SimpleExporter)); cat.Catalogs.Add(typeCatalog); Assert.NotNull(changedNames); } [Fact] public void Dispose_BeforeCompose_CanBeCallMultipleTimes() { var container = ContainerFactory.Create(PartFactory.Create(), PartFactory.Create()); container.Dispose(); container.Dispose(); container.Dispose(); } [Fact] public void Dispose_AfterCompose_CanBeCallMultipleTimes() { var container = ContainerFactory.Create(PartFactory.Create(), PartFactory.Create()); container.Dispose(); container.Dispose(); container.Dispose(); } [Fact] public void Dispose_CallsGCSuppressFinalize() { bool finalizerCalled = false; var container = ContainerFactory.CreateDisposable(disposing => { if (!disposing) { finalizerCalled = true; } }); container.Dispose(); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); Assert.False(finalizerCalled); } [Fact] public void Dispose_CallsDisposeBoolWithTrue() { var container = ContainerFactory.CreateDisposable(disposing => { Assert.True(disposing); }); container.Dispose(); } [Fact] public void Dispose_CallsDisposeBoolOnce() { int disposeCount = 0; var container = ContainerFactory.CreateDisposable(disposing => { disposeCount++; }); container.Dispose(); Assert.Equal(1, disposeCount); } [Fact] public void Dispose_ContainerAsExportedValue_CanBeDisposed() { using (var container = CreateCompositionContainer()) { CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue<ICompositionService>(container); container.Compose(batch); } } [Fact] public void Dispose_ContainerAsPart_CanBeDisposed() { // Tests that when we re-enter CompositionContainer.Dispose, that we don't // stack overflow. using (var container = CreateCompositionContainer()) { var part = PartFactory.CreateExporter(new MicroExport(typeof(ICompositionService), container)); CompositionBatch batch = new CompositionBatch(); batch.AddPart(part); container.Compose(batch); Assert.Same(container, container.GetExportedValue<ICompositionService>()); } } [Fact] public void ICompositionService_ShouldNotBeImplicitlyExported() { var container = CreateCompositionContainer(); Assert.False(container.IsPresent<ICompositionService>()); } [Fact] public void CompositionContainer_ShouldNotBeImplicitlyExported() { var container = CreateCompositionContainer(); Assert.False(container.IsPresent<CompositionContainer>()); } [Fact] public void ICompositionService_ShouldNotBeImplicitlyImported() { var importer = PartFactory.CreateImporter<ICompositionService>(); var container = ContainerFactory.Create(importer); Assert.Null(importer.Value); } [Fact] public void CompositionContainer_ShouldNotBeImplicitlyImported() { var importer = PartFactory.CreateImporter<CompositionContainer>(); var container = ContainerFactory.Create(importer); Assert.Null(importer.Value); } [Fact] public void ICompositionService_CanBeExported() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue<ICompositionService>(container); container.Compose(batch); Assert.Same(container, container.GetExportedValue<ICompositionService>()); } [Fact] public void CompositionContainer_CanBeExported() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue<CompositionContainer>(container); container.Compose(batch); Assert.Same(container, container.GetExportedValue<CompositionContainer>()); } [Fact] public void ReleaseExport_Null_ShouldThrowArgumentNull() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentNullException>("export", () => container.ReleaseExport(null)); } [Fact] public void ReleaseExports_Null_ShouldThrowArgumentNull() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentNullException>("exports", () => container.ReleaseExports(null)); } [Fact] public void ReleaseExports_ElementNull_ShouldThrowArgument() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentException>("exports", () => container.ReleaseExports(new Export[] { null })); } public class OptionalImporter { [Import("ValueType", AllowDefault = true)] public int ValueType { get; set; } [Import("NullableValueType", AllowDefault = true)] public int? NullableValueType { get; set; } [Import("ReferenceType", AllowDefault = true)] public string ReferenceType { get; set; } } public class ExportSimpleIntWithException { [Export("SimpleInt")] public int SimpleInt { get { throw new NotImplementedException(); } } } [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/24240", TestPlatforms.AnyUnix)] // Actual: typeof(System.Reflection.ReflectionTypeLoadException) public void TryGetValueWithCatalogVerifyExecptionDuringGet() { var cat = CatalogFactory.CreateDefaultAttributed(); var container = new CompositionContainer(cat); CompositionAssert.ThrowsError(ErrorId.ImportEngine_PartCannotGetExportedValue, () => { container.GetExportedValue<int>("SimpleInt"); }); } [Fact] public void TryGetExportedValueWhileLockedForNotify() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(new CallbackImportNotify(delegate { container.GetExportedValueOrDefault<int>(); })); container.Compose(batch); } [Fact] public void RawExportTests() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("foo", 1); container.Compose(batch); Lazy<int> export = container.GetExport<int>("foo"); Assert.Equal(1, export.Value); } [Export("MyExporterWithNoFoo")] public class MyExporterWithNoFoo { } [Export("MyExporterWithFoo")] [ExportMetadata("Foo", "Foo value")] public class MyExporterWithFoo { } [Export("MyExporterWithFooBar")] [ExportMetadata("Foo", "Foo value")] [ExportMetadata("Bar", "Bar value")] public class MyExporterWithFooBar { } // Silverlight doesn't support strongly typed metadata [Fact] public void ConverterExportTests() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("foo", 1); container.Compose(batch); var export = container.GetExport<int, IDictionary<string, object>>("foo"); Assert.Equal(1, export.Value); Assert.NotNull(export.Metadata); } [Fact] public void RemoveFromWrongContainerTest() { CompositionContainer d1 = CreateCompositionContainer(); CompositionContainer d2 = CreateCompositionContainer(); CompositionBatch batch1 = new CompositionBatch(); var valueKey = batch1.AddExportedValue("a", 1); d1.Compose(batch1); CompositionBatch batch2 = new CompositionBatch(); batch2.RemovePart(valueKey); // removing entry from wrong container, shoudl be a no-op d2.Compose(batch2); } [Fact] [Trait("Type", "Integration")] public void AddPartSimple() { var container = CreateCompositionContainer(); var importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(importer); batch.AddPart(new Int32Exporter(42)); container.Compose(batch); Assert.Equal(42, importer.Value); } [Fact] [Trait("Type", "Integration")] public void AddPart() { var container = CreateCompositionContainer(); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(AttributedModelServices.CreatePart(importer)); batch.AddPart(new Int32Exporter(42)); container.Compose(batch); Assert.Equal(42, importer.Value); } [Fact] public void ComposeReentrantChildContainerDisposed() { var container = CreateCompositionContainer(); Int32Importer outerImporter = new Int32Importer(); Int32Importer innerImporter = new Int32Importer(); Int32Exporter exporter = new Int32Exporter(42); CompositionBatch batch = new CompositionBatch(); batch.AddPart(exporter); container.Compose(batch); CallbackExecuteCodeDuringCompose callback = new CallbackExecuteCodeDuringCompose(() => { using (CompositionContainer innerContainer = new CompositionContainer(container)) { CompositionBatch nestedBatch = new CompositionBatch(); nestedBatch.AddPart(innerImporter); innerContainer.Compose(nestedBatch); } Assert.Equal(42, innerImporter.Value); }); batch = new CompositionBatch(); batch.AddParts(outerImporter, callback); container.Compose(batch); Assert.Equal(42, outerImporter.Value); Assert.Equal(42, innerImporter.Value); } [Fact] public void ComposeSimple() { var container = CreateCompositionContainer(); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.Equal(42, importer.Value); } [Fact] public void ComposeSimpleFail() { var container = CreateCompositionContainer(); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(importer); CompositionAssert.ThrowsChangeRejectedError(ErrorId.ImportEngine_PartCannotSetImport, // Cannot set Int32Importer.Value because ErrorId.ImportEngine_ImportCardinalityMismatch, // No exports are present that match contract RetryMode.DoNotRetry, () => { container.Compose(batch); }); } [Fact] public void ExceptionDuringNotify() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(new CallbackImportNotify(delegate { throw new InvalidOperationException(); })); CompositionAssert.ThrowsError(ErrorId.ImportEngine_PartCannotActivate, // Cannot activate CallbackImportNotify because RetryMode.DoNotRetry, () => { container.Compose(batch); }); } [Fact] public void NeutralComposeWhileNotified() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(new CallbackImportNotify(delegate { // Is this really a supported scenario? container.Compose(batch); })); container.Compose(batch); } public class PartWithReentrantCompose : ComposablePart { private CompositionContainer _container; public PartWithReentrantCompose(CompositionContainer container) { this._container = container; } public override IEnumerable<ExportDefinition> ExportDefinitions { get { this._container.ComposeExportedValue<string>("ExportedString"); return Enumerable.Empty<ExportDefinition>(); } } public override IEnumerable<ImportDefinition> ImportDefinitions { get { return Enumerable.Empty<ImportDefinition>(); } } public override object GetExportedValue(ExportDefinition definition) { throw new NotImplementedException(); } public override void SetImport(ImportDefinition definition, IEnumerable<Export> exports) { throw new NotImplementedException(); } } [Export] public class SimpleExporter { } [Fact] public void ThreadSafeCompositionContainer() { TypeCatalog catalog = new TypeCatalog(typeof(SimpleExporter)); CompositionContainer container = new CompositionContainer(catalog, true); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.NotNull(container.GetExportedValue<SimpleExporter>()); Assert.Equal(42, importer.Value); container.Dispose(); } [Fact] public void ThreadSafeCompositionOptionsCompositionContainer() { TypeCatalog catalog = new TypeCatalog(typeof(SimpleExporter)); CompositionContainer container = new CompositionContainer(catalog, CompositionOptions.IsThreadSafe); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.NotNull(container.GetExportedValue<SimpleExporter>()); Assert.Equal(42, importer.Value); container.Dispose(); } [Fact] public void DisableSilentRejectionCompositionOptionsCompositionContainer() { TypeCatalog catalog = new TypeCatalog(typeof(SimpleExporter)); CompositionContainer container = new CompositionContainer(catalog, CompositionOptions.DisableSilentRejection); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.NotNull(container.GetExportedValue<SimpleExporter>()); Assert.Equal(42, importer.Value); container.Dispose(); } [Fact] public void DisableSilentRejectionThreadSafeCompositionOptionsCompositionContainer() { TypeCatalog catalog = new TypeCatalog(typeof(SimpleExporter)); CompositionContainer container = new CompositionContainer(catalog, CompositionOptions.DisableSilentRejection | CompositionOptions.IsThreadSafe); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.NotNull(container.GetExportedValue<SimpleExporter>()); Assert.Equal(42, importer.Value); container.Dispose(); } [Fact] public void CompositionOptionsInvalidValue() { Assert.Throws<ArgumentOutOfRangeException>("compositionOptions", () => new CompositionContainer((CompositionOptions)0x0400)); } [Fact] public void ReentrantencyDisabledWhileComposing() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(new PartWithReentrantCompose(container)); ExceptionAssert.Throws<InvalidOperationException>(() => container.Compose(batch)); } private static Expression<Func<ExportDefinition, bool>> ConstraintFromContract(string contractName) { return ConstraintFactory.Create(contractName); } private static string ContractFromType(Type type) { return AttributedModelServices.GetContractName(type); } private static CompositionContainer CreateCompositionContainer() { return new CompositionContainer(); } public interface IMetadataView { string Metadata1 { get; } string Metadata2 { get; } string Metadata3 { get; } } [Fact] public void ComposeExportedValueOfT_NullStringAsExportedValueArgument_VerifyCanPullOnValue() { var container = CreateCompositionContainer(); var expectation = (string)null; container.ComposeExportedValue<string>(expectation); var actualValue = container.GetExportedValue<string>(); Assert.Equal(expectation, actualValue); } [Fact] public void ComposeExportedValueOfT_StringAsExportedValueArgument_VerifyCanPullOnValue() { var expectations = new List<string>(); expectations.Add((string)null); expectations.Add(string.Empty); expectations.Add("Value"); foreach (var expectation in expectations) { var container = CreateCompositionContainer(); container.ComposeExportedValue<string>(expectation); var actualValue = container.GetExportedValue<string>(); Assert.Equal(expectation, actualValue); } } [Fact] public void ComposeExportedValueOfT_StringAsIEnumerableOfCharAsExportedValueArgument_VerifyCanPullOnValue() { var expectations = new List<string>(); expectations.Add((string)null); expectations.Add(string.Empty); expectations.Add("Value"); foreach (var expectation in expectations) { var container = CreateCompositionContainer(); container.ComposeExportedValue<IEnumerable<char>>(expectation); var actualValue = container.GetExportedValue<IEnumerable<char>>(); Assert.Equal(expectation, actualValue); } } [Fact] public void ComposeExportedValueOfT_ObjectAsExportedValueArgument_VerifyCanPullOnValue() { var expectations = new List<object>(); expectations.Add((string)null); expectations.Add(string.Empty); expectations.Add("Value"); expectations.Add(42); expectations.Add(new object()); foreach (var expectation in expectations) { var container = CreateCompositionContainer(); container.ComposeExportedValue<object>(expectation); var actualValue = container.GetExportedValue<object>(); Assert.Equal(expectation, actualValue); } } [Fact] public void ComposeExportedValueOfT_ExportedValue_ExportedUnderDefaultContractName() { string expectedContractName = AttributedModelServices.GetContractName(typeof(string)); var container = CreateCompositionContainer(); container.ComposeExportedValue<string>("Value"); var importDefinition = new ImportDefinition(ed => true, null, ImportCardinality.ZeroOrMore, false, false); var exports = container.GetExports(importDefinition); Assert.Equal(1, exports.Count()); Assert.Equal(expectedContractName, exports.Single().Definition.ContractName); } [Fact] public void ComposeExportedValueOfT_ExportedValue_ExportContainsEmptyMetadata() { var container = CreateCompositionContainer(); container.ComposeExportedValue<string>("Value"); var importDefinition = new ImportDefinition(ed => true, null, ImportCardinality.ZeroOrMore, false, false); var exports = container.GetExports(importDefinition); Assert.Equal(1, exports.Count()); Assert.Equal(1, exports.Single().Metadata.Count); // contains type identity } [Fact] public void ComposeExportedValueOfT_ExportedValue_LazyContainsEmptyMetadata() { var container = CreateCompositionContainer(); container.ComposeExportedValue<string>("Value"); var lazy = container.GetExport<string, IDictionary<string, object>>(); Assert.Equal(1, lazy.Metadata.Count); // contains type identity } [Fact] public void ComposeExportedValueOfT_ExportedValue_ImportsAreNotDiscovered() { var container = CreateCompositionContainer(); var importer = new PartWithRequiredImport(); container.ComposeExportedValue<object>(importer); var importDefinition = new ImportDefinition(ed => true, null, ImportCardinality.ZeroOrMore, false, false); var exports = container.GetExports(importDefinition); Assert.Equal(1, exports.Count()); // we only get one if the import was not discovered since the import is not satisfied } [Fact] public void ComposeExportedValueOfT_NullAsContractName_ThrowsArgumentNullException() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentNullException>("contractName", () => container.ComposeExportedValue<string>((string)null, "Value")); } [Fact] public void ComposeExportedValueOfT_EmptyStringAsContractName_ThrowsArgumentException() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentException>("contractName", () => container.ComposeExportedValue<string>(string.Empty, "Value")); } [Fact] public void ComposeExportedValueOfT_ValidContractName_ValidExportedValue_VerifyCanPullOnValue() { var expectations = new List<Tuple<string, string>>(); expectations.Add(new Tuple<string, string>(" ", (string)null)); expectations.Add(new Tuple<string, string>(" ", string.Empty)); expectations.Add(new Tuple<string, string>(" ", "Value")); expectations.Add(new Tuple<string, string>("ContractName", (string)null)); expectations.Add(new Tuple<string, string>("ContractName", string.Empty)); expectations.Add(new Tuple<string, string>("ContractName", "Value")); foreach (var expectation in expectations) { var container = CreateCompositionContainer(); container.ComposeExportedValue<string>(expectation.Item1, expectation.Item2); var actualValue = container.GetExportedValue<string>(expectation.Item1); Assert.Equal(expectation.Item2, actualValue); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => container.GetExportedValue<string>()); } } [Fact] public void ComposeExportedValueOfT_ValidContractName_ExportedValue_ExportedUnderSpecifiedContractName() { string expectedContractName = "ContractName"; var container = CreateCompositionContainer(); container.ComposeExportedValue<string>(expectedContractName, "Value"); var importDefinition = new ImportDefinition(ed => true, null, ImportCardinality.ZeroOrMore, false, false); var exports = container.GetExports(importDefinition); Assert.Equal(1, exports.Count()); Assert.Equal(expectedContractName, exports.Single().Definition.ContractName); } [Fact] public void ComposeExportedValueOfT_ValidContractName_ExportedValue_ImportsAreNotDiscovered() { var container = CreateCompositionContainer(); var importer = new PartWithRequiredImport(); container.ComposeExportedValue<object>("ContractName", importer); var importDefinition = new ImportDefinition(ed => true, null, ImportCardinality.ZeroOrMore, false, false); var exports = container.GetExports(importDefinition); Assert.Equal(1, exports.Count()); // we only get one if the import was not discovered since the import is not satisfied } [Fact] public void TestExportedValueCachesNullValue() { var container = ContainerFactory.Create(); var exporter = new ExportsMutableProperty(); exporter.Property = null; container.ComposeParts(exporter); Assert.Null(container.GetExportedValue<string>("Property")); exporter.Property = "Value1"; // Exported value should have been cached and so it shouldn't change Assert.Null(container.GetExportedValue<string>("Property")); } [Fact] public void TestExportedValueUsingWhereClause_ExportSuccessful() { CompositionContainer container = new CompositionContainer(new TypeCatalog(typeof(MefCollection<,>))); IMefCollection<DerivedClass, BaseClass> actualValue = container.GetExportedValue<IMefCollection<DerivedClass, BaseClass>>("UsingWhereClause"); Assert.NotNull(actualValue); Assert.IsType<MefCollection<DerivedClass, BaseClass>>(actualValue); } public interface IMefCollection { } public interface IMefCollection<TC, TP> : IList<TC>, IMefCollection where TC : TP { } public class BaseClass { } public class DerivedClass : BaseClass { } [Export("UsingWhereClause", typeof(IMefCollection<,>))] public class MefCollection<TC, TP> : ObservableCollection<TC>, IMefCollection<TC, TP> where TC : TP { } public class ExportsMutableProperty { [Export("Property")] public string Property { get; set; } } public class PartWithRequiredImport { [Import] public object Import { get; set; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel.Composition.Factories; using System.ComponentModel.Composition.Hosting; using System.ComponentModel.Composition.Primitives; using System.Linq; using System.Linq.Expressions; using System.UnitTesting; using Xunit; namespace System.ComponentModel.Composition { public class CompositionContainerTests { [Fact] public void Constructor2_ArrayWithNullElementAsProvidersArgument_ShouldThrowArgumentException() { Assert.Throws<ArgumentException>("providers", () => { new CompositionContainer(new ExportProvider[] { null }); }); } [Fact] public void Constructor3_ArrayWithNullElementAsProvidersArgument_ShouldThrowArgumentException() { var catalog = CatalogFactory.Create(); Assert.Throws<ArgumentException>("providers", () => { new CompositionContainer(catalog, new ExportProvider[] { null }); }); } [Fact] public void Constructor2_ArrayAsProvidersArgument_ShouldNotAllowModificationAfterConstruction() { var providers = new ExportProvider[] { ExportProviderFactory.Create() }; var container = new CompositionContainer(providers); providers[0] = null; Assert.NotNull(container.Providers[0]); } [Fact] public void Constructor3_ArrayAsProvidersArgument_ShouldNotAllowModificationAfterConstruction() { var providers = new ExportProvider[] { ExportProviderFactory.Create() }; var container = new CompositionContainer(CatalogFactory.Create(), providers); providers[0] = null; Assert.NotNull(container.Providers[0]); } [Fact] public void Constructor1_ShouldSetProvidersPropertyToEmptyCollection() { var container = new CompositionContainer(); Assert.Empty(container.Providers); } [Fact] public void Constructor2_EmptyArrayAsProvidersArgument_ShouldSetProvidersPropertyToEmpty() { var container = new CompositionContainer(new ExportProvider[0]); Assert.Empty(container.Providers); } [Fact] public void Constructor3_EmptyArrayAsProvidersArgument_ShouldSetProvidersPropertyToEmpty() { var container = new CompositionContainer(CatalogFactory.Create(), new ExportProvider[0]); Assert.Empty(container.Providers); } [Fact] public void Constructor1_ShouldSetCatalogPropertyToNull() { var container = new CompositionContainer(); Assert.Null(container.Catalog); } [Fact] public void Constructor2_ShouldSetCatalogPropertyToNull() { var container = new CompositionContainer(new ExportProvider[0]); Assert.Null(container.Catalog); } [Fact] public void Constructor3_NullAsCatalogArgument_ShouldSetCatalogPropertyToNull() { var container = new CompositionContainer((ComposablePartCatalog)null, new ExportProvider[0]); Assert.Null(container.Catalog); } [Fact] public void Constructor3_ValueAsCatalogArgument_ShouldSetCatalogProperty() { var expectations = Expectations.GetCatalogs(); foreach (var e in expectations) { var container = new CompositionContainer(e, new ExportProvider[0]); Assert.Same(e, container.Catalog); } } [Fact] public void Catalog_WhenDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { var catalog = container.Catalog; }); } [Fact] public void Providers_WhenDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { var providers = container.Providers; }); } [Fact] public void AddPart1_ImportOnlyPart_ShouldNotGetGarbageCollected() { var container = CreateCompositionContainer(); var import = PartFactory.CreateImporter("Value", ImportCardinality.ZeroOrMore); CompositionBatch batch = new CompositionBatch(); batch.AddPart(import); container.Compose(batch); var weakRef = new WeakReference(import); import = null; GC.Collect(); GC.WaitForPendingFinalizers(); Assert.NotNull(weakRef.Target); GC.KeepAlive(container); } [Fact] public void Compose_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); CompositionBatch batch = new CompositionBatch(); ExceptionAssert.ThrowsDisposed(container, () => { container.Compose(batch); }); } [Fact] public void GetExportOfT1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExport<string>(); }); } [Fact] public void GetExportOfT2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExport<string>("Contract"); }); } [Fact] public void GetExportOfTTMetadataView1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExport<string, object>(); }); } [Fact] public void GetExportOfTTMetadataView2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExport<string, object>("Contract"); }); } [Fact] public void GetExports1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); var definition = ImportDefinitionFactory.Create(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports(definition); }); } [Fact] public void GetExports2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports(typeof(string), typeof(object), "Contract"); }); } [Fact] public void GetExportsOfT1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports<string>(); }); } [Fact] public void GetExportsOfT2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports<string>("Contract"); }); } [Fact] public void GetExportsOfTTMetadataView1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports<string, object>(); }); } [Fact] public void GetExportsOfTTMetadataView2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports<string, object>("Contract"); }); } [Fact] public void GetExportedValueOfT1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValue<string>(); }); } [Fact] public void GetExportedValueOfT2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValue<string>("Contract"); }); } [Fact] public void GetExportedValueOrDefaultOfT1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValueOrDefault<string>(); }); } [Fact] public void GetExportedValueOrDefaultOfT2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValueOrDefault<string>("Contract"); }); } [Fact] public void GetExportedValuesOfT1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValues<string>(); }); } [Fact] public void GetExportedValuesOfT2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValues<string>("Contract"); }); } [Fact] public void GetExports1_NullAsImportDefinitionArgument_ShouldThrowArgumentNull() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentNullException>("definition", () => { container.GetExports((ImportDefinition)null); }); } [Fact] public void GetExports2_NullAsTypeArgument_ShouldThrowArgumentNull() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentNullException>("type", () => { container.GetExports((Type)null, typeof(string), "ContractName"); }); } [Fact] public void GetExportOfT1_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string>(); }); } [Fact] public void GetExportOfT2_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string>("Contract"); }); } [Fact] public void GetExportOfTTMetadataView1_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string, object>(); }); } [Fact] public void GetExportOfTTMetadataView2_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string, object>("Contract"); }); } [Fact] public void GetExports1_DefinitionAskingForExactlyOneContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ExactlyOne); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExports(definition); }); } [Fact] public void GetExports1_DefinitionAskingForExactlyZeroOrOneContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrOne); var exports = container.GetExports(definition); Assert.Empty(exports); } [Fact] public void GetExports1_DefinitionAskingForExactlyZeroOrMoreContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrMore); var exports = container.GetExports(definition); Assert.Empty(exports); } [Fact] public void GetExports2_AskingForContractThatDoesNotExist_ShouldReturnNoExports() { var container = CreateCompositionContainer(); var exports = container.GetExports(typeof(string), (Type)null, "Contract"); Assert.Empty(exports); } [Fact] public void GetExportsOfT1_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExports<string>(); Assert.Empty(exports); } [Fact] public void GetExportsOfT2_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExports<string>("Contract"); Assert.Empty(exports); } [Fact] public void GetExportsOfTTMetadataView1_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExports<string, object>(); Assert.Empty(exports); } [Fact] public void GetExportsOfTTMetadataView2_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExports<string, object>("Contract"); Assert.Empty(exports); } [Fact] public void GetExportedValueOfT1_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<string>(); }); } [Fact] public void GetExportedValueOfT2_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<string>("Contract"); }); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForStringContractThatDoesNotExist_ShouldReturnNull() { var container = CreateCompositionContainer(); var exportedValue = container.GetExportedValueOrDefault<string>(); Assert.Null(exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForStringContractThatDoesNotExist_ShouldReturnNull() { var container = CreateCompositionContainer(); var exportedValue = container.GetExportedValueOrDefault<string>("Contract"); Assert.Null(exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForInt32ContractThatDoesNotExist_ShouldReturnZero() { var container = CreateCompositionContainer(); var exportedValue = container.GetExportedValueOrDefault<int>(); Assert.Equal(0, exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForInt32ContractThatDoesNotExist_ShouldReturnZero() { var container = CreateCompositionContainer(); var exportedValue = container.GetExportedValueOrDefault<int>("Contract"); Assert.Equal(0, exportedValue); } [Fact] public void GetExportedValuesOfT1_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExportedValues<string>(); Assert.Empty(exports); } [Fact] public void GetExportedValuesOfT2_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExports<string>("Contract"); Assert.Empty(exports); } [Fact] public void GetExportOfT1_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport(ContractFromType(typeof(string)), "Value")); var export = container.GetExport<string>(); Assert.Equal("Value", export.Value); } [Fact] public void GetExportOfT2_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var export = container.GetExport<string>("Contract"); Assert.Equal("Value", export.Value); } [Fact] public void GetExportOfTTMetadataView1_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport(ContractFromType(typeof(string)), "Value")); var export = container.GetExport<string, object>(); Assert.Equal("Value", export.Value); } [Fact] public void GetExportOfTTMetadataView2_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var export = container.GetExport<string, object>("Contract"); Assert.Equal("Value", export.Value); } [Fact] public void GetExports1_AskingForExactlyOneContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ExactlyOne); var exports = container.GetExports(definition); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExports1_AskingForZeroOrOneContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrOne); var exports = container.GetExports(definition); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExports1_AskingForZeroOrMoreContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrMore); var exports = container.GetExports(definition); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExports2_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exports = container.GetExports(typeof(string), (Type)null, "Contract"); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExportsOfT1_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value")); var exports = container.GetExports<string>(); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExportsOfT2_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exports = container.GetExports<string>("Contract"); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExportsOfTTMetadataView1_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value")); var exports = container.GetExports<string, object>(); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExportsOfTTMetadataView2_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exports = container.GetExports<string, object>("Contract"); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExportedValueOfT1_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value")); var exportedValue = container.GetExportedValue<string>(); Assert.Equal("Value", exportedValue); } [Fact] public void GetExportedValueOfT2_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exportedValue = container.GetExportedValue<string>("Contract"); Assert.Equal("Value", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value")); var exportedValue = container.GetExportedValueOrDefault<string>(); Assert.Equal("Value", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exportedValue = container.GetExportedValueOrDefault<string>("Contract"); Assert.Equal("Value", exportedValue); } [Fact] public void GetExportedValuesOfT1_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value")); var exportedValues = container.GetExportedValues<string>(); EnumerableAssert.AreEqual(exportedValues, "Value"); } [Fact] public void GetExportedValuesOfT2_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exportedValues = container.GetExportedValues<string>("Contract"); EnumerableAssert.AreEqual(exportedValues, "Value"); } [Fact] public void GetExportOfT1_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport(ContractFromType(typeof(string)), "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string>(); }); } [Fact] public void GetExportOfT2_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string>("Contract"); }); } [Fact] public void GetExportOfTTMetadataView1_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport(ContractFromType(typeof(string)), "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string, object>(); }); } [Fact] public void GetExportOfTTMetadataView2_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string, object>("Contract"); }); } [Fact] public void GetExports1_AskingForExactlyOneContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ExactlyOne); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExports(definition); }); } [Fact] public void GetExports1_AskingForZeroOrOneContractWithMultipleExports_ShouldReturnZero() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrOne); Assert.Equal(0, container.GetExports(definition).Count()); } [Fact] public void GetExports1_AskingForZeroOrMoreContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrMore); var exports = container.GetExports(definition); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExports2_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var exports = container.GetExports(typeof(string), (Type)null, "Contract"); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExportsOfT1_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value1", "Value2")); var exports = container.GetExports<string>(); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExportsOfT2_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var exports = container.GetExports<string>("Contract"); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExportsOfTTMetadataView1_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value1", "Value2")); var exports = container.GetExports<string, object>(); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExportsOfTTMetadataView2_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var exports = container.GetExports<string, object>("Contract"); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExportedValueOfT1_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<string>(); }); } [Fact] public void GetExportedValueOfT2_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<string>("Contract"); }); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForContractWithMultipleExports_ShouldReturnZero() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value1", "Value2")); Assert.Null(container.GetExportedValueOrDefault<string>()); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForContractWithMultipleExports_ShouldReturnZero() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); Assert.Null(container.GetExportedValueOrDefault<string>("Contract")); } [Fact] public void GetExportedValuesOfT1_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value1", "Value2")); var exportedValues = container.GetExportedValues<string>(); EnumerableAssert.AreEqual(exportedValues, "Value1", "Value2"); } [Fact] public void GetExportedValuesOfT2_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), "Value1", "Value2")); var exportedValues = container.GetExportedValues<string>("Contract"); EnumerableAssert.AreEqual(exportedValues, "Value1", "Value2"); } [Fact] public void GetExports1_AskingForExactlyOneAndAll_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract1", "Value1", "Value2", "Value3"), new MicroExport("Contract2", "Value4", "Value5", "Value6")); var definition = ImportDefinitionFactory.Create(import => true, ImportCardinality.ExactlyOne); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExports(definition); }); } [Fact] public void GetExports1_AskingForZeroOrOneAndAll_ShouldReturnZero() { var container = ContainerFactory.Create(new MicroExport("Contract1", "Value1", "Value2", "Value3"), new MicroExport("Contract2", "Value4", "Value5", "Value6")); var definition = ImportDefinitionFactory.Create(import => true, ImportCardinality.ZeroOrOne); Assert.Equal(0, container.GetExports(definition).Count()); } [Fact] public void GetExports1_AskingForZeroOrMoreAndAll_ShouldReturnAll() { var container = ContainerFactory.Create(new MicroExport("Contract1", "Value1", "Value2", "Value3"), new MicroExport("Contract2", "Value4", "Value5", "Value6")); var definition = ImportDefinitionFactory.Create(import => true, ImportCardinality.ZeroOrMore); var exports = container.GetExports(definition); ExportsAssert.AreEqual(exports, "Value1", "Value2", "Value3", "Value4", "Value5", "Value6"); } [Fact] public void GetExportOfT1_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); var export = container.GetExport<string>(); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportOfT2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); var export = container.GetExport<string>("Contract"); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportOfTTMetadataView1_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); var export = container.GetExport<string, object>(); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportOfTTMetadataView2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); var export = container.GetExport<string, object>("Contract"); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExports2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); var exports = container.GetExports(typeof(string), (Type)null, "Contract"); Assert.Equal(1, exports.Count()); var export = exports.ElementAt(0); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportsOfT1_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); var exports = container.GetExports<string>(); Assert.Equal(1, exports.Count()); var export = exports.ElementAt(0); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportsOfT2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); var exports = container.GetExports<string>("Contract"); Assert.Equal(1, exports.Count()); var export = exports.ElementAt(0); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportsOfTTMetadataView1_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); var exports = container.GetExports<string, object>(); Assert.Equal(1, exports.Count()); var export = exports.ElementAt(0); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportsOfTTMetadataView2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); var exports = container.GetExports<string, object>("Contract"); Assert.Equal(1, exports.Count()); var export = exports.ElementAt(0); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportedValueOfT1_StringAsTTypeArgumentAskingForContractWithObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValue<string>(); }); } [Fact] public void GetExportedValueOfT2_StringAsTTypeArgumentAskingForContractWithObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValue<string>("Contract"); }); } [Fact] public void GetExportedValueOrDefaultOfT1_StringAsTTypeArgumentAskingForContractWithObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValueOrDefault<string>(); }); } [Fact] public void GetExportedValueOrDefaultOfT2_StringAsTTypeArgumentAskingForContractWithObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValueOrDefault<string>("Contract"); }); } [Fact] public void GetExportedValuesOfT1_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValues<string>(); }); } [Fact] public void GetExportedValuesOfT2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValues<string>("Contract"); }); } [Fact] public void GetExportOfT1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var export = child.GetExport<string>(); Assert.Equal("Parent", export.Value); } [Fact] public void GetExportOfT2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var export = child.GetExport<string>("Contract"); Assert.Equal("Parent", export.Value); } [Fact] public void GetExportOfTTMetadataView1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var export = child.GetExport<string, object>(); Assert.Equal("Parent", export.Value); } [Fact] public void GetExportOfTTMetadataView2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var export = child.GetExport<string, object>("Contract"); Assert.Equal("Parent", export.Value); } [Fact] public void GetExports1_AskingForExactlyOneContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ExactlyOne); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExports1_AskingForZeroOrOneContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrOne); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExports1_AskingForZeroOrMoreContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrMore); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExports2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exports = child.GetExports(typeof(string), (Type)null, "Contract"); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExportsOfT1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var exports = child.GetExports<string>(); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExportsOfT2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exports = child.GetExports<string>("Contract"); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExportsOfTTMetadataView1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var exports = child.GetExports<string, object>(); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExportsOfTTMetadataView2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exports = child.GetExports<string, object>("Contract"); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExportedValueOfT1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var exportedValue = child.GetExportedValue<string>(); Assert.Equal("Parent", exportedValue); } [Fact] public void GetExportedValueOfT2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exportedValue = child.GetExportedValue<string>("Contract"); Assert.Equal("Parent", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var exportedValue = child.GetExportedValueOrDefault<string>(); Assert.Equal("Parent", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exportedValue = child.GetExportedValueOrDefault<string>("Contract"); Assert.Equal("Parent", exportedValue); } [Fact] public void GetExportedValuesOfT1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var exportedValues = child.GetExportedValues<string>(); EnumerableAssert.AreEqual(exportedValues, "Parent"); } [Fact] public void GetExportedValuesOfT2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exportedValues = child.GetExportedValues<string>("Contract"); EnumerableAssert.AreEqual(exportedValues, "Parent"); } [Fact] public void GetExportOfT1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var export = child.GetExport<string>(); Assert.Equal("Child", export.Value); } [Fact] public void GetExportOfT2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var export = child.GetExport<string>("Contract"); Assert.Equal("Child", export.Value); } [Fact] public void GetExportOfTTMetadataView1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var export = child.GetExport<string, object>(); Assert.Equal("Child", export.Value); } [Fact] public void GetExportOfTTMetadataView2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var export = child.GetExport<string, object>("Contract"); Assert.Equal("Child", export.Value); } [Fact] public void GetExports1_AskingForExactlyOneContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ExactlyOne); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Child"); } [Fact] public void GetExports1_AskingForZeroOrOneContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrOne); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Child"); } [Fact] public void GetExports1_AskingForZeroOrMoreContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrMore); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExports2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exports = child.GetExports(typeof(string), (Type)null, "Contract"); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExportsOfT1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var exports = child.GetExports<string>(); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExportsOfT2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exports = child.GetExports<string>("Contract"); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExportsOfTTMetadataView1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var exports = child.GetExports<string, object>(); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExportsOfTTMetadataView2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exports = child.GetExports<string, object>("Contract"); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExportedValueOfT1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var exportedValue = child.GetExportedValue<string>(); Assert.Equal("Child", exportedValue); } [Fact] public void GetExportedValueOfT2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exportedValue = child.GetExportedValue<string>("Contract"); Assert.Equal("Child", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var exportedValue = child.GetExportedValueOrDefault<string>(); Assert.Equal("Child", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exportedValue = child.GetExportedValueOrDefault<string>("Contract"); Assert.Equal("Child", exportedValue); } [Fact] public void GetExportedValuesOfT1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var exportedValues = child.GetExportedValues<string>(); EnumerableAssert.AreEqual(exportedValues, "Child", "Parent"); } [Fact] public void GetExportedValuesOfT2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exportedValues = child.GetExportedValues<string>("Contract"); EnumerableAssert.AreEqual(exportedValues, "Child", "Parent"); } [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/32295", TestRuntimes.Mono)] public void GetExportOfTTMetadataView1_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport(typeof(string), metadata, "Value1"), new MicroExport(typeof(string), "Value2")); var export = container.GetExport<string, IMetadataView>(); var metadataExport = (Lazy<string, IMetadataView>)export; Assert.Equal("Value1", metadataExport.Value); Assert.Equal("MetadataValue1", metadataExport.Metadata.Metadata1); Assert.Equal("MetadataValue2", metadataExport.Metadata.Metadata2); Assert.Equal("MetadataValue3", metadataExport.Metadata.Metadata3); } [Fact] public void GetExportOfTTMetadataView2_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport("Contract", metadata, "Value1"), new MicroExport("Contract", "Value2")); var export = container.GetExport<string, IMetadataView>("Contract"); var metadataExport = (Lazy<string, IMetadataView>)export; Assert.Equal("Value1", metadataExport.Value); Assert.Equal("MetadataValue1", metadataExport.Metadata.Metadata1); Assert.Equal("MetadataValue2", metadataExport.Metadata.Metadata2); Assert.Equal("MetadataValue3", metadataExport.Metadata.Metadata3); } [Fact] public void GetExports1_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport("Contract", metadata, "Value1"), new MicroExport("Contract", "Value2")); var definition = ImportDefinitionFactory.Create( "Contract", new Dictionary<string, Type> { { "Metadata1", typeof(object) }, { "Metadata2", typeof(object) }, { "Metadata3", typeof(object) } } ); var exports = container.GetExports(definition); Assert.Equal(1, exports.Count()); var export = exports.First(); Assert.Equal("Value1", export.Value); EnumerableAssert.AreEqual(metadata, export.Metadata); } [Fact] public void GetExports2_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport("Contract", metadata, "Value1"), new MicroExport("Contract", "Value2")); var exports = container.GetExports(typeof(string), typeof(IMetadataView), "Contract"); Assert.Equal(1, exports.Count()); var export = exports.First(); IMetadataView exportMetadata = export.Metadata as IMetadataView; Assert.Equal("Value1", export.Value); Assert.NotNull(exportMetadata); Assert.Equal("MetadataValue1", exportMetadata.Metadata1); Assert.Equal("MetadataValue2", exportMetadata.Metadata2); Assert.Equal("MetadataValue3", exportMetadata.Metadata3); } [Fact] public void GetExportsOfTTMetadataView1_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport(typeof(string), metadata, "Value1"), new MicroExport(typeof(string), "Value2")); var exports = container.GetExports<string, IMetadataView>(); Assert.Equal(1, exports.Count()); var export = (Lazy<string, IMetadataView>)exports.First(); Assert.Equal("Value1", export.Value); Assert.Equal("MetadataValue1", export.Metadata.Metadata1); Assert.Equal("MetadataValue2", export.Metadata.Metadata2); Assert.Equal("MetadataValue3", export.Metadata.Metadata3); } [Fact] public void GetExportsOfTTMetadataView2_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport("Contract", metadata, "Value1"), new MicroExport("Contract", "Value2")); var exports = container.GetExports<string, IMetadataView>("Contract"); Assert.Equal(1, exports.Count()); var export = (Lazy<string, IMetadataView>)exports.First(); Assert.Equal("Value1", export.Value); Assert.Equal("MetadataValue1", export.Metadata.Metadata1); Assert.Equal("MetadataValue2", export.Metadata.Metadata2); Assert.Equal("MetadataValue3", export.Metadata.Metadata3); } [Fact] public void GetExports1_AskingForExactlyOneAndAllWhenContainerEmpty_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create(export => true, ImportCardinality.ExactlyOne); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExports(definition); }); } [Fact] public void GetExports1_AskingForZeroOrOneAndAllWhenContainerEmpty_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create(export => true, ImportCardinality.ZeroOrOne); var exports = container.GetExports(definition); Assert.Empty(exports); } [Fact] public void GetExports1_AskingForExactlyOneAndAllWhenContainerEmpty_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create(export => true, ImportCardinality.ZeroOrMore); var exports = container.GetExports(definition); Assert.Empty(exports); } [Fact] public void RemovePart_PartNotInContainerAsPartArgument_ShouldNotCauseImportsToBeRebound() { const string contractName = "Contract"; var exporter = PartFactory.CreateExporter(new MicroExport(contractName, 1)); var importer = PartFactory.CreateImporter(contractName); var container = ContainerFactory.Create(exporter, importer); Assert.Equal(1, importer.Value); Assert.Equal(1, importer.ImportSatisfiedCount); var doesNotExistInContainer = PartFactory.CreateExporter(new MicroExport(contractName, 2)); CompositionBatch batch = new CompositionBatch(); batch.RemovePart(doesNotExistInContainer); container.Compose(batch); Assert.Equal(1, importer.ImportSatisfiedCount); } [Fact] public void RemovePart_PartInContainerQueueAsPartArgument_ShouldNotLeavePartInContainer() { const string contractName = "Contract"; var exporter = PartFactory.CreateExporter(new MicroExport(contractName, 1)); var importer = PartFactory.CreateImporter(true, contractName); var container = ContainerFactory.Create(exporter, importer); CompositionBatch batch = new CompositionBatch(); batch.RemovePart(exporter); container.Compose(batch); Assert.Null(importer.Value); Assert.Equal(2, importer.ImportSatisfiedCount); } [Fact] public void RemovePart_PartAlreadyRemovedAsPartArgument_ShouldNotThrow() { var exporter = PartFactory.CreateExporter(new MicroExport("Contract", 1)); var container = ContainerFactory.Create(exporter); Assert.Equal(1, container.GetExportedValue<int>("Contract")); CompositionBatch batch = new CompositionBatch(); batch.RemovePart(exporter); container.Compose(batch); Assert.False(container.IsPresent("Contract")); batch = new CompositionBatch(); batch.RemovePart(exporter); container.Compose(batch); Assert.False(container.IsPresent("Contract")); } [Fact] public void TryComposeSimple() { var container = CreateCompositionContainer(); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.Equal(42, importer.Value); } [Fact] public void TryComposeSimpleFail() { var container = CreateCompositionContainer(); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer); CompositionAssert.ThrowsChangeRejectedError(ErrorId.ImportEngine_PartCannotSetImport, ErrorId.ImportEngine_ImportCardinalityMismatch, RetryMode.DoNotRetry, () => { container.Compose(batch); }); Assert.Equal(0, importer.Value); } [Fact] public void ComposeDisposableChildContainer() { var outerContainer = CreateCompositionContainer(); Int32Importer outerImporter = new Int32Importer(); CompositionBatch outerBatch = new CompositionBatch(); var key = outerBatch.AddExportedValue("Value", 42); outerBatch.AddPart(outerImporter); outerContainer.Compose(outerBatch); Assert.Equal(42, outerImporter.Value); Int32Importer innerImporter = new Int32Importer(); var innerContainer = new CompositionContainer(outerContainer); CompositionBatch innerBatch = new CompositionBatch(); innerBatch.AddPart(innerImporter); innerContainer.Compose(innerBatch); Assert.Equal(42, innerImporter.Value); Assert.Equal(42, outerImporter.Value); outerBatch = new CompositionBatch(); outerBatch.RemovePart(key); key = outerBatch.AddExportedValue("Value", -5); outerContainer.Compose(outerBatch); Assert.Equal(-5, innerImporter.Value); Assert.Equal(-5, outerImporter.Value); innerContainer.Dispose(); outerBatch = new CompositionBatch(); outerBatch.RemovePart(key); key = outerBatch.AddExportedValue("Value", 500); outerContainer.Compose(outerBatch); Assert.Equal(500, outerImporter.Value); Assert.Equal(-5, innerImporter.Value); } [Fact] public void RemoveValueTest() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); var key = batch.AddExportedValue("foo", "hello"); container.Compose(batch); var result = container.GetExportedValue<string>("foo"); Assert.Equal("hello", result); batch = new CompositionBatch(); batch.RemovePart(key); container.Compose(batch); Assert.False(container.IsPresent("foo")); batch = new CompositionBatch(); batch.RemovePart(key); // Remove should be idempotent container.Compose(batch); } [Fact] [Trait("Type", "Integration")] public void OptionalImportsOfValueTypeBoundToDefaultValueShouldNotAffectAvailableValues() { var container = CreateCompositionContainer(); var importer = new OptionalImporter(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(importer); container.Compose(batch); Assert.Equal(0, importer.ValueType); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<int>("ValueType"); }); } [Fact] [Trait("Type", "Integration")] public void OptionalImportsOfNullableValueTypeBoundToDefaultValueShouldNotAffectAvailableValues() { var container = CreateCompositionContainer(); var importer = new OptionalImporter(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(importer); container.Compose(batch); Assert.Null(importer.NullableValueType); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<int>("NullableValueType"); }); } [Fact] [Trait("Type", "Integration")] public void OptionalImportsOfReferenceTypeBoundToDefaultValueShouldNotAffectAvailableValues() { var container = CreateCompositionContainer(); var importer = new OptionalImporter(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(importer); container.Compose(batch); Assert.Null(importer.ReferenceType); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<int>("ReferenceType"); }); } [Fact] public void ExportsChanged_ExportNothing_ShouldNotFireExportsChanged() { var container = CreateCompositionContainer(); container.ExportsChanged += (sender, args) => { throw new NotImplementedException(); }; CompositionBatch batch = new CompositionBatch(); container.Compose(batch); } [Fact] public void ExportsChanged_ExportAdded_ShouldFireExportsChanged() { var container = CreateCompositionContainer(); IEnumerable<string> changedNames = null; container.ExportsChanged += (sender, args) => { Assert.Same(container, sender); Assert.Null(changedNames); Assert.NotNull(args.AddedExports); Assert.NotNull(args.RemovedExports); Assert.NotNull(args.ChangedContractNames); changedNames = args.ChangedContractNames; }; CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("MyExport", new object()); container.Compose(batch); EnumerableAssert.AreEqual(changedNames, "MyExport"); } [Fact] public void ExportsChanged_ExportRemoved_ShouldFireExportsChanged() { var container = CreateCompositionContainer(); IEnumerable<string> changedNames = null; CompositionBatch batch = new CompositionBatch(); var part = batch.AddExportedValue("MyExport", new object()); container.Compose(batch); container.ExportsChanged += (sender, args) => { Assert.Same(container, sender); Assert.Null(changedNames); Assert.NotNull(args.AddedExports); Assert.NotNull(args.RemovedExports); Assert.NotNull(args.ChangedContractNames); changedNames = args.ChangedContractNames; }; batch = new CompositionBatch(); batch.RemovePart(part); container.Compose(batch); EnumerableAssert.AreEqual(changedNames, "MyExport"); } [Fact] public void ExportsChanged_ExportAddAnother_ShouldFireExportsChanged() { var container = CreateCompositionContainer(); IEnumerable<string> changedNames = null; CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("MyExport", new object()); container.Compose(batch); container.ExportsChanged += (sender, args) => { Assert.Same(container, sender); Assert.Null(changedNames); Assert.NotNull(args.AddedExports); Assert.NotNull(args.RemovedExports); Assert.NotNull(args.ChangedContractNames); changedNames = args.ChangedContractNames; }; batch = new CompositionBatch(); // Adding another should cause an update. batch.AddExportedValue("MyExport", new object()); container.Compose(batch); EnumerableAssert.AreEqual(changedNames, "MyExport"); } [Fact] public void ExportsChanged_AddExportOnParent_ShouldFireExportsChangedOnBoth() { var parent = CreateCompositionContainer(); var child = new CompositionContainer(parent); IEnumerable<string> parentNames = null; parent.ExportsChanged += (sender, args) => { Assert.Same(parent, sender); parentNames = args.ChangedContractNames; }; IEnumerable<string> childNames = null; child.ExportsChanged += (sender, args) => { Assert.Same(child, sender); childNames = args.ChangedContractNames; }; CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("MyExport", new object()); parent.Compose(batch); EnumerableAssert.AreEqual(parentNames, "MyExport"); EnumerableAssert.AreEqual(childNames, "MyExport"); } [Fact] public void ExportsChanged_AddExportOnChild_ShouldFireExportsChangedOnChildOnly() { var parent = CreateCompositionContainer(); var child = new CompositionContainer(parent); parent.ExportsChanged += (sender, args) => { throw new NotImplementedException(); }; IEnumerable<string> childNames = null; child.ExportsChanged += (sender, args) => { Assert.Same(child, sender); childNames = args.ChangedContractNames; }; CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("MyExport2", new object()); child.Compose(batch); EnumerableAssert.AreEqual(childNames, "MyExport2"); } [Fact] public void ExportsChanged_FromAggregateCatalog_ShouldFireExportsChangedOnce() { var cat = new AggregateCatalog(); var container = new CompositionContainer(cat); IEnumerable<string> changedNames = null; container.ExportsChanged += (sender, args) => { Assert.Same(container, sender); Assert.Null(changedNames); Assert.NotNull(args.AddedExports); Assert.NotNull(args.RemovedExports); Assert.NotNull(args.ChangedContractNames); changedNames = args.ChangedContractNames; }; var typeCatalog = new TypeCatalog(typeof(SimpleExporter)); cat.Catalogs.Add(typeCatalog); Assert.NotNull(changedNames); } [Fact] public void Dispose_BeforeCompose_CanBeCallMultipleTimes() { var container = ContainerFactory.Create(PartFactory.Create(), PartFactory.Create()); container.Dispose(); container.Dispose(); container.Dispose(); } [Fact] public void Dispose_AfterCompose_CanBeCallMultipleTimes() { var container = ContainerFactory.Create(PartFactory.Create(), PartFactory.Create()); container.Dispose(); container.Dispose(); container.Dispose(); } [Fact] public void Dispose_CallsGCSuppressFinalize() { bool finalizerCalled = false; var container = ContainerFactory.CreateDisposable(disposing => { if (!disposing) { finalizerCalled = true; } }); container.Dispose(); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); Assert.False(finalizerCalled); } [Fact] public void Dispose_CallsDisposeBoolWithTrue() { var container = ContainerFactory.CreateDisposable(disposing => { Assert.True(disposing); }); container.Dispose(); } [Fact] public void Dispose_CallsDisposeBoolOnce() { int disposeCount = 0; var container = ContainerFactory.CreateDisposable(disposing => { disposeCount++; }); container.Dispose(); Assert.Equal(1, disposeCount); } [Fact] public void Dispose_ContainerAsExportedValue_CanBeDisposed() { using (var container = CreateCompositionContainer()) { CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue<ICompositionService>(container); container.Compose(batch); } } [Fact] public void Dispose_ContainerAsPart_CanBeDisposed() { // Tests that when we re-enter CompositionContainer.Dispose, that we don't // stack overflow. using (var container = CreateCompositionContainer()) { var part = PartFactory.CreateExporter(new MicroExport(typeof(ICompositionService), container)); CompositionBatch batch = new CompositionBatch(); batch.AddPart(part); container.Compose(batch); Assert.Same(container, container.GetExportedValue<ICompositionService>()); } } [Fact] public void ICompositionService_ShouldNotBeImplicitlyExported() { var container = CreateCompositionContainer(); Assert.False(container.IsPresent<ICompositionService>()); } [Fact] public void CompositionContainer_ShouldNotBeImplicitlyExported() { var container = CreateCompositionContainer(); Assert.False(container.IsPresent<CompositionContainer>()); } [Fact] public void ICompositionService_ShouldNotBeImplicitlyImported() { var importer = PartFactory.CreateImporter<ICompositionService>(); var container = ContainerFactory.Create(importer); Assert.Null(importer.Value); } [Fact] public void CompositionContainer_ShouldNotBeImplicitlyImported() { var importer = PartFactory.CreateImporter<CompositionContainer>(); var container = ContainerFactory.Create(importer); Assert.Null(importer.Value); } [Fact] public void ICompositionService_CanBeExported() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue<ICompositionService>(container); container.Compose(batch); Assert.Same(container, container.GetExportedValue<ICompositionService>()); } [Fact] public void CompositionContainer_CanBeExported() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue<CompositionContainer>(container); container.Compose(batch); Assert.Same(container, container.GetExportedValue<CompositionContainer>()); } [Fact] public void ReleaseExport_Null_ShouldThrowArgumentNull() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentNullException>("export", () => container.ReleaseExport(null)); } [Fact] public void ReleaseExports_Null_ShouldThrowArgumentNull() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentNullException>("exports", () => container.ReleaseExports(null)); } [Fact] public void ReleaseExports_ElementNull_ShouldThrowArgument() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentException>("exports", () => container.ReleaseExports(new Export[] { null })); } public class OptionalImporter { [Import("ValueType", AllowDefault = true)] public int ValueType { get; set; } [Import("NullableValueType", AllowDefault = true)] public int? NullableValueType { get; set; } [Import("ReferenceType", AllowDefault = true)] public string ReferenceType { get; set; } } public class ExportSimpleIntWithException { [Export("SimpleInt")] public int SimpleInt { get { throw new NotImplementedException(); } } } [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/24240", TestPlatforms.AnyUnix)] // Actual: typeof(System.Reflection.ReflectionTypeLoadException) public void TryGetValueWithCatalogVerifyExecptionDuringGet() { var cat = CatalogFactory.CreateDefaultAttributed(); var container = new CompositionContainer(cat); CompositionAssert.ThrowsError(ErrorId.ImportEngine_PartCannotGetExportedValue, () => { container.GetExportedValue<int>("SimpleInt"); }); } [Fact] public void TryGetExportedValueWhileLockedForNotify() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(new CallbackImportNotify(delegate { container.GetExportedValueOrDefault<int>(); })); container.Compose(batch); } [Fact] public void RawExportTests() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("foo", 1); container.Compose(batch); Lazy<int> export = container.GetExport<int>("foo"); Assert.Equal(1, export.Value); } [Export("MyExporterWithNoFoo")] public class MyExporterWithNoFoo { } [Export("MyExporterWithFoo")] [ExportMetadata("Foo", "Foo value")] public class MyExporterWithFoo { } [Export("MyExporterWithFooBar")] [ExportMetadata("Foo", "Foo value")] [ExportMetadata("Bar", "Bar value")] public class MyExporterWithFooBar { } // Silverlight doesn't support strongly typed metadata [Fact] public void ConverterExportTests() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("foo", 1); container.Compose(batch); var export = container.GetExport<int, IDictionary<string, object>>("foo"); Assert.Equal(1, export.Value); Assert.NotNull(export.Metadata); } [Fact] public void RemoveFromWrongContainerTest() { CompositionContainer d1 = CreateCompositionContainer(); CompositionContainer d2 = CreateCompositionContainer(); CompositionBatch batch1 = new CompositionBatch(); var valueKey = batch1.AddExportedValue("a", 1); d1.Compose(batch1); CompositionBatch batch2 = new CompositionBatch(); batch2.RemovePart(valueKey); // removing entry from wrong container, shoudl be a no-op d2.Compose(batch2); } [Fact] [Trait("Type", "Integration")] public void AddPartSimple() { var container = CreateCompositionContainer(); var importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(importer); batch.AddPart(new Int32Exporter(42)); container.Compose(batch); Assert.Equal(42, importer.Value); } [Fact] [Trait("Type", "Integration")] public void AddPart() { var container = CreateCompositionContainer(); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(AttributedModelServices.CreatePart(importer)); batch.AddPart(new Int32Exporter(42)); container.Compose(batch); Assert.Equal(42, importer.Value); } [Fact] public void ComposeReentrantChildContainerDisposed() { var container = CreateCompositionContainer(); Int32Importer outerImporter = new Int32Importer(); Int32Importer innerImporter = new Int32Importer(); Int32Exporter exporter = new Int32Exporter(42); CompositionBatch batch = new CompositionBatch(); batch.AddPart(exporter); container.Compose(batch); CallbackExecuteCodeDuringCompose callback = new CallbackExecuteCodeDuringCompose(() => { using (CompositionContainer innerContainer = new CompositionContainer(container)) { CompositionBatch nestedBatch = new CompositionBatch(); nestedBatch.AddPart(innerImporter); innerContainer.Compose(nestedBatch); } Assert.Equal(42, innerImporter.Value); }); batch = new CompositionBatch(); batch.AddParts(outerImporter, callback); container.Compose(batch); Assert.Equal(42, outerImporter.Value); Assert.Equal(42, innerImporter.Value); } [Fact] public void ComposeSimple() { var container = CreateCompositionContainer(); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.Equal(42, importer.Value); } [Fact] public void ComposeSimpleFail() { var container = CreateCompositionContainer(); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(importer); CompositionAssert.ThrowsChangeRejectedError(ErrorId.ImportEngine_PartCannotSetImport, // Cannot set Int32Importer.Value because ErrorId.ImportEngine_ImportCardinalityMismatch, // No exports are present that match contract RetryMode.DoNotRetry, () => { container.Compose(batch); }); } [Fact] public void ExceptionDuringNotify() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(new CallbackImportNotify(delegate { throw new InvalidOperationException(); })); CompositionAssert.ThrowsError(ErrorId.ImportEngine_PartCannotActivate, // Cannot activate CallbackImportNotify because RetryMode.DoNotRetry, () => { container.Compose(batch); }); } [Fact] public void NeutralComposeWhileNotified() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(new CallbackImportNotify(delegate { // Is this really a supported scenario? container.Compose(batch); })); container.Compose(batch); } public class PartWithReentrantCompose : ComposablePart { private CompositionContainer _container; public PartWithReentrantCompose(CompositionContainer container) { this._container = container; } public override IEnumerable<ExportDefinition> ExportDefinitions { get { this._container.ComposeExportedValue<string>("ExportedString"); return Enumerable.Empty<ExportDefinition>(); } } public override IEnumerable<ImportDefinition> ImportDefinitions { get { return Enumerable.Empty<ImportDefinition>(); } } public override object GetExportedValue(ExportDefinition definition) { throw new NotImplementedException(); } public override void SetImport(ImportDefinition definition, IEnumerable<Export> exports) { throw new NotImplementedException(); } } [Export] public class SimpleExporter { } [Fact] public void ThreadSafeCompositionContainer() { TypeCatalog catalog = new TypeCatalog(typeof(SimpleExporter)); CompositionContainer container = new CompositionContainer(catalog, true); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.NotNull(container.GetExportedValue<SimpleExporter>()); Assert.Equal(42, importer.Value); container.Dispose(); } [Fact] public void ThreadSafeCompositionOptionsCompositionContainer() { TypeCatalog catalog = new TypeCatalog(typeof(SimpleExporter)); CompositionContainer container = new CompositionContainer(catalog, CompositionOptions.IsThreadSafe); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.NotNull(container.GetExportedValue<SimpleExporter>()); Assert.Equal(42, importer.Value); container.Dispose(); } [Fact] public void DisableSilentRejectionCompositionOptionsCompositionContainer() { TypeCatalog catalog = new TypeCatalog(typeof(SimpleExporter)); CompositionContainer container = new CompositionContainer(catalog, CompositionOptions.DisableSilentRejection); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.NotNull(container.GetExportedValue<SimpleExporter>()); Assert.Equal(42, importer.Value); container.Dispose(); } [Fact] public void DisableSilentRejectionThreadSafeCompositionOptionsCompositionContainer() { TypeCatalog catalog = new TypeCatalog(typeof(SimpleExporter)); CompositionContainer container = new CompositionContainer(catalog, CompositionOptions.DisableSilentRejection | CompositionOptions.IsThreadSafe); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.NotNull(container.GetExportedValue<SimpleExporter>()); Assert.Equal(42, importer.Value); container.Dispose(); } [Fact] public void CompositionOptionsInvalidValue() { Assert.Throws<ArgumentOutOfRangeException>("compositionOptions", () => new CompositionContainer((CompositionOptions)0x0400)); } [Fact] public void ReentrantencyDisabledWhileComposing() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(new PartWithReentrantCompose(container)); ExceptionAssert.Throws<InvalidOperationException>(() => container.Compose(batch)); } private static Expression<Func<ExportDefinition, bool>> ConstraintFromContract(string contractName) { return ConstraintFactory.Create(contractName); } private static string ContractFromType(Type type) { return AttributedModelServices.GetContractName(type); } private static CompositionContainer CreateCompositionContainer() { return new CompositionContainer(); } public interface IMetadataView { string Metadata1 { get; } string Metadata2 { get; } string Metadata3 { get; } } [Fact] public void ComposeExportedValueOfT_NullStringAsExportedValueArgument_VerifyCanPullOnValue() { var container = CreateCompositionContainer(); var expectation = (string)null; container.ComposeExportedValue<string>(expectation); var actualValue = container.GetExportedValue<string>(); Assert.Equal(expectation, actualValue); } [Fact] public void ComposeExportedValueOfT_StringAsExportedValueArgument_VerifyCanPullOnValue() { var expectations = new List<string>(); expectations.Add((string)null); expectations.Add(string.Empty); expectations.Add("Value"); foreach (var expectation in expectations) { var container = CreateCompositionContainer(); container.ComposeExportedValue<string>(expectation); var actualValue = container.GetExportedValue<string>(); Assert.Equal(expectation, actualValue); } } [Fact] public void ComposeExportedValueOfT_StringAsIEnumerableOfCharAsExportedValueArgument_VerifyCanPullOnValue() { var expectations = new List<string>(); expectations.Add((string)null); expectations.Add(string.Empty); expectations.Add("Value"); foreach (var expectation in expectations) { var container = CreateCompositionContainer(); container.ComposeExportedValue<IEnumerable<char>>(expectation); var actualValue = container.GetExportedValue<IEnumerable<char>>(); Assert.Equal(expectation, actualValue); } } [Fact] public void ComposeExportedValueOfT_ObjectAsExportedValueArgument_VerifyCanPullOnValue() { var expectations = new List<object>(); expectations.Add((string)null); expectations.Add(string.Empty); expectations.Add("Value"); expectations.Add(42); expectations.Add(new object()); foreach (var expectation in expectations) { var container = CreateCompositionContainer(); container.ComposeExportedValue<object>(expectation); var actualValue = container.GetExportedValue<object>(); Assert.Equal(expectation, actualValue); } } [Fact] public void ComposeExportedValueOfT_ExportedValue_ExportedUnderDefaultContractName() { string expectedContractName = AttributedModelServices.GetContractName(typeof(string)); var container = CreateCompositionContainer(); container.ComposeExportedValue<string>("Value"); var importDefinition = new ImportDefinition(ed => true, null, ImportCardinality.ZeroOrMore, false, false); var exports = container.GetExports(importDefinition); Assert.Equal(1, exports.Count()); Assert.Equal(expectedContractName, exports.Single().Definition.ContractName); } [Fact] public void ComposeExportedValueOfT_ExportedValue_ExportContainsEmptyMetadata() { var container = CreateCompositionContainer(); container.ComposeExportedValue<string>("Value"); var importDefinition = new ImportDefinition(ed => true, null, ImportCardinality.ZeroOrMore, false, false); var exports = container.GetExports(importDefinition); Assert.Equal(1, exports.Count()); Assert.Equal(1, exports.Single().Metadata.Count); // contains type identity } [Fact] public void ComposeExportedValueOfT_ExportedValue_LazyContainsEmptyMetadata() { var container = CreateCompositionContainer(); container.ComposeExportedValue<string>("Value"); var lazy = container.GetExport<string, IDictionary<string, object>>(); Assert.Equal(1, lazy.Metadata.Count); // contains type identity } [Fact] public void ComposeExportedValueOfT_ExportedValue_ImportsAreNotDiscovered() { var container = CreateCompositionContainer(); var importer = new PartWithRequiredImport(); container.ComposeExportedValue<object>(importer); var importDefinition = new ImportDefinition(ed => true, null, ImportCardinality.ZeroOrMore, false, false); var exports = container.GetExports(importDefinition); Assert.Equal(1, exports.Count()); // we only get one if the import was not discovered since the import is not satisfied } [Fact] public void ComposeExportedValueOfT_NullAsContractName_ThrowsArgumentNullException() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentNullException>("contractName", () => container.ComposeExportedValue<string>((string)null, "Value")); } [Fact] public void ComposeExportedValueOfT_EmptyStringAsContractName_ThrowsArgumentException() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentException>("contractName", () => container.ComposeExportedValue<string>(string.Empty, "Value")); } [Fact] public void ComposeExportedValueOfT_ValidContractName_ValidExportedValue_VerifyCanPullOnValue() { var expectations = new List<Tuple<string, string>>(); expectations.Add(new Tuple<string, string>(" ", (string)null)); expectations.Add(new Tuple<string, string>(" ", string.Empty)); expectations.Add(new Tuple<string, string>(" ", "Value")); expectations.Add(new Tuple<string, string>("ContractName", (string)null)); expectations.Add(new Tuple<string, string>("ContractName", string.Empty)); expectations.Add(new Tuple<string, string>("ContractName", "Value")); foreach (var expectation in expectations) { var container = CreateCompositionContainer(); container.ComposeExportedValue<string>(expectation.Item1, expectation.Item2); var actualValue = container.GetExportedValue<string>(expectation.Item1); Assert.Equal(expectation.Item2, actualValue); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => container.GetExportedValue<string>()); } } [Fact] public void ComposeExportedValueOfT_ValidContractName_ExportedValue_ExportedUnderSpecifiedContractName() { string expectedContractName = "ContractName"; var container = CreateCompositionContainer(); container.ComposeExportedValue<string>(expectedContractName, "Value"); var importDefinition = new ImportDefinition(ed => true, null, ImportCardinality.ZeroOrMore, false, false); var exports = container.GetExports(importDefinition); Assert.Equal(1, exports.Count()); Assert.Equal(expectedContractName, exports.Single().Definition.ContractName); } [Fact] public void ComposeExportedValueOfT_ValidContractName_ExportedValue_ImportsAreNotDiscovered() { var container = CreateCompositionContainer(); var importer = new PartWithRequiredImport(); container.ComposeExportedValue<object>("ContractName", importer); var importDefinition = new ImportDefinition(ed => true, null, ImportCardinality.ZeroOrMore, false, false); var exports = container.GetExports(importDefinition); Assert.Equal(1, exports.Count()); // we only get one if the import was not discovered since the import is not satisfied } [Fact] public void TestExportedValueCachesNullValue() { var container = ContainerFactory.Create(); var exporter = new ExportsMutableProperty(); exporter.Property = null; container.ComposeParts(exporter); Assert.Null(container.GetExportedValue<string>("Property")); exporter.Property = "Value1"; // Exported value should have been cached and so it shouldn't change Assert.Null(container.GetExportedValue<string>("Property")); } [Fact] public void TestExportedValueUsingWhereClause_ExportSuccessful() { CompositionContainer container = new CompositionContainer(new TypeCatalog(typeof(MefCollection<,>))); IMefCollection<DerivedClass, BaseClass> actualValue = container.GetExportedValue<IMefCollection<DerivedClass, BaseClass>>("UsingWhereClause"); Assert.NotNull(actualValue); Assert.IsType<MefCollection<DerivedClass, BaseClass>>(actualValue); } public interface IMefCollection { } public interface IMefCollection<TC, TP> : IList<TC>, IMefCollection where TC : TP { } public class BaseClass { } public class DerivedClass : BaseClass { } [Export("UsingWhereClause", typeof(IMefCollection<,>))] public class MefCollection<TC, TP> : ObservableCollection<TC>, IMefCollection<TC, TP> where TC : TP { } public class ExportsMutableProperty { [Export("Property")] public string Property { get; set; } } public class PartWithRequiredImport { [Import] public object Import { get; set; } } } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/libraries/System.Private.CoreLib/src/System/Threading/EventResetMode.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /*============================================================================= ** ** Enum: EventResetMode ** ** ** Purpose: Enum to determine the Event type to create ** ** =============================================================================*/ namespace System.Threading { public enum EventResetMode { AutoReset = 0, ManualReset = 1 } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /*============================================================================= ** ** Enum: EventResetMode ** ** ** Purpose: Enum to determine the Event type to create ** ** =============================================================================*/ namespace System.Threading { public enum EventResetMode { AutoReset = 0, ManualReset = 1 } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/libraries/Microsoft.Extensions.DependencyInjection.Specification.Tests/src/Fakes/AnotherClass.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace Microsoft.Extensions.DependencyInjection.Specification.Fakes { public class AnotherClass { public AnotherClass(IFakeService fakeService) { FakeService = fakeService; } public IFakeService FakeService { get; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace Microsoft.Extensions.DependencyInjection.Specification.Fakes { public class AnotherClass { public AnotherClass(IFakeService fakeService) { FakeService = fakeService; } public IFakeService FakeService { get; } } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbMetaDataFactory.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Data.Common; using System.Diagnostics; using System.Globalization; using System.IO; namespace System.Data.ProviderBase { internal class DbMetaDataFactory { // V1.2.3300 private DataSet _metaDataCollectionsDataSet; private string _normalizedServerVersion; private string _serverVersionString; // well known column names private const string _collectionName = "CollectionName"; private const string _populationMechanism = "PopulationMechanism"; private const string _populationString = "PopulationString"; private const string _maximumVersion = "MaximumVersion"; private const string _minimumVersion = "MinimumVersion"; private const string _dataSourceProductVersionNormalized = "DataSourceProductVersionNormalized"; private const string _dataSourceProductVersion = "DataSourceProductVersion"; private const string _restrictionNumber = "RestrictionNumber"; private const string _numberOfRestrictions = "NumberOfRestrictions"; private const string _restrictionName = "RestrictionName"; private const string _parameterName = "ParameterName"; // population mechanisms private const string _dataTable = "DataTable"; private const string _sqlCommand = "SQLCommand"; private const string _prepareCollection = "PrepareCollection"; public DbMetaDataFactory(Stream xmlStream, string serverVersion, string normalizedServerVersion) { ADP.CheckArgumentNull(xmlStream, "xmlStream"); ADP.CheckArgumentNull(serverVersion, "serverVersion"); ADP.CheckArgumentNull(normalizedServerVersion, "normalizedServerVersion"); _metaDataCollectionsDataSet = new DataSet { Locale = CultureInfo.InvariantCulture }; _metaDataCollectionsDataSet.ReadXml(xmlStream); _serverVersionString = serverVersion; _normalizedServerVersion = normalizedServerVersion; } protected DataSet CollectionDataSet { get { return _metaDataCollectionsDataSet; } } protected string ServerVersion { get { return _serverVersionString; } } protected string ServerVersionNormalized { get { return _normalizedServerVersion; } } protected DataTable CloneAndFilterCollection(string collectionName, string[]? hiddenColumnNames) { DataTable? sourceTable; DataTable destinationTable; DataColumn[] filteredSourceColumns; DataColumnCollection destinationColumns; DataRow newRow; sourceTable = _metaDataCollectionsDataSet.Tables[collectionName]; if ((sourceTable == null) || (collectionName != sourceTable.TableName)) { throw ADP.DataTableDoesNotExist(collectionName); } destinationTable = new DataTable(collectionName); destinationTable.Locale = CultureInfo.InvariantCulture; destinationColumns = destinationTable.Columns; filteredSourceColumns = FilterColumns(sourceTable, hiddenColumnNames, destinationColumns); foreach (DataRow row in sourceTable.Rows) { if (SupportedByCurrentVersion(row) == true) { newRow = destinationTable.NewRow(); for (int i = 0; i < destinationColumns.Count; i++) { newRow[destinationColumns[i]] = row[filteredSourceColumns[i], DataRowVersion.Current]; } destinationTable.Rows.Add(newRow); newRow.AcceptChanges(); } } return destinationTable; } public void Dispose() { Dispose(true); } protected virtual void Dispose(bool disposing) { if (disposing) { _normalizedServerVersion = null!; _serverVersionString = null!; _metaDataCollectionsDataSet.Dispose(); } } private DataTable ExecuteCommand(DataRow requestedCollectionRow, string?[]? restrictions, DbConnection connection) { DataTable metaDataCollectionsTable = _metaDataCollectionsDataSet.Tables[DbMetaDataCollectionNames.MetaDataCollections]!; DataColumn populationStringColumn = metaDataCollectionsTable.Columns[_populationString]!; DataColumn numberOfRestrictionsColumn = metaDataCollectionsTable.Columns[_numberOfRestrictions]!; DataColumn collectionNameColumn = metaDataCollectionsTable.Columns[_collectionName]!; //DataColumn restrictionNameColumn = metaDataCollectionsTable.Columns[_restrictionName]; Debug.Assert(requestedCollectionRow != null); string sqlCommand = (requestedCollectionRow[populationStringColumn, DataRowVersion.Current] as string)!; int numberOfRestrictions = (int)requestedCollectionRow[numberOfRestrictionsColumn, DataRowVersion.Current]; string collectionName = (requestedCollectionRow[collectionNameColumn, DataRowVersion.Current] as string)!; if ((restrictions != null) && (restrictions.Length > numberOfRestrictions)) { throw ADP.TooManyRestrictions(collectionName); } DbCommand? command = connection.CreateCommand(); command.CommandText = sqlCommand; command.CommandTimeout = System.Math.Max(command.CommandTimeout, 180); DataTable? resultTable = null; for (int i = 0; i < numberOfRestrictions; i++) { DbParameter restrictionParameter = command.CreateParameter(); if ((restrictions != null) && (restrictions.Length > i) && (restrictions[i] != null)) { restrictionParameter.Value = restrictions[i]; } else { // This is where we have to assign null to the value of the parameter. restrictionParameter.Value = DBNull.Value; } restrictionParameter.ParameterName = GetParameterName(collectionName, i + 1); restrictionParameter.Direction = ParameterDirection.Input; command.Parameters.Add(restrictionParameter); } DbDataReader? reader = null; try { try { reader = command.ExecuteReader(); } catch (Exception e) { if (!ADP.IsCatchableExceptionType(e)) { throw; } throw ADP.QueryFailed(collectionName, e); } // TODO: Consider using the DataAdapter.Fill // Build a DataTable from the reader resultTable = new DataTable(collectionName); resultTable.Locale = CultureInfo.InvariantCulture; DataTable? schemaTable = reader.GetSchemaTable(); foreach (DataRow row in schemaTable!.Rows) { resultTable.Columns.Add(row["ColumnName"] as string, (Type)row["DataType"]); } object[] values = new object[resultTable.Columns.Count]; while (reader.Read()) { reader.GetValues(values); resultTable.Rows.Add(values); } } finally { if (reader != null) { reader.Dispose(); } } return resultTable; } private DataColumn[] FilterColumns(DataTable sourceTable, string[]? hiddenColumnNames, DataColumnCollection destinationColumns) { DataColumn newDestinationColumn; int currentColumn; int columnCount = 0; foreach (DataColumn sourceColumn in sourceTable.Columns) { if (IncludeThisColumn(sourceColumn, hiddenColumnNames) == true) { columnCount++; } } if (columnCount == 0) { throw ADP.NoColumns(); } currentColumn = 0; var filteredSourceColumns = new DataColumn[columnCount]; foreach (DataColumn sourceColumn in sourceTable.Columns) { if (IncludeThisColumn(sourceColumn, hiddenColumnNames) == true) { newDestinationColumn = new DataColumn(sourceColumn.ColumnName, sourceColumn.DataType); destinationColumns.Add(newDestinationColumn); filteredSourceColumns[currentColumn] = sourceColumn; currentColumn++; } } return filteredSourceColumns; } internal DataRow FindMetaDataCollectionRow(string collectionName) { bool versionFailure; bool haveExactMatch; bool haveMultipleInexactMatches; string? candidateCollectionName; DataTable? metaDataCollectionsTable = _metaDataCollectionsDataSet.Tables[DbMetaDataCollectionNames.MetaDataCollections]; if (metaDataCollectionsTable == null) { throw ADP.InvalidXml(); } DataColumn? collectionNameColumn = metaDataCollectionsTable.Columns[DbMetaDataColumnNames.CollectionName]; if ((null == collectionNameColumn) || (typeof(string) != collectionNameColumn.DataType)) { throw ADP.InvalidXmlMissingColumn(DbMetaDataCollectionNames.MetaDataCollections, DbMetaDataColumnNames.CollectionName); } DataRow? requestedCollectionRow = null; string? exactCollectionName = null; // find the requested collection versionFailure = false; haveExactMatch = false; haveMultipleInexactMatches = false; foreach (DataRow row in metaDataCollectionsTable.Rows) { candidateCollectionName = row[collectionNameColumn, DataRowVersion.Current] as string; if (ADP.IsEmpty(candidateCollectionName)) { throw ADP.InvalidXmlInvalidValue(DbMetaDataCollectionNames.MetaDataCollections, DbMetaDataColumnNames.CollectionName); } if (ADP.CompareInsensitiveInvariant(candidateCollectionName, collectionName)) { if (SupportedByCurrentVersion(row) == false) { versionFailure = true; } else { if (collectionName == candidateCollectionName) { if (haveExactMatch == true) { throw ADP.CollectionNameIsNotUnique(collectionName); } requestedCollectionRow = row; exactCollectionName = candidateCollectionName; haveExactMatch = true; } else { // have an inexact match - ok only if it is the only one if (exactCollectionName != null) { // can't fail here becasue we may still find an exact match haveMultipleInexactMatches = true; } requestedCollectionRow = row; exactCollectionName = candidateCollectionName; } } } } if (requestedCollectionRow == null) { if (versionFailure == false) { throw ADP.UndefinedCollection(collectionName); } else { throw ADP.UnsupportedVersion(collectionName); } } if ((haveExactMatch == false) && (haveMultipleInexactMatches == true)) { throw ADP.AmbigousCollectionName(collectionName); } return requestedCollectionRow; } private void FixUpVersion(DataTable dataSourceInfoTable) { Debug.Assert(dataSourceInfoTable.TableName == DbMetaDataCollectionNames.DataSourceInformation); DataColumn? versionColumn = dataSourceInfoTable.Columns[_dataSourceProductVersion]; DataColumn? normalizedVersionColumn = dataSourceInfoTable.Columns[_dataSourceProductVersionNormalized]; if ((versionColumn == null) || (normalizedVersionColumn == null)) { throw ADP.MissingDataSourceInformationColumn(); } if (dataSourceInfoTable.Rows.Count != 1) { throw ADP.IncorrectNumberOfDataSourceInformationRows(); } DataRow dataSourceInfoRow = dataSourceInfoTable.Rows[0]; dataSourceInfoRow[versionColumn] = _serverVersionString; dataSourceInfoRow[normalizedVersionColumn] = _normalizedServerVersion; dataSourceInfoRow.AcceptChanges(); } private string GetParameterName(string neededCollectionName, int neededRestrictionNumber) { DataTable? restrictionsTable; DataColumnCollection? restrictionColumns; DataColumn? collectionName = null; DataColumn? parameterName = null; DataColumn? restrictionName = null; DataColumn? restrictionNumber = null; string? result = null; restrictionsTable = _metaDataCollectionsDataSet.Tables[DbMetaDataCollectionNames.Restrictions]; if (restrictionsTable != null) { restrictionColumns = restrictionsTable.Columns; if (restrictionColumns != null) { collectionName = restrictionColumns[_collectionName]; parameterName = restrictionColumns[_parameterName]; restrictionName = restrictionColumns[_restrictionName]; restrictionNumber = restrictionColumns[_restrictionNumber]; } } if ((parameterName == null) || (collectionName == null) || (restrictionName == null) || (restrictionNumber == null)) { throw ADP.MissingRestrictionColumn(); } foreach (DataRow restriction in restrictionsTable!.Rows) { if (((string)restriction[collectionName] == neededCollectionName) && ((int)restriction[restrictionNumber] == neededRestrictionNumber) && (SupportedByCurrentVersion(restriction))) { result = (string)restriction[parameterName]; break; } } if (result == null) { throw ADP.MissingRestrictionRow(); } return result; } public virtual DataTable GetSchema(DbConnection connection, string collectionName, string?[]? restrictions) { Debug.Assert(_metaDataCollectionsDataSet != null); DataTable metaDataCollectionsTable = _metaDataCollectionsDataSet.Tables[DbMetaDataCollectionNames.MetaDataCollections]!; DataColumn populationMechanismColumn = metaDataCollectionsTable.Columns[_populationMechanism]!; DataColumn collectionNameColumn = metaDataCollectionsTable.Columns[DbMetaDataColumnNames.CollectionName]!; string[]? hiddenColumns; DataTable? requestedSchema; DataRow? requestedCollectionRow = FindMetaDataCollectionRow(collectionName); string exactCollectionName = (requestedCollectionRow[collectionNameColumn, DataRowVersion.Current] as string)!; if (ADP.IsEmptyArray(restrictions) == false) { for (int i = 0; i < restrictions!.Length; i++) { if ((restrictions[i]?.Length > 4096)) { // use a non-specific error because no new beta 2 error messages are allowed // TODO: will add a more descriptive error in RTM throw ADP.NotSupported(); } } } string populationMechanism = (requestedCollectionRow[populationMechanismColumn, DataRowVersion.Current] as string)!; switch (populationMechanism) { case _dataTable: if (exactCollectionName == DbMetaDataCollectionNames.MetaDataCollections) { hiddenColumns = new string[2]; hiddenColumns[0] = _populationMechanism; hiddenColumns[1] = _populationString; } else { hiddenColumns = null; } // none of the datatable collections support restrictions if (ADP.IsEmptyArray(restrictions) == false) { throw ADP.TooManyRestrictions(exactCollectionName); } requestedSchema = CloneAndFilterCollection(exactCollectionName, hiddenColumns); // TODO: Consider an alternate method that doesn't involve special casing -- perhaps _prepareCollection // for the data source infomation table we need to fix up the version columns at run time // since the version is determined at run time if (exactCollectionName == DbMetaDataCollectionNames.DataSourceInformation) { FixUpVersion(requestedSchema); } break; case _sqlCommand: requestedSchema = ExecuteCommand(requestedCollectionRow, restrictions, connection); break; case _prepareCollection: requestedSchema = PrepareCollection(exactCollectionName, restrictions, connection); break; default: throw ADP.UndefinedPopulationMechanism(populationMechanism); } return requestedSchema; } private bool IncludeThisColumn(DataColumn sourceColumn, string[]? hiddenColumnNames) { bool result = true; string sourceColumnName = sourceColumn.ColumnName; switch (sourceColumnName) { case _minimumVersion: case _maximumVersion: result = false; break; default: if (hiddenColumnNames == null) { break; } for (int i = 0; i < hiddenColumnNames.Length; i++) { if (hiddenColumnNames[i] == sourceColumnName) { result = false; break; } } break; } return result; } protected virtual DataTable PrepareCollection(string collectionName, string?[]? restrictions, DbConnection connection) { throw ADP.NotSupported(); } private bool SupportedByCurrentVersion(DataRow requestedCollectionRow) { bool result = true; DataColumnCollection tableColumns = requestedCollectionRow.Table.Columns; DataColumn? versionColumn; object version; // check the minimum version first versionColumn = tableColumns[_minimumVersion]; if (versionColumn != null) { version = requestedCollectionRow[versionColumn]; if (version != null) { if (version != DBNull.Value) { if (0 > string.Compare(_normalizedServerVersion, (string)version, StringComparison.OrdinalIgnoreCase)) { result = false; } } } } // if the minmum version was ok what about the maximum version if (result == true) { versionColumn = tableColumns[_maximumVersion]; if (versionColumn != null) { version = requestedCollectionRow[versionColumn]; if (version != null) { if (version != DBNull.Value) { if (0 < string.Compare(_normalizedServerVersion, (string)version, StringComparison.OrdinalIgnoreCase)) { result = false; } } } } } return result; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Data.Common; using System.Diagnostics; using System.Globalization; using System.IO; namespace System.Data.ProviderBase { internal class DbMetaDataFactory { // V1.2.3300 private DataSet _metaDataCollectionsDataSet; private string _normalizedServerVersion; private string _serverVersionString; // well known column names private const string _collectionName = "CollectionName"; private const string _populationMechanism = "PopulationMechanism"; private const string _populationString = "PopulationString"; private const string _maximumVersion = "MaximumVersion"; private const string _minimumVersion = "MinimumVersion"; private const string _dataSourceProductVersionNormalized = "DataSourceProductVersionNormalized"; private const string _dataSourceProductVersion = "DataSourceProductVersion"; private const string _restrictionNumber = "RestrictionNumber"; private const string _numberOfRestrictions = "NumberOfRestrictions"; private const string _restrictionName = "RestrictionName"; private const string _parameterName = "ParameterName"; // population mechanisms private const string _dataTable = "DataTable"; private const string _sqlCommand = "SQLCommand"; private const string _prepareCollection = "PrepareCollection"; public DbMetaDataFactory(Stream xmlStream, string serverVersion, string normalizedServerVersion) { ADP.CheckArgumentNull(xmlStream, "xmlStream"); ADP.CheckArgumentNull(serverVersion, "serverVersion"); ADP.CheckArgumentNull(normalizedServerVersion, "normalizedServerVersion"); _metaDataCollectionsDataSet = new DataSet { Locale = CultureInfo.InvariantCulture }; _metaDataCollectionsDataSet.ReadXml(xmlStream); _serverVersionString = serverVersion; _normalizedServerVersion = normalizedServerVersion; } protected DataSet CollectionDataSet { get { return _metaDataCollectionsDataSet; } } protected string ServerVersion { get { return _serverVersionString; } } protected string ServerVersionNormalized { get { return _normalizedServerVersion; } } protected DataTable CloneAndFilterCollection(string collectionName, string[]? hiddenColumnNames) { DataTable? sourceTable; DataTable destinationTable; DataColumn[] filteredSourceColumns; DataColumnCollection destinationColumns; DataRow newRow; sourceTable = _metaDataCollectionsDataSet.Tables[collectionName]; if ((sourceTable == null) || (collectionName != sourceTable.TableName)) { throw ADP.DataTableDoesNotExist(collectionName); } destinationTable = new DataTable(collectionName); destinationTable.Locale = CultureInfo.InvariantCulture; destinationColumns = destinationTable.Columns; filteredSourceColumns = FilterColumns(sourceTable, hiddenColumnNames, destinationColumns); foreach (DataRow row in sourceTable.Rows) { if (SupportedByCurrentVersion(row) == true) { newRow = destinationTable.NewRow(); for (int i = 0; i < destinationColumns.Count; i++) { newRow[destinationColumns[i]] = row[filteredSourceColumns[i], DataRowVersion.Current]; } destinationTable.Rows.Add(newRow); newRow.AcceptChanges(); } } return destinationTable; } public void Dispose() { Dispose(true); } protected virtual void Dispose(bool disposing) { if (disposing) { _normalizedServerVersion = null!; _serverVersionString = null!; _metaDataCollectionsDataSet.Dispose(); } } private DataTable ExecuteCommand(DataRow requestedCollectionRow, string?[]? restrictions, DbConnection connection) { DataTable metaDataCollectionsTable = _metaDataCollectionsDataSet.Tables[DbMetaDataCollectionNames.MetaDataCollections]!; DataColumn populationStringColumn = metaDataCollectionsTable.Columns[_populationString]!; DataColumn numberOfRestrictionsColumn = metaDataCollectionsTable.Columns[_numberOfRestrictions]!; DataColumn collectionNameColumn = metaDataCollectionsTable.Columns[_collectionName]!; //DataColumn restrictionNameColumn = metaDataCollectionsTable.Columns[_restrictionName]; Debug.Assert(requestedCollectionRow != null); string sqlCommand = (requestedCollectionRow[populationStringColumn, DataRowVersion.Current] as string)!; int numberOfRestrictions = (int)requestedCollectionRow[numberOfRestrictionsColumn, DataRowVersion.Current]; string collectionName = (requestedCollectionRow[collectionNameColumn, DataRowVersion.Current] as string)!; if ((restrictions != null) && (restrictions.Length > numberOfRestrictions)) { throw ADP.TooManyRestrictions(collectionName); } DbCommand? command = connection.CreateCommand(); command.CommandText = sqlCommand; command.CommandTimeout = System.Math.Max(command.CommandTimeout, 180); DataTable? resultTable = null; for (int i = 0; i < numberOfRestrictions; i++) { DbParameter restrictionParameter = command.CreateParameter(); if ((restrictions != null) && (restrictions.Length > i) && (restrictions[i] != null)) { restrictionParameter.Value = restrictions[i]; } else { // This is where we have to assign null to the value of the parameter. restrictionParameter.Value = DBNull.Value; } restrictionParameter.ParameterName = GetParameterName(collectionName, i + 1); restrictionParameter.Direction = ParameterDirection.Input; command.Parameters.Add(restrictionParameter); } DbDataReader? reader = null; try { try { reader = command.ExecuteReader(); } catch (Exception e) { if (!ADP.IsCatchableExceptionType(e)) { throw; } throw ADP.QueryFailed(collectionName, e); } // TODO: Consider using the DataAdapter.Fill // Build a DataTable from the reader resultTable = new DataTable(collectionName); resultTable.Locale = CultureInfo.InvariantCulture; DataTable? schemaTable = reader.GetSchemaTable(); foreach (DataRow row in schemaTable!.Rows) { resultTable.Columns.Add(row["ColumnName"] as string, (Type)row["DataType"]); } object[] values = new object[resultTable.Columns.Count]; while (reader.Read()) { reader.GetValues(values); resultTable.Rows.Add(values); } } finally { if (reader != null) { reader.Dispose(); } } return resultTable; } private DataColumn[] FilterColumns(DataTable sourceTable, string[]? hiddenColumnNames, DataColumnCollection destinationColumns) { DataColumn newDestinationColumn; int currentColumn; int columnCount = 0; foreach (DataColumn sourceColumn in sourceTable.Columns) { if (IncludeThisColumn(sourceColumn, hiddenColumnNames) == true) { columnCount++; } } if (columnCount == 0) { throw ADP.NoColumns(); } currentColumn = 0; var filteredSourceColumns = new DataColumn[columnCount]; foreach (DataColumn sourceColumn in sourceTable.Columns) { if (IncludeThisColumn(sourceColumn, hiddenColumnNames) == true) { newDestinationColumn = new DataColumn(sourceColumn.ColumnName, sourceColumn.DataType); destinationColumns.Add(newDestinationColumn); filteredSourceColumns[currentColumn] = sourceColumn; currentColumn++; } } return filteredSourceColumns; } internal DataRow FindMetaDataCollectionRow(string collectionName) { bool versionFailure; bool haveExactMatch; bool haveMultipleInexactMatches; string? candidateCollectionName; DataTable? metaDataCollectionsTable = _metaDataCollectionsDataSet.Tables[DbMetaDataCollectionNames.MetaDataCollections]; if (metaDataCollectionsTable == null) { throw ADP.InvalidXml(); } DataColumn? collectionNameColumn = metaDataCollectionsTable.Columns[DbMetaDataColumnNames.CollectionName]; if ((null == collectionNameColumn) || (typeof(string) != collectionNameColumn.DataType)) { throw ADP.InvalidXmlMissingColumn(DbMetaDataCollectionNames.MetaDataCollections, DbMetaDataColumnNames.CollectionName); } DataRow? requestedCollectionRow = null; string? exactCollectionName = null; // find the requested collection versionFailure = false; haveExactMatch = false; haveMultipleInexactMatches = false; foreach (DataRow row in metaDataCollectionsTable.Rows) { candidateCollectionName = row[collectionNameColumn, DataRowVersion.Current] as string; if (ADP.IsEmpty(candidateCollectionName)) { throw ADP.InvalidXmlInvalidValue(DbMetaDataCollectionNames.MetaDataCollections, DbMetaDataColumnNames.CollectionName); } if (ADP.CompareInsensitiveInvariant(candidateCollectionName, collectionName)) { if (SupportedByCurrentVersion(row) == false) { versionFailure = true; } else { if (collectionName == candidateCollectionName) { if (haveExactMatch == true) { throw ADP.CollectionNameIsNotUnique(collectionName); } requestedCollectionRow = row; exactCollectionName = candidateCollectionName; haveExactMatch = true; } else { // have an inexact match - ok only if it is the only one if (exactCollectionName != null) { // can't fail here becasue we may still find an exact match haveMultipleInexactMatches = true; } requestedCollectionRow = row; exactCollectionName = candidateCollectionName; } } } } if (requestedCollectionRow == null) { if (versionFailure == false) { throw ADP.UndefinedCollection(collectionName); } else { throw ADP.UnsupportedVersion(collectionName); } } if ((haveExactMatch == false) && (haveMultipleInexactMatches == true)) { throw ADP.AmbigousCollectionName(collectionName); } return requestedCollectionRow; } private void FixUpVersion(DataTable dataSourceInfoTable) { Debug.Assert(dataSourceInfoTable.TableName == DbMetaDataCollectionNames.DataSourceInformation); DataColumn? versionColumn = dataSourceInfoTable.Columns[_dataSourceProductVersion]; DataColumn? normalizedVersionColumn = dataSourceInfoTable.Columns[_dataSourceProductVersionNormalized]; if ((versionColumn == null) || (normalizedVersionColumn == null)) { throw ADP.MissingDataSourceInformationColumn(); } if (dataSourceInfoTable.Rows.Count != 1) { throw ADP.IncorrectNumberOfDataSourceInformationRows(); } DataRow dataSourceInfoRow = dataSourceInfoTable.Rows[0]; dataSourceInfoRow[versionColumn] = _serverVersionString; dataSourceInfoRow[normalizedVersionColumn] = _normalizedServerVersion; dataSourceInfoRow.AcceptChanges(); } private string GetParameterName(string neededCollectionName, int neededRestrictionNumber) { DataTable? restrictionsTable; DataColumnCollection? restrictionColumns; DataColumn? collectionName = null; DataColumn? parameterName = null; DataColumn? restrictionName = null; DataColumn? restrictionNumber = null; string? result = null; restrictionsTable = _metaDataCollectionsDataSet.Tables[DbMetaDataCollectionNames.Restrictions]; if (restrictionsTable != null) { restrictionColumns = restrictionsTable.Columns; if (restrictionColumns != null) { collectionName = restrictionColumns[_collectionName]; parameterName = restrictionColumns[_parameterName]; restrictionName = restrictionColumns[_restrictionName]; restrictionNumber = restrictionColumns[_restrictionNumber]; } } if ((parameterName == null) || (collectionName == null) || (restrictionName == null) || (restrictionNumber == null)) { throw ADP.MissingRestrictionColumn(); } foreach (DataRow restriction in restrictionsTable!.Rows) { if (((string)restriction[collectionName] == neededCollectionName) && ((int)restriction[restrictionNumber] == neededRestrictionNumber) && (SupportedByCurrentVersion(restriction))) { result = (string)restriction[parameterName]; break; } } if (result == null) { throw ADP.MissingRestrictionRow(); } return result; } public virtual DataTable GetSchema(DbConnection connection, string collectionName, string?[]? restrictions) { Debug.Assert(_metaDataCollectionsDataSet != null); DataTable metaDataCollectionsTable = _metaDataCollectionsDataSet.Tables[DbMetaDataCollectionNames.MetaDataCollections]!; DataColumn populationMechanismColumn = metaDataCollectionsTable.Columns[_populationMechanism]!; DataColumn collectionNameColumn = metaDataCollectionsTable.Columns[DbMetaDataColumnNames.CollectionName]!; string[]? hiddenColumns; DataTable? requestedSchema; DataRow? requestedCollectionRow = FindMetaDataCollectionRow(collectionName); string exactCollectionName = (requestedCollectionRow[collectionNameColumn, DataRowVersion.Current] as string)!; if (ADP.IsEmptyArray(restrictions) == false) { for (int i = 0; i < restrictions!.Length; i++) { if ((restrictions[i]?.Length > 4096)) { // use a non-specific error because no new beta 2 error messages are allowed // TODO: will add a more descriptive error in RTM throw ADP.NotSupported(); } } } string populationMechanism = (requestedCollectionRow[populationMechanismColumn, DataRowVersion.Current] as string)!; switch (populationMechanism) { case _dataTable: if (exactCollectionName == DbMetaDataCollectionNames.MetaDataCollections) { hiddenColumns = new string[2]; hiddenColumns[0] = _populationMechanism; hiddenColumns[1] = _populationString; } else { hiddenColumns = null; } // none of the datatable collections support restrictions if (ADP.IsEmptyArray(restrictions) == false) { throw ADP.TooManyRestrictions(exactCollectionName); } requestedSchema = CloneAndFilterCollection(exactCollectionName, hiddenColumns); // TODO: Consider an alternate method that doesn't involve special casing -- perhaps _prepareCollection // for the data source infomation table we need to fix up the version columns at run time // since the version is determined at run time if (exactCollectionName == DbMetaDataCollectionNames.DataSourceInformation) { FixUpVersion(requestedSchema); } break; case _sqlCommand: requestedSchema = ExecuteCommand(requestedCollectionRow, restrictions, connection); break; case _prepareCollection: requestedSchema = PrepareCollection(exactCollectionName, restrictions, connection); break; default: throw ADP.UndefinedPopulationMechanism(populationMechanism); } return requestedSchema; } private bool IncludeThisColumn(DataColumn sourceColumn, string[]? hiddenColumnNames) { bool result = true; string sourceColumnName = sourceColumn.ColumnName; switch (sourceColumnName) { case _minimumVersion: case _maximumVersion: result = false; break; default: if (hiddenColumnNames == null) { break; } for (int i = 0; i < hiddenColumnNames.Length; i++) { if (hiddenColumnNames[i] == sourceColumnName) { result = false; break; } } break; } return result; } protected virtual DataTable PrepareCollection(string collectionName, string?[]? restrictions, DbConnection connection) { throw ADP.NotSupported(); } private bool SupportedByCurrentVersion(DataRow requestedCollectionRow) { bool result = true; DataColumnCollection tableColumns = requestedCollectionRow.Table.Columns; DataColumn? versionColumn; object version; // check the minimum version first versionColumn = tableColumns[_minimumVersion]; if (versionColumn != null) { version = requestedCollectionRow[versionColumn]; if (version != null) { if (version != DBNull.Value) { if (0 > string.Compare(_normalizedServerVersion, (string)version, StringComparison.OrdinalIgnoreCase)) { result = false; } } } } // if the minmum version was ok what about the maximum version if (result == true) { versionColumn = tableColumns[_maximumVersion]; if (versionColumn != null) { version = requestedCollectionRow[versionColumn]; if (version != null) { if (version != DBNull.Value) { if (0 < string.Compare(_normalizedServerVersion, (string)version, StringComparison.OrdinalIgnoreCase)) { result = false; } } } } } return result; } } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptExportKey.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Runtime.InteropServices; using System.Security.Cryptography; internal static partial class Interop { internal static partial class Advapi32 { [GeneratedDllImport(Libraries.Advapi32, SetLastError = true)] public static partial bool CryptExportKey( SafeCapiKeyHandle hKey, SafeCapiKeyHandle hExpKey, int dwBlobType, int dwFlags, byte[]? pbData, ref int dwDataLen); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Runtime.InteropServices; using System.Security.Cryptography; internal static partial class Interop { internal static partial class Advapi32 { [GeneratedDllImport(Libraries.Advapi32, SetLastError = true)] public static partial bool CryptExportKey( SafeCapiKeyHandle hKey, SafeCapiKeyHandle hExpKey, int dwBlobType, int dwFlags, byte[]? pbData, ref int dwDataLen); } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/libraries/System.Private.Xml/tests/XmlDocument/XmlAttributeCollectionTests/InsertBeforeTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; namespace System.Xml.Tests { public class InsertBeforeTests { private XmlDocument CreateDocumentWithElement() { var doc = new XmlDocument(); doc.AppendChild(doc.CreateElement("root")); return doc; } [Fact] public void InsertBeforeWithSameRefAttrKeepsOrderIntactAndReturnsTheArgument() { XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; XmlAttribute attr1, attr2, attr3; attr1 = element.Attributes.Append(doc.CreateAttribute("attr1")); attr2 = element.Attributes.Append(doc.CreateAttribute("attr2")); attr3 = element.Attributes.Append(doc.CreateAttribute("attr3")); XmlAttributeCollection target = element.Attributes; XmlAttribute result = target.InsertBefore(attr2, attr2); Assert.Equal(3, target.Count); Assert.Same(attr1, target[0]); Assert.Same(attr2, target[1]); Assert.Same(attr3, target[2]); Assert.Same(attr2, result); } [Fact] public void InsertBeforeWithNullRefAttrAddsToTheEnd() { XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; XmlAttribute attr1, attr2, attr3; attr1 = element.Attributes.Append(doc.CreateAttribute("attr1")); attr2 = element.Attributes.Append(doc.CreateAttribute("attr2")); attr3 = doc.CreateAttribute("attr3"); XmlAttributeCollection target = element.Attributes; target.InsertBefore(attr3, null); Assert.Equal(3, target.Count); Assert.Same(attr1, target[0]); Assert.Same(attr2, target[1]); Assert.Same(attr3, target[2]); } [Fact] public void InsertBeforeWithRefAttrWithAnotherOwnerElementThrows() { XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; XmlAttribute newAttr = doc.CreateAttribute("newAttr"); XmlElement anotherElement = doc.CreateElement("anotherElement"); XmlAttribute anotherOwnerElementAttr = anotherElement.SetAttributeNode("anotherOwnerElementAttr", string.Empty); XmlAttributeCollection target = element.Attributes; AssertExtensions.Throws<ArgumentException>(null, () => target.InsertBefore(newAttr, anotherOwnerElementAttr)); } [Fact] public void InsertBeforeWithAttrWithAnotherOwnerDocumentThrows() { XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; XmlAttribute existingAttr = doc.CreateAttribute("existingAttr"); element.Attributes.Append(existingAttr); XmlAttribute anotherOwnerDocumentAttr = new XmlDocument().CreateAttribute("anotherOwnerDocumentAttr"); XmlAttributeCollection target = element.Attributes; AssertExtensions.Throws<ArgumentException>(null, () => target.InsertBefore(anotherOwnerDocumentAttr, existingAttr)); } [Fact] public void InsertBeforeDetachesAttrFromCurrentOwnerElement() { const string attributeName = "movingAttr"; XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; XmlAttribute attr = element.Attributes.Append(doc.CreateAttribute(attributeName)); // assert on implicitly set preconditions Assert.Same(element, attr.OwnerElement); Assert.True(element.HasAttribute(attributeName)); XmlElement destinationElement = doc.CreateElement("anotherElement"); XmlAttribute refAttr = destinationElement.Attributes.Append(doc.CreateAttribute("anotherAttr")); XmlAttributeCollection target = destinationElement.Attributes; target.InsertBefore(attr, refAttr); Assert.Same(destinationElement, attr.OwnerElement); Assert.False(element.HasAttribute(attributeName)); } [Fact] public void InsertBeforeCanInsertBeforeTheFirst() { XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; XmlAttribute refAttr = element.Attributes.Append(doc.CreateAttribute("attr1", "some:uri1")); element.Attributes.Append(doc.CreateAttribute("attr2", "some:uri2")); element.Attributes.Append(doc.CreateAttribute("attr3", "some:uri3")); XmlAttribute newAttr = doc.CreateAttribute("newAttr"); XmlAttributeCollection target = element.Attributes; target.InsertBefore(newAttr, refAttr); Assert.Equal(4, target.Count); Assert.Same(newAttr, target[0]); Assert.Same(refAttr, target[1]); } [Fact] public void InsertBeforeCanInsertBeforeTheLast() { XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; element.Attributes.Append(doc.CreateAttribute("attr1", "some:uri1")); element.Attributes.Append(doc.CreateAttribute("attr2", "some:uri2")); XmlAttribute refAttr = element.Attributes.Append(doc.CreateAttribute("attr3", "some:uri3")); XmlAttribute newAttr = doc.CreateAttribute("newAttr"); XmlAttributeCollection target = element.Attributes; target.InsertBefore(newAttr, refAttr); Assert.Equal(4, target.Count); Assert.Same(newAttr, target[2]); Assert.Same(refAttr, target[3]); } [Fact] public void InsertBeforeCanInsertInTheMiddle() { XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; element.Attributes.Append(doc.CreateAttribute("attr1", "some:uri1")); XmlAttribute refAttr = element.Attributes.Append(doc.CreateAttribute("attr2", "some:uri2")); element.Attributes.Append(doc.CreateAttribute("attr3", "some:uri3")); XmlAttribute newAttr = doc.CreateAttribute("newAttr"); XmlAttributeCollection target = element.Attributes; target.InsertBefore(newAttr, refAttr); Assert.Equal(4, target.Count); Assert.Same(newAttr, target[1]); Assert.Same(refAttr, target[2]); } [Fact] public void InsertBeforeRemovesDupAttrAfterTheRef() { const string attributeName = "existingAttr"; const string attributeUri = "some:existingUri"; XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; XmlAttribute refAttr = element.Attributes.Append(doc.CreateAttribute("attr1", "some:uri1")); element.Attributes.Append(doc.CreateAttribute(attributeName, attributeUri)); //dup XmlAttribute anotherAttr = element.Attributes.Append(doc.CreateAttribute("attr2", "some:uri2")); XmlAttribute newAttr = doc.CreateAttribute(attributeName, attributeUri); XmlAttributeCollection target = element.Attributes; target.InsertBefore(newAttr, refAttr); Assert.Equal(3, target.Count); Assert.Same(newAttr, target[0]); Assert.Same(refAttr, target[1]); Assert.Same(anotherAttr, target[2]); } [Fact] public void InsertBeforeRemovesDupAttrBeforeTheRef() { const string attributeName = "existingAttr"; const string attributeUri = "some:existingUri"; XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; XmlAttribute anotherAttr = element.Attributes.Append(doc.CreateAttribute("attr1", "some:uri1")); element.Attributes.Append(doc.CreateAttribute(attributeName, attributeUri)); //dup XmlAttribute refAttr = element.Attributes.Append(doc.CreateAttribute("attr2", "some:uri2")); XmlAttribute newAttr = doc.CreateAttribute(attributeName, attributeUri); XmlAttributeCollection target = element.Attributes; target.InsertBefore(newAttr, refAttr); Assert.Equal(3, target.Count); Assert.Same(anotherAttr, target[0]); Assert.Same(newAttr, target[1]); Assert.Same(refAttr, target[2]); } [Fact] public void InsertBeforeRemovesDupRefAttr() { const string attributeName = "existingAttr"; const string attributeUri = "some:existingUri"; XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; XmlAttribute refAttr = element.Attributes.Append(doc.CreateAttribute(attributeName, attributeUri)); //dup XmlAttribute anotherAttr1 = element.Attributes.Append(doc.CreateAttribute("attr1", "some:uri1")); XmlAttribute anotherAttr2 = element.Attributes.Append(doc.CreateAttribute("attr2", "some:uri2")); XmlAttribute newAttr = doc.CreateAttribute(attributeName, attributeUri); XmlAttributeCollection target = element.Attributes; target.InsertBefore(newAttr, refAttr); Assert.Equal(3, target.Count); Assert.Same(newAttr, target[0]); Assert.Same(anotherAttr1, target[1]); Assert.Same(anotherAttr2, target[2]); } [Fact] public void InsertBeforeReturnsInsertedAttr() { XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; XmlAttribute refAttr = element.Attributes.Append(doc.CreateAttribute("attr1", "some:uri1")); XmlAttribute newAttr = doc.CreateAttribute("attr2", "some:uri2"); XmlAttributeCollection target = element.Attributes; Assert.Same(newAttr, target.InsertBefore(newAttr, refAttr)); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; namespace System.Xml.Tests { public class InsertBeforeTests { private XmlDocument CreateDocumentWithElement() { var doc = new XmlDocument(); doc.AppendChild(doc.CreateElement("root")); return doc; } [Fact] public void InsertBeforeWithSameRefAttrKeepsOrderIntactAndReturnsTheArgument() { XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; XmlAttribute attr1, attr2, attr3; attr1 = element.Attributes.Append(doc.CreateAttribute("attr1")); attr2 = element.Attributes.Append(doc.CreateAttribute("attr2")); attr3 = element.Attributes.Append(doc.CreateAttribute("attr3")); XmlAttributeCollection target = element.Attributes; XmlAttribute result = target.InsertBefore(attr2, attr2); Assert.Equal(3, target.Count); Assert.Same(attr1, target[0]); Assert.Same(attr2, target[1]); Assert.Same(attr3, target[2]); Assert.Same(attr2, result); } [Fact] public void InsertBeforeWithNullRefAttrAddsToTheEnd() { XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; XmlAttribute attr1, attr2, attr3; attr1 = element.Attributes.Append(doc.CreateAttribute("attr1")); attr2 = element.Attributes.Append(doc.CreateAttribute("attr2")); attr3 = doc.CreateAttribute("attr3"); XmlAttributeCollection target = element.Attributes; target.InsertBefore(attr3, null); Assert.Equal(3, target.Count); Assert.Same(attr1, target[0]); Assert.Same(attr2, target[1]); Assert.Same(attr3, target[2]); } [Fact] public void InsertBeforeWithRefAttrWithAnotherOwnerElementThrows() { XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; XmlAttribute newAttr = doc.CreateAttribute("newAttr"); XmlElement anotherElement = doc.CreateElement("anotherElement"); XmlAttribute anotherOwnerElementAttr = anotherElement.SetAttributeNode("anotherOwnerElementAttr", string.Empty); XmlAttributeCollection target = element.Attributes; AssertExtensions.Throws<ArgumentException>(null, () => target.InsertBefore(newAttr, anotherOwnerElementAttr)); } [Fact] public void InsertBeforeWithAttrWithAnotherOwnerDocumentThrows() { XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; XmlAttribute existingAttr = doc.CreateAttribute("existingAttr"); element.Attributes.Append(existingAttr); XmlAttribute anotherOwnerDocumentAttr = new XmlDocument().CreateAttribute("anotherOwnerDocumentAttr"); XmlAttributeCollection target = element.Attributes; AssertExtensions.Throws<ArgumentException>(null, () => target.InsertBefore(anotherOwnerDocumentAttr, existingAttr)); } [Fact] public void InsertBeforeDetachesAttrFromCurrentOwnerElement() { const string attributeName = "movingAttr"; XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; XmlAttribute attr = element.Attributes.Append(doc.CreateAttribute(attributeName)); // assert on implicitly set preconditions Assert.Same(element, attr.OwnerElement); Assert.True(element.HasAttribute(attributeName)); XmlElement destinationElement = doc.CreateElement("anotherElement"); XmlAttribute refAttr = destinationElement.Attributes.Append(doc.CreateAttribute("anotherAttr")); XmlAttributeCollection target = destinationElement.Attributes; target.InsertBefore(attr, refAttr); Assert.Same(destinationElement, attr.OwnerElement); Assert.False(element.HasAttribute(attributeName)); } [Fact] public void InsertBeforeCanInsertBeforeTheFirst() { XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; XmlAttribute refAttr = element.Attributes.Append(doc.CreateAttribute("attr1", "some:uri1")); element.Attributes.Append(doc.CreateAttribute("attr2", "some:uri2")); element.Attributes.Append(doc.CreateAttribute("attr3", "some:uri3")); XmlAttribute newAttr = doc.CreateAttribute("newAttr"); XmlAttributeCollection target = element.Attributes; target.InsertBefore(newAttr, refAttr); Assert.Equal(4, target.Count); Assert.Same(newAttr, target[0]); Assert.Same(refAttr, target[1]); } [Fact] public void InsertBeforeCanInsertBeforeTheLast() { XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; element.Attributes.Append(doc.CreateAttribute("attr1", "some:uri1")); element.Attributes.Append(doc.CreateAttribute("attr2", "some:uri2")); XmlAttribute refAttr = element.Attributes.Append(doc.CreateAttribute("attr3", "some:uri3")); XmlAttribute newAttr = doc.CreateAttribute("newAttr"); XmlAttributeCollection target = element.Attributes; target.InsertBefore(newAttr, refAttr); Assert.Equal(4, target.Count); Assert.Same(newAttr, target[2]); Assert.Same(refAttr, target[3]); } [Fact] public void InsertBeforeCanInsertInTheMiddle() { XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; element.Attributes.Append(doc.CreateAttribute("attr1", "some:uri1")); XmlAttribute refAttr = element.Attributes.Append(doc.CreateAttribute("attr2", "some:uri2")); element.Attributes.Append(doc.CreateAttribute("attr3", "some:uri3")); XmlAttribute newAttr = doc.CreateAttribute("newAttr"); XmlAttributeCollection target = element.Attributes; target.InsertBefore(newAttr, refAttr); Assert.Equal(4, target.Count); Assert.Same(newAttr, target[1]); Assert.Same(refAttr, target[2]); } [Fact] public void InsertBeforeRemovesDupAttrAfterTheRef() { const string attributeName = "existingAttr"; const string attributeUri = "some:existingUri"; XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; XmlAttribute refAttr = element.Attributes.Append(doc.CreateAttribute("attr1", "some:uri1")); element.Attributes.Append(doc.CreateAttribute(attributeName, attributeUri)); //dup XmlAttribute anotherAttr = element.Attributes.Append(doc.CreateAttribute("attr2", "some:uri2")); XmlAttribute newAttr = doc.CreateAttribute(attributeName, attributeUri); XmlAttributeCollection target = element.Attributes; target.InsertBefore(newAttr, refAttr); Assert.Equal(3, target.Count); Assert.Same(newAttr, target[0]); Assert.Same(refAttr, target[1]); Assert.Same(anotherAttr, target[2]); } [Fact] public void InsertBeforeRemovesDupAttrBeforeTheRef() { const string attributeName = "existingAttr"; const string attributeUri = "some:existingUri"; XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; XmlAttribute anotherAttr = element.Attributes.Append(doc.CreateAttribute("attr1", "some:uri1")); element.Attributes.Append(doc.CreateAttribute(attributeName, attributeUri)); //dup XmlAttribute refAttr = element.Attributes.Append(doc.CreateAttribute("attr2", "some:uri2")); XmlAttribute newAttr = doc.CreateAttribute(attributeName, attributeUri); XmlAttributeCollection target = element.Attributes; target.InsertBefore(newAttr, refAttr); Assert.Equal(3, target.Count); Assert.Same(anotherAttr, target[0]); Assert.Same(newAttr, target[1]); Assert.Same(refAttr, target[2]); } [Fact] public void InsertBeforeRemovesDupRefAttr() { const string attributeName = "existingAttr"; const string attributeUri = "some:existingUri"; XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; XmlAttribute refAttr = element.Attributes.Append(doc.CreateAttribute(attributeName, attributeUri)); //dup XmlAttribute anotherAttr1 = element.Attributes.Append(doc.CreateAttribute("attr1", "some:uri1")); XmlAttribute anotherAttr2 = element.Attributes.Append(doc.CreateAttribute("attr2", "some:uri2")); XmlAttribute newAttr = doc.CreateAttribute(attributeName, attributeUri); XmlAttributeCollection target = element.Attributes; target.InsertBefore(newAttr, refAttr); Assert.Equal(3, target.Count); Assert.Same(newAttr, target[0]); Assert.Same(anotherAttr1, target[1]); Assert.Same(anotherAttr2, target[2]); } [Fact] public void InsertBeforeReturnsInsertedAttr() { XmlDocument doc = CreateDocumentWithElement(); XmlElement element = doc.DocumentElement; XmlAttribute refAttr = element.Attributes.Append(doc.CreateAttribute("attr1", "some:uri1")); XmlAttribute newAttr = doc.CreateAttribute("attr2", "some:uri2"); XmlAttributeCollection target = element.Attributes; Assert.Same(newAttr, target.InsertBefore(newAttr, refAttr)); } } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/mono/mono/tests/generic-method-patching.2.cs
using System; using System.Collections.Generic; public class MyDict<S,T> { public void Add (S key, T value) { S[] sa = new S[1]; T[] ta = new T[1]; sa[0] = key; ta[0] = value; } } public abstract class FastFunc<S,T> { public abstract S Invoke (T bla); } public class StringFastFunc : FastFunc<string, int> { public override string Invoke (int bla) { return bla.ToString (); } } public class ArrayFastFunc : FastFunc<byte [], int> { public override byte [] Invoke (int bla) { return new byte [bla]; } } public class IntCache<T> { MyDict<int,T> cache; public T Invoke (FastFunc<T,int> f, int bla) { if (cache == null) cache = new MyDict <int,T> (); T value = f.Invoke (bla); cache.Add (bla, value); return value; } } public class main { public static int Main () { StringFastFunc sff = new StringFastFunc (); ArrayFastFunc aff = new ArrayFastFunc (); IntCache<string> ics = new IntCache<string> (); MyDict<string,string> dss = new MyDict<string,string> (); dss.Add ("123", "456"); ics.Invoke (sff, 123); ics.Invoke (sff, 456); IntCache<byte []> ica = new IntCache<byte []> (); ica.Invoke (aff, 1); ica.Invoke (aff, 2); ica.Invoke (aff, 3); return 0; } }
using System; using System.Collections.Generic; public class MyDict<S,T> { public void Add (S key, T value) { S[] sa = new S[1]; T[] ta = new T[1]; sa[0] = key; ta[0] = value; } } public abstract class FastFunc<S,T> { public abstract S Invoke (T bla); } public class StringFastFunc : FastFunc<string, int> { public override string Invoke (int bla) { return bla.ToString (); } } public class ArrayFastFunc : FastFunc<byte [], int> { public override byte [] Invoke (int bla) { return new byte [bla]; } } public class IntCache<T> { MyDict<int,T> cache; public T Invoke (FastFunc<T,int> f, int bla) { if (cache == null) cache = new MyDict <int,T> (); T value = f.Invoke (bla); cache.Add (bla, value); return value; } } public class main { public static int Main () { StringFastFunc sff = new StringFastFunc (); ArrayFastFunc aff = new ArrayFastFunc (); IntCache<string> ics = new IntCache<string> (); MyDict<string,string> dss = new MyDict<string,string> (); dss.Add ("123", "456"); ics.Invoke (sff, 123); ics.Invoke (sff, 456); IntCache<byte []> ica = new IntCache<byte []> (); ica.Invoke (aff, 1); ica.Invoke (aff, 2); ica.Invoke (aff, 3); return 0; } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/ExtractNarrowingUpper.Vector128.Int32.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void ExtractNarrowingUpper_Vector128_Int32() { var test = new SimpleBinaryOpTest__ExtractNarrowingUpper_Vector128_Int32(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleBinaryOpTest__ExtractNarrowingUpper_Vector128_Int32 { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Int32[] inArray1, Int64[] inArray2, Int32[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int32>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Int64>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int32>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Int32, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Int64, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector64<Int32> _fld1; public Vector128<Int64> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref testStruct._fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref testStruct._fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__ExtractNarrowingUpper_Vector128_Int32 testClass) { var result = AdvSimd.ExtractNarrowingUpper(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__ExtractNarrowingUpper_Vector128_Int32 testClass) { fixed (Vector64<Int32>* pFld1 = &_fld1) fixed (Vector128<Int64>* pFld2 = &_fld2) { var result = AdvSimd.ExtractNarrowingUpper( AdvSimd.LoadVector64((Int32*)(pFld1)), AdvSimd.LoadVector128((Int64*)(pFld2)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector64<Int32>>() / sizeof(Int32); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int32>>() / sizeof(Int32); private static Int32[] _data1 = new Int32[Op1ElementCount]; private static Int64[] _data2 = new Int64[Op2ElementCount]; private static Vector64<Int32> _clsVar1; private static Vector128<Int64> _clsVar2; private Vector64<Int32> _fld1; private Vector128<Int64> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__ExtractNarrowingUpper_Vector128_Int32() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); } public SimpleBinaryOpTest__ExtractNarrowingUpper_Vector128_Int32() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } _dataTable = new DataTable(_data1, _data2, new Int32[RetElementCount], LargestVectorSize); } public bool IsSupported => AdvSimd.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = AdvSimd.ExtractNarrowingUpper( Unsafe.Read<Vector64<Int32>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Int64>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = AdvSimd.ExtractNarrowingUpper( AdvSimd.LoadVector64((Int32*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Int64*)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.ExtractNarrowingUpper), new Type[] { typeof(Vector64<Int32>), typeof(Vector128<Int64>) }) .Invoke(null, new object[] { Unsafe.Read<Vector64<Int32>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Int64>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.ExtractNarrowingUpper), new Type[] { typeof(Vector64<Int32>), typeof(Vector128<Int64>) }) .Invoke(null, new object[] { AdvSimd.LoadVector64((Int32*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Int64*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.ExtractNarrowingUpper( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector64<Int32>* pClsVar1 = &_clsVar1) fixed (Vector128<Int64>* pClsVar2 = &_clsVar2) { var result = AdvSimd.ExtractNarrowingUpper( AdvSimd.LoadVector64((Int32*)(pClsVar1)), AdvSimd.LoadVector128((Int64*)(pClsVar2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector64<Int32>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Int64>>(_dataTable.inArray2Ptr); var result = AdvSimd.ExtractNarrowingUpper(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector64((Int32*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((Int64*)(_dataTable.inArray2Ptr)); var result = AdvSimd.ExtractNarrowingUpper(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__ExtractNarrowingUpper_Vector128_Int32(); var result = AdvSimd.ExtractNarrowingUpper(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleBinaryOpTest__ExtractNarrowingUpper_Vector128_Int32(); fixed (Vector64<Int32>* pFld1 = &test._fld1) fixed (Vector128<Int64>* pFld2 = &test._fld2) { var result = AdvSimd.ExtractNarrowingUpper( AdvSimd.LoadVector64((Int32*)(pFld1)), AdvSimd.LoadVector128((Int64*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.ExtractNarrowingUpper(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector64<Int32>* pFld1 = &_fld1) fixed (Vector128<Int64>* pFld2 = &_fld2) { var result = AdvSimd.ExtractNarrowingUpper( AdvSimd.LoadVector64((Int32*)(pFld1)), AdvSimd.LoadVector128((Int64*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = AdvSimd.ExtractNarrowingUpper(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = AdvSimd.ExtractNarrowingUpper( AdvSimd.LoadVector64((Int32*)(&test._fld1)), AdvSimd.LoadVector128((Int64*)(&test._fld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector64<Int32> op1, Vector128<Int64> op2, void* result, [CallerMemberName] string method = "") { Int32[] inArray1 = new Int32[Op1ElementCount]; Int64[] inArray2 = new Int64[Op2ElementCount]; Int32[] outArray = new Int32[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Int32[] inArray1 = new Int32[Op1ElementCount]; Int64[] inArray2 = new Int64[Op2ElementCount]; Int32[] outArray = new Int32[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector64<Int32>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Int64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Int32[] left, Int64[] right, Int32[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.ExtractNarrowingUpper(left, right, i) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.ExtractNarrowingUpper)}<Int32>(Vector64<Int32>, Vector128<Int64>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void ExtractNarrowingUpper_Vector128_Int32() { var test = new SimpleBinaryOpTest__ExtractNarrowingUpper_Vector128_Int32(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleBinaryOpTest__ExtractNarrowingUpper_Vector128_Int32 { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Int32[] inArray1, Int64[] inArray2, Int32[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int32>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Int64>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int32>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Int32, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Int64, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector64<Int32> _fld1; public Vector128<Int64> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref testStruct._fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref testStruct._fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__ExtractNarrowingUpper_Vector128_Int32 testClass) { var result = AdvSimd.ExtractNarrowingUpper(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__ExtractNarrowingUpper_Vector128_Int32 testClass) { fixed (Vector64<Int32>* pFld1 = &_fld1) fixed (Vector128<Int64>* pFld2 = &_fld2) { var result = AdvSimd.ExtractNarrowingUpper( AdvSimd.LoadVector64((Int32*)(pFld1)), AdvSimd.LoadVector128((Int64*)(pFld2)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector64<Int32>>() / sizeof(Int32); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int32>>() / sizeof(Int32); private static Int32[] _data1 = new Int32[Op1ElementCount]; private static Int64[] _data2 = new Int64[Op2ElementCount]; private static Vector64<Int32> _clsVar1; private static Vector128<Int64> _clsVar2; private Vector64<Int32> _fld1; private Vector128<Int64> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__ExtractNarrowingUpper_Vector128_Int32() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); } public SimpleBinaryOpTest__ExtractNarrowingUpper_Vector128_Int32() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } _dataTable = new DataTable(_data1, _data2, new Int32[RetElementCount], LargestVectorSize); } public bool IsSupported => AdvSimd.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = AdvSimd.ExtractNarrowingUpper( Unsafe.Read<Vector64<Int32>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Int64>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = AdvSimd.ExtractNarrowingUpper( AdvSimd.LoadVector64((Int32*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Int64*)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.ExtractNarrowingUpper), new Type[] { typeof(Vector64<Int32>), typeof(Vector128<Int64>) }) .Invoke(null, new object[] { Unsafe.Read<Vector64<Int32>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Int64>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.ExtractNarrowingUpper), new Type[] { typeof(Vector64<Int32>), typeof(Vector128<Int64>) }) .Invoke(null, new object[] { AdvSimd.LoadVector64((Int32*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Int64*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.ExtractNarrowingUpper( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector64<Int32>* pClsVar1 = &_clsVar1) fixed (Vector128<Int64>* pClsVar2 = &_clsVar2) { var result = AdvSimd.ExtractNarrowingUpper( AdvSimd.LoadVector64((Int32*)(pClsVar1)), AdvSimd.LoadVector128((Int64*)(pClsVar2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector64<Int32>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Int64>>(_dataTable.inArray2Ptr); var result = AdvSimd.ExtractNarrowingUpper(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector64((Int32*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((Int64*)(_dataTable.inArray2Ptr)); var result = AdvSimd.ExtractNarrowingUpper(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__ExtractNarrowingUpper_Vector128_Int32(); var result = AdvSimd.ExtractNarrowingUpper(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleBinaryOpTest__ExtractNarrowingUpper_Vector128_Int32(); fixed (Vector64<Int32>* pFld1 = &test._fld1) fixed (Vector128<Int64>* pFld2 = &test._fld2) { var result = AdvSimd.ExtractNarrowingUpper( AdvSimd.LoadVector64((Int32*)(pFld1)), AdvSimd.LoadVector128((Int64*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.ExtractNarrowingUpper(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector64<Int32>* pFld1 = &_fld1) fixed (Vector128<Int64>* pFld2 = &_fld2) { var result = AdvSimd.ExtractNarrowingUpper( AdvSimd.LoadVector64((Int32*)(pFld1)), AdvSimd.LoadVector128((Int64*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = AdvSimd.ExtractNarrowingUpper(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = AdvSimd.ExtractNarrowingUpper( AdvSimd.LoadVector64((Int32*)(&test._fld1)), AdvSimd.LoadVector128((Int64*)(&test._fld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector64<Int32> op1, Vector128<Int64> op2, void* result, [CallerMemberName] string method = "") { Int32[] inArray1 = new Int32[Op1ElementCount]; Int64[] inArray2 = new Int64[Op2ElementCount]; Int32[] outArray = new Int32[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Int32[] inArray1 = new Int32[Op1ElementCount]; Int64[] inArray2 = new Int64[Op2ElementCount]; Int32[] outArray = new Int32[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector64<Int32>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Int64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Int32[] left, Int64[] right, Int32[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.ExtractNarrowingUpper(left, right, i) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.ExtractNarrowingUpper)}<Int32>(Vector64<Int32>, Vector128<Int64>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/libraries/System.Linq.Expressions/tests/DelegateType/DelegateCreationTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; namespace System.Linq.Expressions.Tests { public abstract class DelegateCreationTests { public static IEnumerable<object[]> ValidTypeArgs(bool includesReturnType) { for (int i = 1; i <= (includesReturnType ? 17 : 16); ++i) { yield return new object[] { Enumerable.Repeat(typeof(bool), i).ToArray() }; } yield return new object[] { new[] { typeof(int) } }; yield return new object[] { new[] { typeof(int), typeof(string) } }; yield return new object[] { new[] { typeof(string), typeof(int), typeof(decimal) } }; yield return new object[] { new[] { typeof(string), typeof(int), typeof(decimal), typeof(float) } }; yield return new object[] { new[] { typeof(NWindProxy.Customer), typeof(string), typeof(int), typeof(decimal), typeof(float) } }; } public static IEnumerable<object[]> OpenGenericTypeArgs(bool includesReturnType) { for (int i = 1; i <= (includesReturnType ? 17 : 16); ++i) { yield return new object[] { Enumerable.Repeat(typeof(List<>).MakeGenericType(typeof(List<>).GetGenericArguments()), i).ToArray() }; } } public static IEnumerable<object[]> ExcessiveLengthTypeArgs() { yield return new object[] { Enumerable.Repeat(typeof(int), 18).ToArray() }; } public static IEnumerable<object[]> ExcessiveLengthOpenGenericTypeArgs() { yield return new object[] { Enumerable.Repeat(typeof(List<int>), 18).ToArray() }; } public static IEnumerable<object[]> EmptyTypeArgs() { yield return new object[] { Type.EmptyTypes }; } public static IEnumerable<object[]> ByRefTypeArgs() { yield return new object[] { new[] { typeof(int), typeof(int).MakeByRefType(), typeof(string) } }; yield return new object[] { new[] { typeof(int).MakeByRefType() } }; yield return new object[] { Enumerable.Repeat(typeof(double).MakeByRefType(), 20).ToArray() }; } public static IEnumerable<object[]> ByRefLikeTypeArgs() { yield return new object[] { new[] { typeof(Span<char>) } }; } public static IEnumerable<object[]> PointerTypeArgs() { yield return new object[] { new[] { typeof(int).MakePointerType() } }; yield return new object[] { new[] { typeof(string), typeof(double).MakePointerType(), typeof(int) } }; yield return new object[] { Enumerable.Repeat(typeof(int).MakePointerType(), 20).ToArray() }; } public static IEnumerable<object[]> ManagedPointerTypeArgs() { yield return new object[] { new[] { typeof(string).MakePointerType() } }; yield return new object[] { new[] { typeof(int), typeof(string).MakePointerType(), typeof(double) } }; yield return new object[] { Enumerable.Repeat(typeof(string).MakePointerType(), 20).ToArray() }; } public static IEnumerable<object[]> VoidTypeArgs(bool includeSingleVoid) { if (includeSingleVoid) { yield return new object[] { new[] { typeof(void) } }; } yield return new object[] { new[] { typeof(string), typeof(void), typeof(int) } }; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; namespace System.Linq.Expressions.Tests { public abstract class DelegateCreationTests { public static IEnumerable<object[]> ValidTypeArgs(bool includesReturnType) { for (int i = 1; i <= (includesReturnType ? 17 : 16); ++i) { yield return new object[] { Enumerable.Repeat(typeof(bool), i).ToArray() }; } yield return new object[] { new[] { typeof(int) } }; yield return new object[] { new[] { typeof(int), typeof(string) } }; yield return new object[] { new[] { typeof(string), typeof(int), typeof(decimal) } }; yield return new object[] { new[] { typeof(string), typeof(int), typeof(decimal), typeof(float) } }; yield return new object[] { new[] { typeof(NWindProxy.Customer), typeof(string), typeof(int), typeof(decimal), typeof(float) } }; } public static IEnumerable<object[]> OpenGenericTypeArgs(bool includesReturnType) { for (int i = 1; i <= (includesReturnType ? 17 : 16); ++i) { yield return new object[] { Enumerable.Repeat(typeof(List<>).MakeGenericType(typeof(List<>).GetGenericArguments()), i).ToArray() }; } } public static IEnumerable<object[]> ExcessiveLengthTypeArgs() { yield return new object[] { Enumerable.Repeat(typeof(int), 18).ToArray() }; } public static IEnumerable<object[]> ExcessiveLengthOpenGenericTypeArgs() { yield return new object[] { Enumerable.Repeat(typeof(List<int>), 18).ToArray() }; } public static IEnumerable<object[]> EmptyTypeArgs() { yield return new object[] { Type.EmptyTypes }; } public static IEnumerable<object[]> ByRefTypeArgs() { yield return new object[] { new[] { typeof(int), typeof(int).MakeByRefType(), typeof(string) } }; yield return new object[] { new[] { typeof(int).MakeByRefType() } }; yield return new object[] { Enumerable.Repeat(typeof(double).MakeByRefType(), 20).ToArray() }; } public static IEnumerable<object[]> ByRefLikeTypeArgs() { yield return new object[] { new[] { typeof(Span<char>) } }; } public static IEnumerable<object[]> PointerTypeArgs() { yield return new object[] { new[] { typeof(int).MakePointerType() } }; yield return new object[] { new[] { typeof(string), typeof(double).MakePointerType(), typeof(int) } }; yield return new object[] { Enumerable.Repeat(typeof(int).MakePointerType(), 20).ToArray() }; } public static IEnumerable<object[]> ManagedPointerTypeArgs() { yield return new object[] { new[] { typeof(string).MakePointerType() } }; yield return new object[] { new[] { typeof(int), typeof(string).MakePointerType(), typeof(double) } }; yield return new object[] { Enumerable.Repeat(typeof(string).MakePointerType(), 20).ToArray() }; } public static IEnumerable<object[]> VoidTypeArgs(bool includeSingleVoid) { if (includeSingleVoid) { yield return new object[] { new[] { typeof(void) } }; } yield return new object[] { new[] { typeof(string), typeof(void), typeof(int) } }; } } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/libraries/System.Memory/tests/ReadOnlyBuffer/ReadOnlySequenceTests.Common.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Buffers; using System.Collections.Generic; using System.Linq; using System.MemoryTests; using System.Text; using Xunit; namespace System.Memory.Tests { public abstract class ReadOnlySequenceTestsCommon<T> { #region Position [Fact] public void SegmentStartIsConsideredInBoundsCheck() { // 0 50 100 0 50 100 // [ ##############] -> [############## ] // ^c1 ^c2 var bufferSegment1 = new BufferSegment<T>(new T[49]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[50]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment2, 50); SequencePosition c1 = buffer.GetPosition(25); // segment 1 index 75 SequencePosition c2 = buffer.GetPosition(55); // segment 2 index 5 ReadOnlySequence<T> sliced = buffer.Slice(c1, c2); Assert.Equal(30, sliced.Length); c1 = buffer.GetPosition(25, buffer.Start); // segment 1 index 75 c2 = buffer.GetPosition(55, buffer.Start); // segment 2 index 5 sliced = buffer.Slice(c1, c2); Assert.Equal(30, sliced.Length); } [Fact] public void GetPositionPrefersNextSegment() { BufferSegment<T> bufferSegment1 = new BufferSegment<T>(new T[50]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[0]); ReadOnlySequence<T> buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment2, 0); SequencePosition c1 = buffer.GetPosition(50); Assert.Equal(0, c1.GetInteger()); Assert.Equal(bufferSegment2, c1.GetObject()); c1 = buffer.GetPosition(50, buffer.Start); Assert.Equal(0, c1.GetInteger()); Assert.Equal(bufferSegment2, c1.GetObject()); } [Fact] public void GetPositionDoesNotCrossOutsideBuffer() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[100]); BufferSegment<T> bufferSegment3 = bufferSegment2.Append(new T[0]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment2, 100); SequencePosition c1 = buffer.GetPosition(200); Assert.Equal(100, c1.GetInteger()); Assert.Equal(bufferSegment2, c1.GetObject()); c1 = buffer.GetPosition(200, buffer.Start); Assert.Equal(100, c1.GetInteger()); Assert.Equal(bufferSegment2, c1.GetObject()); } [Fact] public void CheckEndReachableDoesNotCrossPastEnd() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[100]); BufferSegment<T> bufferSegment3 = bufferSegment2.Append(new T[100]); BufferSegment<T> bufferSegment4 = bufferSegment3.Append(new T[100]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment4, 100); SequencePosition c1 = buffer.GetPosition(200); Assert.Equal(0, c1.GetInteger()); Assert.Equal(bufferSegment3, c1.GetObject()); ReadOnlySequence<T> seq = buffer.Slice(0, c1); Assert.Equal(200, seq.Length); c1 = buffer.GetPosition(200, buffer.Start); Assert.Equal(0, c1.GetInteger()); Assert.Equal(bufferSegment3, c1.GetObject()); seq = buffer.Slice(0, c1); Assert.Equal(200, seq.Length); } #endregion #region Offset [Fact] public void GetOffset_SingleSegment() { var buffer = new ReadOnlySequence<T>(new T[50]); Assert.Equal(25, buffer.GetOffset(buffer.GetPosition(25))); } private (BufferSegment<T> bufferSegment1, BufferSegment<T> bufferSegment4) GetBufferSegment() { // [50] -> [50] -> [0] -> [50] var bufferSegment1 = new BufferSegment<T>(new T[50]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[50]); BufferSegment<T> bufferSegment3 = bufferSegment2.Append(new T[0]); return (bufferSegment1, bufferSegment3.Append(new T[50])); } private ReadOnlySequence<T> GetFourSegmentsReadOnlySequence() { (BufferSegment<T> bufferSegment1, BufferSegment<T> bufferSegment4) = GetBufferSegment(); return new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment4, 50); } [Fact] public void GetOffset_MultiSegment_FirstSegment() { ReadOnlySequence<T> buffer = GetFourSegmentsReadOnlySequence(); Assert.Equal(25, buffer.GetOffset(buffer.GetPosition(25))); } [Fact] public void GetOffset_MultiSegment_LastSegment() { ReadOnlySequence<T> buffer = GetFourSegmentsReadOnlySequence(); Assert.Equal(125, buffer.GetOffset(buffer.GetPosition(125))); } [Fact] public void GetOffset_MultiSegment_MiddleSegment() { ReadOnlySequence<T> buffer = GetFourSegmentsReadOnlySequence(); Assert.Equal(75, buffer.GetOffset(buffer.GetPosition(75))); } [Fact] public void GetOffset_SingleSegment_NullPositionObject() { var buffer = new ReadOnlySequence<T>(new T[50]); Assert.Equal(0, buffer.GetOffset(new SequencePosition(null, 25))); } [Fact] public void GetOffset_MultiSegment_NullPositionObject() { ReadOnlySequence<T> buffer = GetFourSegmentsReadOnlySequence(); Assert.Equal(0, buffer.GetOffset(new SequencePosition(null, 25))); } [Fact] public void GetOffset_MultiSegment_BoundaryConditions() { // [50] -> [50] -> [0] -> [50] var bufferSegment1 = new BufferSegment<T>(new T[50]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[50]); BufferSegment<T> bufferSegment3 = bufferSegment2.Append(new T[0]); BufferSegment<T> bufferSegment4 = bufferSegment3.Append(new T[50]); var sequence = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment4, 50); // Non empty adjacent segment Assert.Equal(50, sequence.GetOffset(new SequencePosition(bufferSegment1, 50))); Assert.Equal(50, sequence.GetOffset(new SequencePosition(bufferSegment2, 0))); Assert.Equal(51, sequence.GetOffset(new SequencePosition(bufferSegment2, 1))); // Empty adjacent segment Assert.Equal(100, sequence.GetOffset(new SequencePosition(bufferSegment2, 50))); Assert.Equal(100, sequence.GetOffset(new SequencePosition(bufferSegment3, 0))); Assert.Equal(101, sequence.GetOffset(new SequencePosition(bufferSegment4, 1))); // Cannot get 101 starting from empty adjacent segment Assert.Throws<ArgumentOutOfRangeException>(() => sequence.GetOffset(new SequencePosition(bufferSegment3, 1))); } [Fact] public void GetOffset_MultiSegment_Enumerate() { ReadOnlySequence<T> buffer = GetFourSegmentsReadOnlySequence(); for (int i = 0; i <= buffer.Length; i++) { Assert.Equal(i, buffer.GetOffset(buffer.GetPosition(i))); } } [Fact] public void GetOffset_SingleSegment_Enumerate() { ReadOnlySequence<T> buffer = new ReadOnlySequence<T>(new T[50]); for (int i = 0; i <= buffer.Length; i++) { Assert.Equal(i, buffer.GetOffset(buffer.GetPosition(i))); } } [Fact] public void GetOffset_MultiSegment_Slice() { ReadOnlySequence<T> buffer = GetFourSegmentsReadOnlySequence(); for (int i = 0; i <= buffer.Length; i++) { Assert.Equal(buffer.Slice(0, i).Length, buffer.GetOffset(buffer.GetPosition(i))); } } [Fact] public void GetOffset_SingleSegment_Slice() { ReadOnlySequence<T> buffer = new ReadOnlySequence<T>(new T[50]); for (int i = 0; i <= buffer.Length; i++) { Assert.Equal(buffer.Slice(0, i).Length, buffer.GetOffset(buffer.GetPosition(i))); } } [Fact] public void GetOffset_SingleSegment_PositionOutOfRange() { var positionObject = new T[50]; var buffer = new ReadOnlySequence<T>(positionObject); Assert.Throws<ArgumentOutOfRangeException>("position", () => buffer.GetOffset(new SequencePosition(positionObject, 75))); } [Fact] public void GetOffset_MultiSegment_PositionOutOfRange() { (BufferSegment<T> bufferSegment1, BufferSegment<T> bufferSegment4) = GetBufferSegment(); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment4, 50); Assert.Throws<ArgumentOutOfRangeException>("position", () => buffer.GetOffset(new SequencePosition(bufferSegment4, 200))); } [Fact] public void GetOffset_MultiSegment_PositionOutOfRange_SegmentNotFound() { ReadOnlySequence<T> buffer = GetFourSegmentsReadOnlySequence(); ReadOnlySequence<T> buffer2 = GetFourSegmentsReadOnlySequence(); Assert.Throws<ArgumentOutOfRangeException>("position", () => buffer.GetOffset(buffer2.GetPosition(25))); } [Fact] public void GetOffset_MultiSegment_InvalidSequencePositionSegment() { ReadOnlySequence<T> buffer = GetFourSegmentsReadOnlySequence(); ReadOnlySequence<T> buffer2 = new ReadOnlySequence<T>(new T[50]); Assert.Throws<InvalidCastException>(() => buffer.GetOffset(buffer2.GetPosition(25))); } [Fact] public void GetOffset_SingleSegment_SequencePositionSegment() { var data = new T[0]; var sequence = new ReadOnlySequence<T>(data); Assert.Equal(0, sequence.GetOffset(new SequencePosition(data, 0))); // Invalid positions Assert.Throws<ArgumentOutOfRangeException>(() => sequence.GetOffset(new SequencePosition(data, 1))); } [Fact] public void GetOffset_MultiSegment_SequencePositionSegment() { // [0] -> [0] -> [0] -> [50] var bufferSegment1 = new BufferSegment<T>(new T[0]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[0]); BufferSegment<T> bufferSegment3 = bufferSegment2.Append(new T[0]); BufferSegment<T> bufferSegment4 = bufferSegment3.Append(new T[50]); var sequence = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment4, 50); Assert.Equal(0, sequence.GetOffset(new SequencePosition(bufferSegment1, 0))); Assert.Equal(0, sequence.GetOffset(new SequencePosition(bufferSegment2, 0))); Assert.Equal(0, sequence.GetOffset(new SequencePosition(bufferSegment3, 0))); Assert.Equal(0, sequence.GetOffset(new SequencePosition(bufferSegment4, 0))); // Invalid positions Assert.Throws<ArgumentOutOfRangeException>(() => sequence.GetOffset(new SequencePosition(bufferSegment1, 1))); Assert.Throws<ArgumentOutOfRangeException>(() => sequence.GetOffset(new SequencePosition(bufferSegment2, 1))); Assert.Throws<ArgumentOutOfRangeException>(() => sequence.GetOffset(new SequencePosition(bufferSegment3, 1))); for (int i = 0; i <= bufferSegment4.Memory.Length; i++) { Assert.Equal(i, sequence.GetOffset(new SequencePosition(bufferSegment4, i))); } } #endregion #region First [Fact] public void AsArray_CanGetFirst() { var memory = new ReadOnlyMemory<T>(new T[5]); VerifyCanGetFirst(new ReadOnlySequence<T>(memory), expectedSize: 5); } [Fact] public void AsMemoryManager_CanGetFirst() { MemoryManager<T> manager = new CustomMemoryForTest<T>(new T[5]); ReadOnlyMemory<T> memoryFromManager = ((ReadOnlyMemory<T>)manager.Memory); VerifyCanGetFirst(new ReadOnlySequence<T>(memoryFromManager), expectedSize: 5); } [Fact] public void AsMultiSegment_CanGetFirst() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[100]); BufferSegment<T> bufferSegment3 = bufferSegment2.Append(new T[100]); BufferSegment<T> bufferSegment4 = bufferSegment3.Append(new T[200]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment4, 200); // Verify first 3 segments Assert.Equal(500, buffer.Length); int length = 500; for (int s = 0; s < 3; s++) { for (int i = 100; i > 0; i--) { Assert.Equal(i, buffer.First.Length); Assert.Equal(i, buffer.FirstSpan.Length); buffer = buffer.Slice(1); length--; Assert.Equal(length, buffer.Length); } } // Verify last segment VerifyCanGetFirst(buffer, expectedSize: 200); } protected void VerifyCanGetFirst(ReadOnlySequence<T> buffer, int expectedSize) { Assert.Equal(expectedSize, buffer.Length); int length = expectedSize; for (int i = length; i > 0; i--) { Assert.Equal(i, buffer.First.Length); Assert.Equal(i, buffer.FirstSpan.Length); buffer = buffer.Slice(1); length--; Assert.Equal(length, buffer.Length); } Assert.Equal(0, buffer.Length); Assert.Equal(0, buffer.First.Length); Assert.Equal(0, buffer.FirstSpan.Length); } #endregion #region EmptySegments [Fact] public void SeekSkipsEmptySegments() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[0]); BufferSegment<T> bufferSegment3 = bufferSegment2.Append(new T[0]); BufferSegment<T> bufferSegment4 = bufferSegment3.Append(new T[100]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment4, 100); SequencePosition c1 = buffer.GetPosition(100); Assert.Equal(0, c1.GetInteger()); Assert.Equal(bufferSegment4, c1.GetObject()); c1 = buffer.GetPosition(100, buffer.Start); Assert.Equal(0, c1.GetInteger()); Assert.Equal(bufferSegment4, c1.GetObject()); } [Fact] public void TryGetReturnsEmptySegments() { var bufferSegment1 = new BufferSegment<T>(new T[0]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[0]); BufferSegment<T> bufferSegment3 = bufferSegment2.Append(new T[0]); BufferSegment<T> bufferSegment4 = bufferSegment3.Append(new T[0]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment3, 0); var start = buffer.Start; Assert.True(buffer.TryGet(ref start, out var memory)); Assert.Equal(0, memory.Length); Assert.True(buffer.TryGet(ref start, out memory)); Assert.Equal(0, memory.Length); Assert.True(buffer.TryGet(ref start, out memory)); Assert.Equal(0, memory.Length); Assert.False(buffer.TryGet(ref start, out memory)); } [Fact] public void SeekEmptySkipDoesNotCrossPastEnd() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[0]); BufferSegment<T> bufferSegment3 = bufferSegment2.Append(new T[0]); BufferSegment<T> bufferSegment4 = bufferSegment3.Append(new T[100]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment2, 0); SequencePosition c1 = buffer.GetPosition(100); Assert.Equal(0, c1.GetInteger()); Assert.Equal(bufferSegment2, c1.GetObject()); c1 = buffer.GetPosition(100, buffer.Start); Assert.Equal(0, c1.GetInteger()); Assert.Equal(bufferSegment2, c1.GetObject()); // Go out of bounds for segment Assert.Throws<ArgumentOutOfRangeException>(() => c1 = buffer.GetPosition(150, buffer.Start)); Assert.Throws<ArgumentOutOfRangeException>(() => c1 = buffer.GetPosition(250, buffer.Start)); } [Fact] public void SeekEmptySkipDoesNotCrossPastEndWithExtraChainedBlocks() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[0]); BufferSegment<T> bufferSegment3 = bufferSegment2.Append(new T[0]); BufferSegment<T> bufferSegment4 = bufferSegment3.Append(new T[100]); BufferSegment<T> bufferSegment5 = bufferSegment4.Append(new T[0]); BufferSegment<T> bufferSegment6 = bufferSegment5.Append(new T[100]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment2, 0); SequencePosition c1 = buffer.GetPosition(100); Assert.Equal(0, c1.GetInteger()); Assert.Equal(bufferSegment2, c1.GetObject()); c1 = buffer.GetPosition(100, buffer.Start); Assert.Equal(0, c1.GetInteger()); Assert.Equal(bufferSegment2, c1.GetObject()); // Go out of bounds for segment Assert.Throws<ArgumentOutOfRangeException>(() => c1 = buffer.GetPosition(150, buffer.Start)); Assert.Throws<ArgumentOutOfRangeException>(() => c1 = buffer.GetPosition(250, buffer.Start)); } #endregion #region TryGet [Fact] public void TryGetStopsAtEnd() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[100]); BufferSegment<T> bufferSegment3 = bufferSegment2.Append(new T[100]); BufferSegment<T> bufferSegment4 = bufferSegment3.Append(new T[100]); BufferSegment<T> bufferSegment5 = bufferSegment4.Append(new T[100]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment3, 100); var start = buffer.Start; Assert.True(buffer.TryGet(ref start, out var memory)); Assert.Equal(100, memory.Length); Assert.True(buffer.TryGet(ref start, out memory)); Assert.Equal(100, memory.Length); Assert.True(buffer.TryGet(ref start, out memory)); Assert.Equal(100, memory.Length); Assert.False(buffer.TryGet(ref start, out memory)); } [Fact] public void TryGetStopsAtEndWhenEndIsLastItemOfFull() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[100]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment1, 100); SequencePosition start = buffer.Start; Assert.True(buffer.TryGet(ref start, out ReadOnlyMemory<T> memory)); Assert.Equal(100, memory.Length); Assert.False(buffer.TryGet(ref start, out memory)); } [Fact] public void TryGetStopsAtEndWhenEndIsFirstItemOfFull() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[100]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment2, 0); SequencePosition start = buffer.Start; Assert.True(buffer.TryGet(ref start, out ReadOnlyMemory<T> memory)); Assert.Equal(100, memory.Length); Assert.True(buffer.TryGet(ref start, out memory)); Assert.Equal(0, memory.Length); Assert.False(buffer.TryGet(ref start, out memory)); } [Fact] public void TryGetStopsAtEndWhenEndIsFirstItemOfEmpty() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[0]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment2, 0); SequencePosition start = buffer.Start; Assert.True(buffer.TryGet(ref start, out ReadOnlyMemory<T> memory)); Assert.Equal(100, memory.Length); Assert.True(buffer.TryGet(ref start, out memory)); Assert.Equal(0, memory.Length); Assert.False(buffer.TryGet(ref start, out memory)); } #endregion #region Enumerable [Fact] public void EnumerableStopsAtEndWhenEndIsLastItemOfFull() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[100]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment1, 100); List<int> sizes = new List<int>(); foreach (ReadOnlyMemory<T> memory in buffer) { sizes.Add(memory.Length); } Assert.Equal(1, sizes.Count); Assert.Equal(new[] { 100 }, sizes); } [Fact] public void EnumerableStopsAtEndWhenEndIsFirstItemOfFull() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[100]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment2, 0); List<int> sizes = new List<int>(); foreach (ReadOnlyMemory<T> memory in buffer) { sizes.Add(memory.Length); } Assert.Equal(2, sizes.Count); Assert.Equal(new[] { 100, 0 }, sizes); } [Fact] public void EnumerableStopsAtEndWhenEndIsFirstItemOfEmpty() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[0]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment2, 0); List<int> sizes = new List<int>(); foreach (ReadOnlyMemory<T> memory in buffer) { sizes.Add(memory.Length); } Assert.Equal(2, sizes.Count); Assert.Equal(new[] { 100, 0 }, sizes); } #endregion #region Constructor [Fact] public void Ctor_Array_ValidatesArguments() { Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(new T[5], 6, 0)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(new T[5], 4, 2)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(new T[5], -4, 0)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(new T[5], 4, -2)); Assert.Throws<ArgumentNullException>(() => new ReadOnlySequence<T>(null, 4, 2)); } [Fact] public void Ctor_SingleSegment_ValidatesArguments() { var segment = new BufferSegment<T>(new T[5]); Assert.Throws<ArgumentNullException>(() => new ReadOnlySequence<T>(null, 2, segment, 3)); Assert.Throws<ArgumentNullException>(() => new ReadOnlySequence<T>(segment, 2, null, 3)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(segment, 6, segment, 3)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(segment, 2, segment, 6)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(segment, -1, segment, 0)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(segment, 0, segment, -1)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(segment, 3, segment, 2)); } [Fact] public void Ctor_MultiSegments_ValidatesArguments() { var segment1 = new BufferSegment<T>(new T[5]); BufferSegment<T> segment2 = segment1.Append(new T[5]); Assert.Throws<ArgumentNullException>(() => new ReadOnlySequence<T>(null, 5, segment2, 3)); Assert.Throws<ArgumentNullException>(() => new ReadOnlySequence<T>(segment1, 2, null, 3)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(segment1, 6, segment2, 3)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(segment1, 2, segment2, 6)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(segment1, -1, segment2, 0)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(segment1, 0, segment2, -1)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(segment2, 2, segment1, 3)); } #endregion } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Buffers; using System.Collections.Generic; using System.Linq; using System.MemoryTests; using System.Text; using Xunit; namespace System.Memory.Tests { public abstract class ReadOnlySequenceTestsCommon<T> { #region Position [Fact] public void SegmentStartIsConsideredInBoundsCheck() { // 0 50 100 0 50 100 // [ ##############] -> [############## ] // ^c1 ^c2 var bufferSegment1 = new BufferSegment<T>(new T[49]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[50]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment2, 50); SequencePosition c1 = buffer.GetPosition(25); // segment 1 index 75 SequencePosition c2 = buffer.GetPosition(55); // segment 2 index 5 ReadOnlySequence<T> sliced = buffer.Slice(c1, c2); Assert.Equal(30, sliced.Length); c1 = buffer.GetPosition(25, buffer.Start); // segment 1 index 75 c2 = buffer.GetPosition(55, buffer.Start); // segment 2 index 5 sliced = buffer.Slice(c1, c2); Assert.Equal(30, sliced.Length); } [Fact] public void GetPositionPrefersNextSegment() { BufferSegment<T> bufferSegment1 = new BufferSegment<T>(new T[50]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[0]); ReadOnlySequence<T> buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment2, 0); SequencePosition c1 = buffer.GetPosition(50); Assert.Equal(0, c1.GetInteger()); Assert.Equal(bufferSegment2, c1.GetObject()); c1 = buffer.GetPosition(50, buffer.Start); Assert.Equal(0, c1.GetInteger()); Assert.Equal(bufferSegment2, c1.GetObject()); } [Fact] public void GetPositionDoesNotCrossOutsideBuffer() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[100]); BufferSegment<T> bufferSegment3 = bufferSegment2.Append(new T[0]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment2, 100); SequencePosition c1 = buffer.GetPosition(200); Assert.Equal(100, c1.GetInteger()); Assert.Equal(bufferSegment2, c1.GetObject()); c1 = buffer.GetPosition(200, buffer.Start); Assert.Equal(100, c1.GetInteger()); Assert.Equal(bufferSegment2, c1.GetObject()); } [Fact] public void CheckEndReachableDoesNotCrossPastEnd() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[100]); BufferSegment<T> bufferSegment3 = bufferSegment2.Append(new T[100]); BufferSegment<T> bufferSegment4 = bufferSegment3.Append(new T[100]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment4, 100); SequencePosition c1 = buffer.GetPosition(200); Assert.Equal(0, c1.GetInteger()); Assert.Equal(bufferSegment3, c1.GetObject()); ReadOnlySequence<T> seq = buffer.Slice(0, c1); Assert.Equal(200, seq.Length); c1 = buffer.GetPosition(200, buffer.Start); Assert.Equal(0, c1.GetInteger()); Assert.Equal(bufferSegment3, c1.GetObject()); seq = buffer.Slice(0, c1); Assert.Equal(200, seq.Length); } #endregion #region Offset [Fact] public void GetOffset_SingleSegment() { var buffer = new ReadOnlySequence<T>(new T[50]); Assert.Equal(25, buffer.GetOffset(buffer.GetPosition(25))); } private (BufferSegment<T> bufferSegment1, BufferSegment<T> bufferSegment4) GetBufferSegment() { // [50] -> [50] -> [0] -> [50] var bufferSegment1 = new BufferSegment<T>(new T[50]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[50]); BufferSegment<T> bufferSegment3 = bufferSegment2.Append(new T[0]); return (bufferSegment1, bufferSegment3.Append(new T[50])); } private ReadOnlySequence<T> GetFourSegmentsReadOnlySequence() { (BufferSegment<T> bufferSegment1, BufferSegment<T> bufferSegment4) = GetBufferSegment(); return new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment4, 50); } [Fact] public void GetOffset_MultiSegment_FirstSegment() { ReadOnlySequence<T> buffer = GetFourSegmentsReadOnlySequence(); Assert.Equal(25, buffer.GetOffset(buffer.GetPosition(25))); } [Fact] public void GetOffset_MultiSegment_LastSegment() { ReadOnlySequence<T> buffer = GetFourSegmentsReadOnlySequence(); Assert.Equal(125, buffer.GetOffset(buffer.GetPosition(125))); } [Fact] public void GetOffset_MultiSegment_MiddleSegment() { ReadOnlySequence<T> buffer = GetFourSegmentsReadOnlySequence(); Assert.Equal(75, buffer.GetOffset(buffer.GetPosition(75))); } [Fact] public void GetOffset_SingleSegment_NullPositionObject() { var buffer = new ReadOnlySequence<T>(new T[50]); Assert.Equal(0, buffer.GetOffset(new SequencePosition(null, 25))); } [Fact] public void GetOffset_MultiSegment_NullPositionObject() { ReadOnlySequence<T> buffer = GetFourSegmentsReadOnlySequence(); Assert.Equal(0, buffer.GetOffset(new SequencePosition(null, 25))); } [Fact] public void GetOffset_MultiSegment_BoundaryConditions() { // [50] -> [50] -> [0] -> [50] var bufferSegment1 = new BufferSegment<T>(new T[50]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[50]); BufferSegment<T> bufferSegment3 = bufferSegment2.Append(new T[0]); BufferSegment<T> bufferSegment4 = bufferSegment3.Append(new T[50]); var sequence = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment4, 50); // Non empty adjacent segment Assert.Equal(50, sequence.GetOffset(new SequencePosition(bufferSegment1, 50))); Assert.Equal(50, sequence.GetOffset(new SequencePosition(bufferSegment2, 0))); Assert.Equal(51, sequence.GetOffset(new SequencePosition(bufferSegment2, 1))); // Empty adjacent segment Assert.Equal(100, sequence.GetOffset(new SequencePosition(bufferSegment2, 50))); Assert.Equal(100, sequence.GetOffset(new SequencePosition(bufferSegment3, 0))); Assert.Equal(101, sequence.GetOffset(new SequencePosition(bufferSegment4, 1))); // Cannot get 101 starting from empty adjacent segment Assert.Throws<ArgumentOutOfRangeException>(() => sequence.GetOffset(new SequencePosition(bufferSegment3, 1))); } [Fact] public void GetOffset_MultiSegment_Enumerate() { ReadOnlySequence<T> buffer = GetFourSegmentsReadOnlySequence(); for (int i = 0; i <= buffer.Length; i++) { Assert.Equal(i, buffer.GetOffset(buffer.GetPosition(i))); } } [Fact] public void GetOffset_SingleSegment_Enumerate() { ReadOnlySequence<T> buffer = new ReadOnlySequence<T>(new T[50]); for (int i = 0; i <= buffer.Length; i++) { Assert.Equal(i, buffer.GetOffset(buffer.GetPosition(i))); } } [Fact] public void GetOffset_MultiSegment_Slice() { ReadOnlySequence<T> buffer = GetFourSegmentsReadOnlySequence(); for (int i = 0; i <= buffer.Length; i++) { Assert.Equal(buffer.Slice(0, i).Length, buffer.GetOffset(buffer.GetPosition(i))); } } [Fact] public void GetOffset_SingleSegment_Slice() { ReadOnlySequence<T> buffer = new ReadOnlySequence<T>(new T[50]); for (int i = 0; i <= buffer.Length; i++) { Assert.Equal(buffer.Slice(0, i).Length, buffer.GetOffset(buffer.GetPosition(i))); } } [Fact] public void GetOffset_SingleSegment_PositionOutOfRange() { var positionObject = new T[50]; var buffer = new ReadOnlySequence<T>(positionObject); Assert.Throws<ArgumentOutOfRangeException>("position", () => buffer.GetOffset(new SequencePosition(positionObject, 75))); } [Fact] public void GetOffset_MultiSegment_PositionOutOfRange() { (BufferSegment<T> bufferSegment1, BufferSegment<T> bufferSegment4) = GetBufferSegment(); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment4, 50); Assert.Throws<ArgumentOutOfRangeException>("position", () => buffer.GetOffset(new SequencePosition(bufferSegment4, 200))); } [Fact] public void GetOffset_MultiSegment_PositionOutOfRange_SegmentNotFound() { ReadOnlySequence<T> buffer = GetFourSegmentsReadOnlySequence(); ReadOnlySequence<T> buffer2 = GetFourSegmentsReadOnlySequence(); Assert.Throws<ArgumentOutOfRangeException>("position", () => buffer.GetOffset(buffer2.GetPosition(25))); } [Fact] public void GetOffset_MultiSegment_InvalidSequencePositionSegment() { ReadOnlySequence<T> buffer = GetFourSegmentsReadOnlySequence(); ReadOnlySequence<T> buffer2 = new ReadOnlySequence<T>(new T[50]); Assert.Throws<InvalidCastException>(() => buffer.GetOffset(buffer2.GetPosition(25))); } [Fact] public void GetOffset_SingleSegment_SequencePositionSegment() { var data = new T[0]; var sequence = new ReadOnlySequence<T>(data); Assert.Equal(0, sequence.GetOffset(new SequencePosition(data, 0))); // Invalid positions Assert.Throws<ArgumentOutOfRangeException>(() => sequence.GetOffset(new SequencePosition(data, 1))); } [Fact] public void GetOffset_MultiSegment_SequencePositionSegment() { // [0] -> [0] -> [0] -> [50] var bufferSegment1 = new BufferSegment<T>(new T[0]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[0]); BufferSegment<T> bufferSegment3 = bufferSegment2.Append(new T[0]); BufferSegment<T> bufferSegment4 = bufferSegment3.Append(new T[50]); var sequence = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment4, 50); Assert.Equal(0, sequence.GetOffset(new SequencePosition(bufferSegment1, 0))); Assert.Equal(0, sequence.GetOffset(new SequencePosition(bufferSegment2, 0))); Assert.Equal(0, sequence.GetOffset(new SequencePosition(bufferSegment3, 0))); Assert.Equal(0, sequence.GetOffset(new SequencePosition(bufferSegment4, 0))); // Invalid positions Assert.Throws<ArgumentOutOfRangeException>(() => sequence.GetOffset(new SequencePosition(bufferSegment1, 1))); Assert.Throws<ArgumentOutOfRangeException>(() => sequence.GetOffset(new SequencePosition(bufferSegment2, 1))); Assert.Throws<ArgumentOutOfRangeException>(() => sequence.GetOffset(new SequencePosition(bufferSegment3, 1))); for (int i = 0; i <= bufferSegment4.Memory.Length; i++) { Assert.Equal(i, sequence.GetOffset(new SequencePosition(bufferSegment4, i))); } } #endregion #region First [Fact] public void AsArray_CanGetFirst() { var memory = new ReadOnlyMemory<T>(new T[5]); VerifyCanGetFirst(new ReadOnlySequence<T>(memory), expectedSize: 5); } [Fact] public void AsMemoryManager_CanGetFirst() { MemoryManager<T> manager = new CustomMemoryForTest<T>(new T[5]); ReadOnlyMemory<T> memoryFromManager = ((ReadOnlyMemory<T>)manager.Memory); VerifyCanGetFirst(new ReadOnlySequence<T>(memoryFromManager), expectedSize: 5); } [Fact] public void AsMultiSegment_CanGetFirst() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[100]); BufferSegment<T> bufferSegment3 = bufferSegment2.Append(new T[100]); BufferSegment<T> bufferSegment4 = bufferSegment3.Append(new T[200]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment4, 200); // Verify first 3 segments Assert.Equal(500, buffer.Length); int length = 500; for (int s = 0; s < 3; s++) { for (int i = 100; i > 0; i--) { Assert.Equal(i, buffer.First.Length); Assert.Equal(i, buffer.FirstSpan.Length); buffer = buffer.Slice(1); length--; Assert.Equal(length, buffer.Length); } } // Verify last segment VerifyCanGetFirst(buffer, expectedSize: 200); } protected void VerifyCanGetFirst(ReadOnlySequence<T> buffer, int expectedSize) { Assert.Equal(expectedSize, buffer.Length); int length = expectedSize; for (int i = length; i > 0; i--) { Assert.Equal(i, buffer.First.Length); Assert.Equal(i, buffer.FirstSpan.Length); buffer = buffer.Slice(1); length--; Assert.Equal(length, buffer.Length); } Assert.Equal(0, buffer.Length); Assert.Equal(0, buffer.First.Length); Assert.Equal(0, buffer.FirstSpan.Length); } #endregion #region EmptySegments [Fact] public void SeekSkipsEmptySegments() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[0]); BufferSegment<T> bufferSegment3 = bufferSegment2.Append(new T[0]); BufferSegment<T> bufferSegment4 = bufferSegment3.Append(new T[100]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment4, 100); SequencePosition c1 = buffer.GetPosition(100); Assert.Equal(0, c1.GetInteger()); Assert.Equal(bufferSegment4, c1.GetObject()); c1 = buffer.GetPosition(100, buffer.Start); Assert.Equal(0, c1.GetInteger()); Assert.Equal(bufferSegment4, c1.GetObject()); } [Fact] public void TryGetReturnsEmptySegments() { var bufferSegment1 = new BufferSegment<T>(new T[0]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[0]); BufferSegment<T> bufferSegment3 = bufferSegment2.Append(new T[0]); BufferSegment<T> bufferSegment4 = bufferSegment3.Append(new T[0]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment3, 0); var start = buffer.Start; Assert.True(buffer.TryGet(ref start, out var memory)); Assert.Equal(0, memory.Length); Assert.True(buffer.TryGet(ref start, out memory)); Assert.Equal(0, memory.Length); Assert.True(buffer.TryGet(ref start, out memory)); Assert.Equal(0, memory.Length); Assert.False(buffer.TryGet(ref start, out memory)); } [Fact] public void SeekEmptySkipDoesNotCrossPastEnd() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[0]); BufferSegment<T> bufferSegment3 = bufferSegment2.Append(new T[0]); BufferSegment<T> bufferSegment4 = bufferSegment3.Append(new T[100]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment2, 0); SequencePosition c1 = buffer.GetPosition(100); Assert.Equal(0, c1.GetInteger()); Assert.Equal(bufferSegment2, c1.GetObject()); c1 = buffer.GetPosition(100, buffer.Start); Assert.Equal(0, c1.GetInteger()); Assert.Equal(bufferSegment2, c1.GetObject()); // Go out of bounds for segment Assert.Throws<ArgumentOutOfRangeException>(() => c1 = buffer.GetPosition(150, buffer.Start)); Assert.Throws<ArgumentOutOfRangeException>(() => c1 = buffer.GetPosition(250, buffer.Start)); } [Fact] public void SeekEmptySkipDoesNotCrossPastEndWithExtraChainedBlocks() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[0]); BufferSegment<T> bufferSegment3 = bufferSegment2.Append(new T[0]); BufferSegment<T> bufferSegment4 = bufferSegment3.Append(new T[100]); BufferSegment<T> bufferSegment5 = bufferSegment4.Append(new T[0]); BufferSegment<T> bufferSegment6 = bufferSegment5.Append(new T[100]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment2, 0); SequencePosition c1 = buffer.GetPosition(100); Assert.Equal(0, c1.GetInteger()); Assert.Equal(bufferSegment2, c1.GetObject()); c1 = buffer.GetPosition(100, buffer.Start); Assert.Equal(0, c1.GetInteger()); Assert.Equal(bufferSegment2, c1.GetObject()); // Go out of bounds for segment Assert.Throws<ArgumentOutOfRangeException>(() => c1 = buffer.GetPosition(150, buffer.Start)); Assert.Throws<ArgumentOutOfRangeException>(() => c1 = buffer.GetPosition(250, buffer.Start)); } #endregion #region TryGet [Fact] public void TryGetStopsAtEnd() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[100]); BufferSegment<T> bufferSegment3 = bufferSegment2.Append(new T[100]); BufferSegment<T> bufferSegment4 = bufferSegment3.Append(new T[100]); BufferSegment<T> bufferSegment5 = bufferSegment4.Append(new T[100]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment3, 100); var start = buffer.Start; Assert.True(buffer.TryGet(ref start, out var memory)); Assert.Equal(100, memory.Length); Assert.True(buffer.TryGet(ref start, out memory)); Assert.Equal(100, memory.Length); Assert.True(buffer.TryGet(ref start, out memory)); Assert.Equal(100, memory.Length); Assert.False(buffer.TryGet(ref start, out memory)); } [Fact] public void TryGetStopsAtEndWhenEndIsLastItemOfFull() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[100]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment1, 100); SequencePosition start = buffer.Start; Assert.True(buffer.TryGet(ref start, out ReadOnlyMemory<T> memory)); Assert.Equal(100, memory.Length); Assert.False(buffer.TryGet(ref start, out memory)); } [Fact] public void TryGetStopsAtEndWhenEndIsFirstItemOfFull() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[100]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment2, 0); SequencePosition start = buffer.Start; Assert.True(buffer.TryGet(ref start, out ReadOnlyMemory<T> memory)); Assert.Equal(100, memory.Length); Assert.True(buffer.TryGet(ref start, out memory)); Assert.Equal(0, memory.Length); Assert.False(buffer.TryGet(ref start, out memory)); } [Fact] public void TryGetStopsAtEndWhenEndIsFirstItemOfEmpty() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[0]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment2, 0); SequencePosition start = buffer.Start; Assert.True(buffer.TryGet(ref start, out ReadOnlyMemory<T> memory)); Assert.Equal(100, memory.Length); Assert.True(buffer.TryGet(ref start, out memory)); Assert.Equal(0, memory.Length); Assert.False(buffer.TryGet(ref start, out memory)); } #endregion #region Enumerable [Fact] public void EnumerableStopsAtEndWhenEndIsLastItemOfFull() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[100]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment1, 100); List<int> sizes = new List<int>(); foreach (ReadOnlyMemory<T> memory in buffer) { sizes.Add(memory.Length); } Assert.Equal(1, sizes.Count); Assert.Equal(new[] { 100 }, sizes); } [Fact] public void EnumerableStopsAtEndWhenEndIsFirstItemOfFull() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[100]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment2, 0); List<int> sizes = new List<int>(); foreach (ReadOnlyMemory<T> memory in buffer) { sizes.Add(memory.Length); } Assert.Equal(2, sizes.Count); Assert.Equal(new[] { 100, 0 }, sizes); } [Fact] public void EnumerableStopsAtEndWhenEndIsFirstItemOfEmpty() { var bufferSegment1 = new BufferSegment<T>(new T[100]); BufferSegment<T> bufferSegment2 = bufferSegment1.Append(new T[0]); var buffer = new ReadOnlySequence<T>(bufferSegment1, 0, bufferSegment2, 0); List<int> sizes = new List<int>(); foreach (ReadOnlyMemory<T> memory in buffer) { sizes.Add(memory.Length); } Assert.Equal(2, sizes.Count); Assert.Equal(new[] { 100, 0 }, sizes); } #endregion #region Constructor [Fact] public void Ctor_Array_ValidatesArguments() { Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(new T[5], 6, 0)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(new T[5], 4, 2)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(new T[5], -4, 0)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(new T[5], 4, -2)); Assert.Throws<ArgumentNullException>(() => new ReadOnlySequence<T>(null, 4, 2)); } [Fact] public void Ctor_SingleSegment_ValidatesArguments() { var segment = new BufferSegment<T>(new T[5]); Assert.Throws<ArgumentNullException>(() => new ReadOnlySequence<T>(null, 2, segment, 3)); Assert.Throws<ArgumentNullException>(() => new ReadOnlySequence<T>(segment, 2, null, 3)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(segment, 6, segment, 3)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(segment, 2, segment, 6)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(segment, -1, segment, 0)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(segment, 0, segment, -1)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(segment, 3, segment, 2)); } [Fact] public void Ctor_MultiSegments_ValidatesArguments() { var segment1 = new BufferSegment<T>(new T[5]); BufferSegment<T> segment2 = segment1.Append(new T[5]); Assert.Throws<ArgumentNullException>(() => new ReadOnlySequence<T>(null, 5, segment2, 3)); Assert.Throws<ArgumentNullException>(() => new ReadOnlySequence<T>(segment1, 2, null, 3)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(segment1, 6, segment2, 3)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(segment1, 2, segment2, 6)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(segment1, -1, segment2, 0)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(segment1, 0, segment2, -1)); Assert.Throws<ArgumentOutOfRangeException>(() => new ReadOnlySequence<T>(segment2, 2, segment1, 3)); } #endregion } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/Helpers.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; namespace System.Dynamic.Utils { // Miscellaneous helpers that don't belong anywhere else internal static class Helpers { internal static T? CommonNode<T>(T first, T second, Func<T, T> parent) where T : class { EqualityComparer<T> cmp = EqualityComparer<T>.Default; if (cmp.Equals(first, second)) { return first; } var set = new HashSet<T>(cmp); for (T t = first; t != null; t = parent(t)) { set.Add(t); } for (T t = second; t != null; t = parent(t)) { if (set.Contains(t)) { return t; } } return null; } internal static void IncrementCount<T>(T key, Dictionary<T, int> dict) where T : notnull { int count; dict.TryGetValue(key, out count); dict[key] = count + 1; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; namespace System.Dynamic.Utils { // Miscellaneous helpers that don't belong anywhere else internal static class Helpers { internal static T? CommonNode<T>(T first, T second, Func<T, T> parent) where T : class { EqualityComparer<T> cmp = EqualityComparer<T>.Default; if (cmp.Equals(first, second)) { return first; } var set = new HashSet<T>(cmp); for (T t = first; t != null; t = parent(t)) { set.Add(t); } for (T t = second; t != null; t = parent(t)) { if (set.Contains(t)) { return t; } } return null; } internal static void IncrementCount<T>(T key, Dictionary<T, int> dict) where T : notnull { int count; dict.TryGetValue(key, out count); dict[key] = count + 1; } } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIcmpV4Statistics.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Net.NetworkInformation { // ICMP statistics for IPv4. internal sealed class SystemIcmpV4Statistics : IcmpV4Statistics { private readonly Interop.IpHlpApi.MibIcmpInfo _stats; internal unsafe SystemIcmpV4Statistics() { uint result; fixed (Interop.IpHlpApi.MibIcmpInfo* pStats = &_stats) result = Interop.IpHlpApi.GetIcmpStatistics(pStats); if (result != Interop.IpHlpApi.ERROR_SUCCESS) { throw new NetworkInformationException((int)result); } } public override long MessagesSent { get { return _stats.outStats.messages; } } public override long MessagesReceived { get { return _stats.inStats.messages; } } public override long ErrorsSent { get { return _stats.outStats.errors; } } public override long ErrorsReceived { get { return _stats.inStats.errors; } } public override long DestinationUnreachableMessagesSent { get { return _stats.outStats.destinationUnreachables; } } public override long DestinationUnreachableMessagesReceived { get { return _stats.inStats.destinationUnreachables; } } public override long TimeExceededMessagesSent { get { return _stats.outStats.timeExceeds; } } public override long TimeExceededMessagesReceived { get { return _stats.inStats.timeExceeds; } } public override long ParameterProblemsSent { get { return _stats.outStats.parameterProblems; } } public override long ParameterProblemsReceived { get { return _stats.inStats.parameterProblems; } } public override long SourceQuenchesSent { get { return _stats.outStats.sourceQuenches; } } public override long SourceQuenchesReceived { get { return _stats.inStats.sourceQuenches; } } public override long RedirectsSent { get { return _stats.outStats.redirects; } } public override long RedirectsReceived { get { return _stats.inStats.redirects; } } public override long EchoRequestsSent { get { return _stats.outStats.echoRequests; } } public override long EchoRequestsReceived { get { return _stats.inStats.echoRequests; } } public override long EchoRepliesSent { get { return _stats.outStats.echoReplies; } } public override long EchoRepliesReceived { get { return _stats.inStats.echoReplies; } } public override long TimestampRequestsSent { get { return _stats.outStats.timestampRequests; } } public override long TimestampRequestsReceived { get { return _stats.inStats.timestampRequests; } } public override long TimestampRepliesSent { get { return _stats.outStats.timestampReplies; } } public override long TimestampRepliesReceived { get { return _stats.inStats.timestampReplies; } } public override long AddressMaskRequestsSent { get { return _stats.outStats.addressMaskRequests; } } public override long AddressMaskRequestsReceived { get { return _stats.inStats.addressMaskRequests; } } public override long AddressMaskRepliesSent { get { return _stats.outStats.addressMaskReplies; } } public override long AddressMaskRepliesReceived { get { return _stats.inStats.addressMaskReplies; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Net.NetworkInformation { // ICMP statistics for IPv4. internal sealed class SystemIcmpV4Statistics : IcmpV4Statistics { private readonly Interop.IpHlpApi.MibIcmpInfo _stats; internal unsafe SystemIcmpV4Statistics() { uint result; fixed (Interop.IpHlpApi.MibIcmpInfo* pStats = &_stats) result = Interop.IpHlpApi.GetIcmpStatistics(pStats); if (result != Interop.IpHlpApi.ERROR_SUCCESS) { throw new NetworkInformationException((int)result); } } public override long MessagesSent { get { return _stats.outStats.messages; } } public override long MessagesReceived { get { return _stats.inStats.messages; } } public override long ErrorsSent { get { return _stats.outStats.errors; } } public override long ErrorsReceived { get { return _stats.inStats.errors; } } public override long DestinationUnreachableMessagesSent { get { return _stats.outStats.destinationUnreachables; } } public override long DestinationUnreachableMessagesReceived { get { return _stats.inStats.destinationUnreachables; } } public override long TimeExceededMessagesSent { get { return _stats.outStats.timeExceeds; } } public override long TimeExceededMessagesReceived { get { return _stats.inStats.timeExceeds; } } public override long ParameterProblemsSent { get { return _stats.outStats.parameterProblems; } } public override long ParameterProblemsReceived { get { return _stats.inStats.parameterProblems; } } public override long SourceQuenchesSent { get { return _stats.outStats.sourceQuenches; } } public override long SourceQuenchesReceived { get { return _stats.inStats.sourceQuenches; } } public override long RedirectsSent { get { return _stats.outStats.redirects; } } public override long RedirectsReceived { get { return _stats.inStats.redirects; } } public override long EchoRequestsSent { get { return _stats.outStats.echoRequests; } } public override long EchoRequestsReceived { get { return _stats.inStats.echoRequests; } } public override long EchoRepliesSent { get { return _stats.outStats.echoReplies; } } public override long EchoRepliesReceived { get { return _stats.inStats.echoReplies; } } public override long TimestampRequestsSent { get { return _stats.outStats.timestampRequests; } } public override long TimestampRequestsReceived { get { return _stats.inStats.timestampRequests; } } public override long TimestampRepliesSent { get { return _stats.outStats.timestampReplies; } } public override long TimestampRepliesReceived { get { return _stats.inStats.timestampReplies; } } public override long AddressMaskRequestsSent { get { return _stats.outStats.addressMaskRequests; } } public override long AddressMaskRequestsReceived { get { return _stats.inStats.addressMaskRequests; } } public override long AddressMaskRepliesSent { get { return _stats.outStats.addressMaskReplies; } } public override long AddressMaskRepliesReceived { get { return _stats.inStats.addressMaskReplies; } } } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/OidLookup.Windows.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using static Interop.Crypt32; namespace System.Security.Cryptography { internal static partial class OidLookup { private static bool ShouldUseCache(OidGroup oidGroup) { return oidGroup == OidGroup.All; } private static string? NativeOidToFriendlyName(string oid, OidGroup oidGroup, bool fallBackToAllGroups) { CRYPT_OID_INFO oidInfo = Interop.Crypt32.FindOidInfo(CryptOidInfoKeyType.CRYPT_OID_INFO_OID_KEY, oid, oidGroup, fallBackToAllGroups); return oidInfo.Name; } private static string? NativeFriendlyNameToOid(string friendlyName, OidGroup oidGroup, bool fallBackToAllGroups) { CRYPT_OID_INFO oidInfo = Interop.Crypt32.FindOidInfo(CryptOidInfoKeyType.CRYPT_OID_INFO_NAME_KEY, friendlyName, oidGroup, fallBackToAllGroups); return oidInfo.OID; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using static Interop.Crypt32; namespace System.Security.Cryptography { internal static partial class OidLookup { private static bool ShouldUseCache(OidGroup oidGroup) { return oidGroup == OidGroup.All; } private static string? NativeOidToFriendlyName(string oid, OidGroup oidGroup, bool fallBackToAllGroups) { CRYPT_OID_INFO oidInfo = Interop.Crypt32.FindOidInfo(CryptOidInfoKeyType.CRYPT_OID_INFO_OID_KEY, oid, oidGroup, fallBackToAllGroups); return oidInfo.Name; } private static string? NativeFriendlyNameToOid(string friendlyName, OidGroup oidGroup, bool fallBackToAllGroups) { CRYPT_OID_INFO oidInfo = Interop.Crypt32.FindOidInfo(CryptOidInfoKeyType.CRYPT_OID_INFO_NAME_KEY, friendlyName, oidGroup, fallBackToAllGroups); return oidInfo.OID; } } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FatFunctionPointerNode.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Internal.Text; using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; namespace ILCompiler.DependencyAnalysis { /// <summary> /// Represents a fat function pointer - a data structure that captures a pointer to a canonical /// method body along with the instantiation context the canonical body requires. /// Pointers to these structures can be created by e.g. ldftn/ldvirtftn of a method with a canonical body. /// </summary> public class FatFunctionPointerNode : ObjectNode, IMethodNode, ISymbolDefinitionNode { private bool _isUnboxingStub; public bool IsUnboxingStub => _isUnboxingStub; public FatFunctionPointerNode(MethodDesc methodRepresented, bool isUnboxingStub) { // We should not create these for methods that don't have a canonical method body Debug.Assert(methodRepresented.GetCanonMethodTarget(CanonicalFormKind.Specific) != methodRepresented); Method = methodRepresented; _isUnboxingStub = isUnboxingStub; } public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb) { string prefix = _isUnboxingStub ? "__fatunboxpointer_" : "__fatpointer_"; sb.Append(prefix).Append(nameMangler.GetMangledMethodName(Method)); } int ISymbolDefinitionNode.Offset => 0; int ISymbolNode.Offset => Method.Context.Target.Architecture == TargetArchitecture.Wasm32 ? 1 << 31 : 2; public override bool IsShareable => true; public MethodDesc Method { get; } public override ObjectNodeSection Section { get { if (Method.Context.Target.IsWindows) return ObjectNodeSection.ReadOnlyDataSection; else return ObjectNodeSection.DataSection; } } public override bool StaticDependenciesAreComputed => true; protected override string GetName(NodeFactory factory) => this.GetMangledName(factory.NameMangler); public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) { var builder = new ObjectDataBuilder(factory, relocsOnly); // These need to be aligned the same as methods because they show up in same contexts builder.RequireInitialAlignment(factory.Target.MinimumFunctionAlignment); builder.AddSymbol(this); MethodDesc canonMethod = Method.GetCanonMethodTarget(CanonicalFormKind.Specific); // Pointer to the canonical body of the method builder.EmitPointerReloc(factory.MethodEntrypoint(canonMethod, _isUnboxingStub)); // Find out what's the context to use ISortableSymbolNode contextParameter; if (canonMethod.RequiresInstMethodDescArg()) { contextParameter = factory.MethodGenericDictionary(Method); } else { Debug.Assert(canonMethod.RequiresInstMethodTableArg()); // Ask for a constructed type symbol because we need the vtable to get to the dictionary contextParameter = factory.ConstructedTypeSymbol(Method.OwningType); } // The next entry is a pointer to the context to be used for the canonical method builder.EmitPointerReloc(contextParameter); return builder.ToObjectData(); } public override int ClassCode => 190463489; public override int CompareToImpl(ISortableNode other, CompilerComparer comparer) { var compare = _isUnboxingStub.CompareTo(((FatFunctionPointerNode)other)._isUnboxingStub); if (compare != 0) return compare; return comparer.Compare(Method, ((FatFunctionPointerNode)other).Method); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Internal.Text; using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; namespace ILCompiler.DependencyAnalysis { /// <summary> /// Represents a fat function pointer - a data structure that captures a pointer to a canonical /// method body along with the instantiation context the canonical body requires. /// Pointers to these structures can be created by e.g. ldftn/ldvirtftn of a method with a canonical body. /// </summary> public class FatFunctionPointerNode : ObjectNode, IMethodNode, ISymbolDefinitionNode { private bool _isUnboxingStub; public bool IsUnboxingStub => _isUnboxingStub; public FatFunctionPointerNode(MethodDesc methodRepresented, bool isUnboxingStub) { // We should not create these for methods that don't have a canonical method body Debug.Assert(methodRepresented.GetCanonMethodTarget(CanonicalFormKind.Specific) != methodRepresented); Method = methodRepresented; _isUnboxingStub = isUnboxingStub; } public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb) { string prefix = _isUnboxingStub ? "__fatunboxpointer_" : "__fatpointer_"; sb.Append(prefix).Append(nameMangler.GetMangledMethodName(Method)); } int ISymbolDefinitionNode.Offset => 0; int ISymbolNode.Offset => Method.Context.Target.Architecture == TargetArchitecture.Wasm32 ? 1 << 31 : 2; public override bool IsShareable => true; public MethodDesc Method { get; } public override ObjectNodeSection Section { get { if (Method.Context.Target.IsWindows) return ObjectNodeSection.ReadOnlyDataSection; else return ObjectNodeSection.DataSection; } } public override bool StaticDependenciesAreComputed => true; protected override string GetName(NodeFactory factory) => this.GetMangledName(factory.NameMangler); public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) { var builder = new ObjectDataBuilder(factory, relocsOnly); // These need to be aligned the same as methods because they show up in same contexts builder.RequireInitialAlignment(factory.Target.MinimumFunctionAlignment); builder.AddSymbol(this); MethodDesc canonMethod = Method.GetCanonMethodTarget(CanonicalFormKind.Specific); // Pointer to the canonical body of the method builder.EmitPointerReloc(factory.MethodEntrypoint(canonMethod, _isUnboxingStub)); // Find out what's the context to use ISortableSymbolNode contextParameter; if (canonMethod.RequiresInstMethodDescArg()) { contextParameter = factory.MethodGenericDictionary(Method); } else { Debug.Assert(canonMethod.RequiresInstMethodTableArg()); // Ask for a constructed type symbol because we need the vtable to get to the dictionary contextParameter = factory.ConstructedTypeSymbol(Method.OwningType); } // The next entry is a pointer to the context to be used for the canonical method builder.EmitPointerReloc(contextParameter); return builder.ToObjectData(); } public override int ClassCode => 190463489; public override int CompareToImpl(ISortableNode other, CompilerComparer comparer) { var compare = _isUnboxingStub.CompareTo(((FatFunctionPointerNode)other)._isUnboxingStub); if (compare != 0) return compare; return comparer.Compare(Method, ((FatFunctionPointerNode)other).Method); } } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/SubtractSaturate.Vector128.Byte.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void SubtractSaturate_Vector128_Byte() { var test = new SimpleBinaryOpTest__SubtractSaturate_Vector128_Byte(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleBinaryOpTest__SubtractSaturate_Vector128_Byte { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Byte[] inArray1, Byte[] inArray2, Byte[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Byte>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Byte>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Byte>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Byte, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Byte, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector128<Byte> _fld1; public Vector128<Byte> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref testStruct._fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref testStruct._fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__SubtractSaturate_Vector128_Byte testClass) { var result = AdvSimd.SubtractSaturate(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__SubtractSaturate_Vector128_Byte testClass) { fixed (Vector128<Byte>* pFld1 = &_fld1) fixed (Vector128<Byte>* pFld2 = &_fld2) { var result = AdvSimd.SubtractSaturate( AdvSimd.LoadVector128((Byte*)(pFld1)), AdvSimd.LoadVector128((Byte*)(pFld2)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Byte>>() / sizeof(Byte); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Byte>>() / sizeof(Byte); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Byte>>() / sizeof(Byte); private static Byte[] _data1 = new Byte[Op1ElementCount]; private static Byte[] _data2 = new Byte[Op2ElementCount]; private static Vector128<Byte> _clsVar1; private static Vector128<Byte> _clsVar2; private Vector128<Byte> _fld1; private Vector128<Byte> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__SubtractSaturate_Vector128_Byte() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); } public SimpleBinaryOpTest__SubtractSaturate_Vector128_Byte() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } _dataTable = new DataTable(_data1, _data2, new Byte[RetElementCount], LargestVectorSize); } public bool IsSupported => AdvSimd.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = AdvSimd.SubtractSaturate( Unsafe.Read<Vector128<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = AdvSimd.SubtractSaturate( AdvSimd.LoadVector128((Byte*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Byte*)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.SubtractSaturate), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Byte>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.SubtractSaturate), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((Byte*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Byte*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Byte>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.SubtractSaturate( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<Byte>* pClsVar1 = &_clsVar1) fixed (Vector128<Byte>* pClsVar2 = &_clsVar2) { var result = AdvSimd.SubtractSaturate( AdvSimd.LoadVector128((Byte*)(pClsVar1)), AdvSimd.LoadVector128((Byte*)(pClsVar2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector128<Byte>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr); var result = AdvSimd.SubtractSaturate(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector128((Byte*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((Byte*)(_dataTable.inArray2Ptr)); var result = AdvSimd.SubtractSaturate(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__SubtractSaturate_Vector128_Byte(); var result = AdvSimd.SubtractSaturate(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleBinaryOpTest__SubtractSaturate_Vector128_Byte(); fixed (Vector128<Byte>* pFld1 = &test._fld1) fixed (Vector128<Byte>* pFld2 = &test._fld2) { var result = AdvSimd.SubtractSaturate( AdvSimd.LoadVector128((Byte*)(pFld1)), AdvSimd.LoadVector128((Byte*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.SubtractSaturate(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<Byte>* pFld1 = &_fld1) fixed (Vector128<Byte>* pFld2 = &_fld2) { var result = AdvSimd.SubtractSaturate( AdvSimd.LoadVector128((Byte*)(pFld1)), AdvSimd.LoadVector128((Byte*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = AdvSimd.SubtractSaturate(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = AdvSimd.SubtractSaturate( AdvSimd.LoadVector128((Byte*)(&test._fld1)), AdvSimd.LoadVector128((Byte*)(&test._fld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector128<Byte> op1, Vector128<Byte> op2, void* result, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; Byte[] outArray = new Byte[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Byte>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; Byte[] outArray = new Byte[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Byte>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Byte[] left, Byte[] right, Byte[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.SubtractSaturate(left[i], right[i]) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.SubtractSaturate)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void SubtractSaturate_Vector128_Byte() { var test = new SimpleBinaryOpTest__SubtractSaturate_Vector128_Byte(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleBinaryOpTest__SubtractSaturate_Vector128_Byte { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Byte[] inArray1, Byte[] inArray2, Byte[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Byte>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Byte>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Byte>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Byte, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Byte, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector128<Byte> _fld1; public Vector128<Byte> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref testStruct._fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref testStruct._fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__SubtractSaturate_Vector128_Byte testClass) { var result = AdvSimd.SubtractSaturate(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__SubtractSaturate_Vector128_Byte testClass) { fixed (Vector128<Byte>* pFld1 = &_fld1) fixed (Vector128<Byte>* pFld2 = &_fld2) { var result = AdvSimd.SubtractSaturate( AdvSimd.LoadVector128((Byte*)(pFld1)), AdvSimd.LoadVector128((Byte*)(pFld2)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Byte>>() / sizeof(Byte); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Byte>>() / sizeof(Byte); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Byte>>() / sizeof(Byte); private static Byte[] _data1 = new Byte[Op1ElementCount]; private static Byte[] _data2 = new Byte[Op2ElementCount]; private static Vector128<Byte> _clsVar1; private static Vector128<Byte> _clsVar2; private Vector128<Byte> _fld1; private Vector128<Byte> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__SubtractSaturate_Vector128_Byte() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); } public SimpleBinaryOpTest__SubtractSaturate_Vector128_Byte() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } _dataTable = new DataTable(_data1, _data2, new Byte[RetElementCount], LargestVectorSize); } public bool IsSupported => AdvSimd.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = AdvSimd.SubtractSaturate( Unsafe.Read<Vector128<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = AdvSimd.SubtractSaturate( AdvSimd.LoadVector128((Byte*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Byte*)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.SubtractSaturate), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Byte>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.SubtractSaturate), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((Byte*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Byte*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Byte>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.SubtractSaturate( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<Byte>* pClsVar1 = &_clsVar1) fixed (Vector128<Byte>* pClsVar2 = &_clsVar2) { var result = AdvSimd.SubtractSaturate( AdvSimd.LoadVector128((Byte*)(pClsVar1)), AdvSimd.LoadVector128((Byte*)(pClsVar2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector128<Byte>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr); var result = AdvSimd.SubtractSaturate(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector128((Byte*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((Byte*)(_dataTable.inArray2Ptr)); var result = AdvSimd.SubtractSaturate(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__SubtractSaturate_Vector128_Byte(); var result = AdvSimd.SubtractSaturate(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleBinaryOpTest__SubtractSaturate_Vector128_Byte(); fixed (Vector128<Byte>* pFld1 = &test._fld1) fixed (Vector128<Byte>* pFld2 = &test._fld2) { var result = AdvSimd.SubtractSaturate( AdvSimd.LoadVector128((Byte*)(pFld1)), AdvSimd.LoadVector128((Byte*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.SubtractSaturate(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<Byte>* pFld1 = &_fld1) fixed (Vector128<Byte>* pFld2 = &_fld2) { var result = AdvSimd.SubtractSaturate( AdvSimd.LoadVector128((Byte*)(pFld1)), AdvSimd.LoadVector128((Byte*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = AdvSimd.SubtractSaturate(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = AdvSimd.SubtractSaturate( AdvSimd.LoadVector128((Byte*)(&test._fld1)), AdvSimd.LoadVector128((Byte*)(&test._fld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector128<Byte> op1, Vector128<Byte> op2, void* result, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; Byte[] outArray = new Byte[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Byte>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; Byte[] outArray = new Byte[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Byte>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Byte[] left, Byte[] right, Byte[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.SubtractSaturate(left[i], right[i]) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.SubtractSaturate)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/tests/JIT/HardwareIntrinsics/X86/Regression/GitHub_17435/GitHub_17435.cs
using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics.X86; using System.Runtime.Intrinsics; namespace GitHub_17435 { class Program { const int Pass = 100; const int Fail = 0; static unsafe int Main(string[] args) { if (Sse2.IsSupported) { (uint a, uint b) = Program.Repro(); if ((a !=3) || (b != 6)) { Console.WriteLine($"FAILED {a}, {b}"); return Fail; } else { Console.WriteLine("Passed"); return Pass; } } else { Console.WriteLine("SSE2 not supported"); return Pass; } } [MethodImpl(MethodImplOptions.NoInlining)] public unsafe static (uint, uint) Repro() { uint* a = stackalloc uint[4]; a[0] = 1; a[1] = 1; a[2] = 1; a[3] = 1; // Here we force populate the registers var b = a[0]; var h = a[3]; var c = a[1]; // We operate the values in xmm0 Vector128<uint> v = Sse2.LoadVector128(a); v = Sse2.Add(v, v); // We send to the memory the modified values Sse2.Store(a, v); // We return both sums (from registers and from memory) return (b + h + c, a[0]+a[1]+a[3]); } } }
using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics.X86; using System.Runtime.Intrinsics; namespace GitHub_17435 { class Program { const int Pass = 100; const int Fail = 0; static unsafe int Main(string[] args) { if (Sse2.IsSupported) { (uint a, uint b) = Program.Repro(); if ((a !=3) || (b != 6)) { Console.WriteLine($"FAILED {a}, {b}"); return Fail; } else { Console.WriteLine("Passed"); return Pass; } } else { Console.WriteLine("SSE2 not supported"); return Pass; } } [MethodImpl(MethodImplOptions.NoInlining)] public unsafe static (uint, uint) Repro() { uint* a = stackalloc uint[4]; a[0] = 1; a[1] = 1; a[2] = 1; a[3] = 1; // Here we force populate the registers var b = a[0]; var h = a[3]; var c = a[1]; // We operate the values in xmm0 Vector128<uint> v = Sse2.LoadVector128(a); v = Sse2.Add(v, v); // We send to the memory the modified values Sse2.Store(a, v); // We return both sums (from registers and from memory) return (b + h + c, a[0]+a[1]+a[3]); } } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/mono/mono/tests/anonarray.2.cs
using System; using System.Collections.Generic; class Program { public static void Main() { // this form of initialisation causes a crash when I try // to iterate through the items. IEnumerable<IEnumerable<string>> table = new string[][] { new string[] { "1a", "1b" }, new string[] { "2a", "2b" } }; foreach (IEnumerable<string> row in table) { foreach (string cell in row) { Console.Write("{0} ", cell); } Console.WriteLine(); } } }
using System; using System.Collections.Generic; class Program { public static void Main() { // this form of initialisation causes a crash when I try // to iterate through the items. IEnumerable<IEnumerable<string>> table = new string[][] { new string[] { "1a", "1b" }, new string[] { "2a", "2b" } }; foreach (IEnumerable<string> row in table) { foreach (string cell in row) { Console.Write("{0} ", cell); } Console.WriteLine(); } } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/coreclr/jit/compiler.h
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX Compiler XX XX XX XX Represents the method data we are currently JIT-compiling. XX XX An instance of this class is created for every method we JIT. XX XX This contains all the info needed for the method. So allocating a XX XX a new instance per method makes it thread-safe. XX XX It should be used to do all the memory management for the compiler run. XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ /*****************************************************************************/ #ifndef _COMPILER_H_ #define _COMPILER_H_ /*****************************************************************************/ #include "jit.h" #include "opcode.h" #include "varset.h" #include "jitstd.h" #include "jithashtable.h" #include "gentree.h" #include "debuginfo.h" #include "lir.h" #include "block.h" #include "inline.h" #include "jiteh.h" #include "instr.h" #include "regalloc.h" #include "sm.h" #include "cycletimer.h" #include "blockset.h" #include "arraystack.h" #include "hashbv.h" #include "jitexpandarray.h" #include "tinyarray.h" #include "valuenum.h" #include "jittelemetry.h" #include "namedintrinsiclist.h" #ifdef LATE_DISASM #include "disasm.h" #endif #include "codegeninterface.h" #include "regset.h" #include "jitgcinfo.h" #if DUMP_GC_TABLES && defined(JIT32_GCENCODER) #include "gcdump.h" #endif #include "emit.h" #include "hwintrinsic.h" #include "simd.h" #include "simdashwintrinsic.h" // This is only used locally in the JIT to indicate that // a verification block should be inserted #define SEH_VERIFICATION_EXCEPTION 0xe0564552 // VER /***************************************************************************** * Forward declarations */ struct InfoHdr; // defined in GCInfo.h struct escapeMapping_t; // defined in fgdiagnostic.cpp class emitter; // defined in emit.h struct ShadowParamVarInfo; // defined in GSChecks.cpp struct InitVarDscInfo; // defined in register_arg_convention.h class FgStack; // defined in fgbasic.cpp class Instrumentor; // defined in fgprofile.cpp class SpanningTreeVisitor; // defined in fgprofile.cpp class CSE_DataFlow; // defined in OptCSE.cpp class OptBoolsDsc; // defined in optimizer.cpp #ifdef DEBUG struct IndentStack; #endif class Lowering; // defined in lower.h // The following are defined in this file, Compiler.h class Compiler; /***************************************************************************** * Unwind info */ #include "unwind.h" /*****************************************************************************/ // // Declare global operator new overloads that use the compiler's arena allocator // // I wanted to make the second argument optional, with default = CMK_Unknown, but that // caused these to be ambiguous with the global placement new operators. void* __cdecl operator new(size_t n, Compiler* context, CompMemKind cmk); void* __cdecl operator new[](size_t n, Compiler* context, CompMemKind cmk); void* __cdecl operator new(size_t n, void* p, const jitstd::placement_t& syntax_difference); // Requires the definitions of "operator new" so including "LoopCloning.h" after the definitions. #include "loopcloning.h" /*****************************************************************************/ /* This is included here and not earlier as it needs the definition of "CSE" * which is defined in the section above */ /*****************************************************************************/ unsigned genLog2(unsigned value); unsigned genLog2(unsigned __int64 value); unsigned ReinterpretHexAsDecimal(unsigned in); /*****************************************************************************/ const unsigned FLG_CCTOR = (CORINFO_FLG_CONSTRUCTOR | CORINFO_FLG_STATIC); #ifdef DEBUG const int BAD_STK_OFFS = 0xBAADF00D; // for LclVarDsc::lvStkOffs #endif //------------------------------------------------------------------------ // HFA info shared by LclVarDsc and fgArgTabEntry //------------------------------------------------------------------------ inline bool IsHfa(CorInfoHFAElemType kind) { return kind != CORINFO_HFA_ELEM_NONE; } inline var_types HfaTypeFromElemKind(CorInfoHFAElemType kind) { switch (kind) { case CORINFO_HFA_ELEM_FLOAT: return TYP_FLOAT; case CORINFO_HFA_ELEM_DOUBLE: return TYP_DOUBLE; #ifdef FEATURE_SIMD case CORINFO_HFA_ELEM_VECTOR64: return TYP_SIMD8; case CORINFO_HFA_ELEM_VECTOR128: return TYP_SIMD16; #endif case CORINFO_HFA_ELEM_NONE: return TYP_UNDEF; default: assert(!"Invalid HfaElemKind"); return TYP_UNDEF; } } inline CorInfoHFAElemType HfaElemKindFromType(var_types type) { switch (type) { case TYP_FLOAT: return CORINFO_HFA_ELEM_FLOAT; case TYP_DOUBLE: return CORINFO_HFA_ELEM_DOUBLE; #ifdef FEATURE_SIMD case TYP_SIMD8: return CORINFO_HFA_ELEM_VECTOR64; case TYP_SIMD16: return CORINFO_HFA_ELEM_VECTOR128; #endif case TYP_UNDEF: return CORINFO_HFA_ELEM_NONE; default: assert(!"Invalid HFA Type"); return CORINFO_HFA_ELEM_NONE; } } // The following holds the Local var info (scope information) typedef const char* VarName; // Actual ASCII string struct VarScopeDsc { unsigned vsdVarNum; // (remapped) LclVarDsc number unsigned vsdLVnum; // 'which' in eeGetLVinfo(). // Also, it is the index of this entry in the info.compVarScopes array, // which is useful since the array is also accessed via the // compEnterScopeList and compExitScopeList sorted arrays. IL_OFFSET vsdLifeBeg; // instr offset of beg of life IL_OFFSET vsdLifeEnd; // instr offset of end of life #ifdef DEBUG VarName vsdName; // name of the var #endif }; // This class stores information associated with a LclVar SSA definition. class LclSsaVarDsc { // The basic block where the definition occurs. Definitions of uninitialized variables // are considered to occur at the start of the first basic block (fgFirstBB). // // TODO-Cleanup: In the case of uninitialized variables the block is set to nullptr by // SsaBuilder and changed to fgFirstBB during value numbering. It would be useful to // investigate and perhaps eliminate this rather unexpected behavior. BasicBlock* m_block; // The GT_ASG node that generates the definition, or nullptr for definitions // of uninitialized variables. GenTreeOp* m_asg; public: LclSsaVarDsc() : m_block(nullptr), m_asg(nullptr) { } LclSsaVarDsc(BasicBlock* block, GenTreeOp* asg) : m_block(block), m_asg(asg) { assert((asg == nullptr) || asg->OperIs(GT_ASG)); } BasicBlock* GetBlock() const { return m_block; } void SetBlock(BasicBlock* block) { m_block = block; } GenTreeOp* GetAssignment() const { return m_asg; } void SetAssignment(GenTreeOp* asg) { assert((asg == nullptr) || asg->OperIs(GT_ASG)); m_asg = asg; } ValueNumPair m_vnPair; }; // This class stores information associated with a memory SSA definition. class SsaMemDef { public: ValueNumPair m_vnPair; }; //------------------------------------------------------------------------ // SsaDefArray: A resizable array of SSA definitions. // // Unlike an ordinary resizable array implementation, this allows only element // addition (by calling AllocSsaNum) and has special handling for RESERVED_SSA_NUM // (basically it's a 1-based array). The array doesn't impose any particular // requirements on the elements it stores and AllocSsaNum forwards its arguments // to the array element constructor, this way the array supports both LclSsaVarDsc // and SsaMemDef elements. // template <typename T> class SsaDefArray { T* m_array; unsigned m_arraySize; unsigned m_count; static_assert_no_msg(SsaConfig::RESERVED_SSA_NUM == 0); static_assert_no_msg(SsaConfig::FIRST_SSA_NUM == 1); // Get the minimum valid SSA number. unsigned GetMinSsaNum() const { return SsaConfig::FIRST_SSA_NUM; } // Increase (double) the size of the array. void GrowArray(CompAllocator alloc) { unsigned oldSize = m_arraySize; unsigned newSize = max(2, oldSize * 2); T* newArray = alloc.allocate<T>(newSize); for (unsigned i = 0; i < oldSize; i++) { newArray[i] = m_array[i]; } m_array = newArray; m_arraySize = newSize; } public: // Construct an empty SsaDefArray. SsaDefArray() : m_array(nullptr), m_arraySize(0), m_count(0) { } // Reset the array (used only if the SSA form is reconstructed). void Reset() { m_count = 0; } // Allocate a new SSA number (starting with SsaConfig::FIRST_SSA_NUM). template <class... Args> unsigned AllocSsaNum(CompAllocator alloc, Args&&... args) { if (m_count == m_arraySize) { GrowArray(alloc); } unsigned ssaNum = GetMinSsaNum() + m_count; m_array[m_count++] = T(std::forward<Args>(args)...); // Ensure that the first SSA number we allocate is SsaConfig::FIRST_SSA_NUM assert((ssaNum == SsaConfig::FIRST_SSA_NUM) || (m_count > 1)); return ssaNum; } // Get the number of SSA definitions in the array. unsigned GetCount() const { return m_count; } // Get a pointer to the SSA definition at the specified index. T* GetSsaDefByIndex(unsigned index) { assert(index < m_count); return &m_array[index]; } // Check if the specified SSA number is valid. bool IsValidSsaNum(unsigned ssaNum) const { return (GetMinSsaNum() <= ssaNum) && (ssaNum < (GetMinSsaNum() + m_count)); } // Get a pointer to the SSA definition associated with the specified SSA number. T* GetSsaDef(unsigned ssaNum) { assert(ssaNum != SsaConfig::RESERVED_SSA_NUM); return GetSsaDefByIndex(ssaNum - GetMinSsaNum()); } // Get an SSA number associated with the specified SSA def (that must be in this array). unsigned GetSsaNum(T* ssaDef) { assert((m_array <= ssaDef) && (ssaDef < &m_array[m_count])); return GetMinSsaNum() + static_cast<unsigned>(ssaDef - &m_array[0]); } }; enum RefCountState { RCS_INVALID, // not valid to get/set ref counts RCS_EARLY, // early counts for struct promotion and struct passing RCS_NORMAL, // normal ref counts (from lvaMarkRefs onward) }; #ifdef DEBUG // Reasons why we can't enregister a local. enum class DoNotEnregisterReason { None, AddrExposed, // the address of this local is exposed. DontEnregStructs, // struct enregistration is disabled. NotRegSizeStruct, // the struct size does not much any register size, usually the struct size is too big. LocalField, // the local is accessed with LCL_FLD, note we can do it not only for struct locals. VMNeedsStackAddr, LiveInOutOfHandler, // the local is alive in and out of exception handler and not signle def. BlockOp, // Is read or written via a block operation. IsStructArg, // Is a struct passed as an argument in a way that requires a stack location. DepField, // It is a field of a dependently promoted struct NoRegVars, // opts.compFlags & CLFLG_REGVAR is not set MinOptsGC, // It is a GC Ref and we are compiling MinOpts #if !defined(TARGET_64BIT) LongParamField, // It is a decomposed field of a long parameter. #endif #ifdef JIT32_GCENCODER PinningRef, #endif LclAddrNode, // the local is accessed with LCL_ADDR_VAR/FLD. CastTakesAddr, StoreBlkSrc, // the local is used as STORE_BLK source. OneAsgRetyping, // fgMorphOneAsgBlockOp prevents this local from being enregister. SwizzleArg, // the local is passed using LCL_FLD as another type. BlockOpRet, // the struct is returned and it promoted or there is a cast. ReturnSpCheck, // the local is used to do SP check SimdUserForcesDep // a promoted struct was used by a SIMD/HWI node; it must be dependently promoted }; enum class AddressExposedReason { NONE, PARENT_EXPOSED, // This is a promoted field but the parent is exposed. TOO_CONSERVATIVE, // Were marked as exposed to be conservative, fix these places. ESCAPE_ADDRESS, // The address is escaping, for example, passed as call argument. WIDE_INDIR, // We access via indirection with wider type. OSR_EXPOSED, // It was exposed in the original method, osr has to repeat it. STRESS_LCL_FLD, // Stress mode replaces localVar with localFld and makes them addrExposed. COPY_FLD_BY_FLD, // Field by field copy takes the address of the local, can be fixed. DISPATCH_RET_BUF // Caller return buffer dispatch. }; #endif // DEBUG class LclVarDsc { public: // The constructor. Most things can just be zero'ed. // // Initialize the ArgRegs to REG_STK. // Morph will update if this local is passed in a register. LclVarDsc() : _lvArgReg(REG_STK) , #if FEATURE_MULTIREG_ARGS _lvOtherArgReg(REG_STK) , #endif // FEATURE_MULTIREG_ARGS lvClassHnd(NO_CLASS_HANDLE) , lvRefBlks(BlockSetOps::UninitVal()) , lvPerSsaData() { } // note this only packs because var_types is a typedef of unsigned char var_types lvType : 5; // TYP_INT/LONG/FLOAT/DOUBLE/REF unsigned char lvIsParam : 1; // is this a parameter? unsigned char lvIsRegArg : 1; // is this an argument that was passed by register? unsigned char lvFramePointerBased : 1; // 0 = off of REG_SPBASE (e.g., ESP), 1 = off of REG_FPBASE (e.g., EBP) unsigned char lvOnFrame : 1; // (part of) the variable lives on the frame unsigned char lvRegister : 1; // assigned to live in a register? For RyuJIT backend, this is only set if the // variable is in the same register for the entire function. unsigned char lvTracked : 1; // is this a tracked variable? bool lvTrackedNonStruct() { return lvTracked && lvType != TYP_STRUCT; } unsigned char lvPinned : 1; // is this a pinned variable? unsigned char lvMustInit : 1; // must be initialized private: bool m_addrExposed : 1; // The address of this variable is "exposed" -- passed as an argument, stored in a // global location, etc. // We cannot reason reliably about the value of the variable. public: unsigned char lvDoNotEnregister : 1; // Do not enregister this variable. unsigned char lvFieldAccessed : 1; // The var is a struct local, and a field of the variable is accessed. Affects // struct promotion. unsigned char lvLiveInOutOfHndlr : 1; // The variable is live in or out of an exception handler, and therefore must // be on the stack (at least at those boundaries.) unsigned char lvInSsa : 1; // The variable is in SSA form (set by SsaBuilder) unsigned char lvIsCSE : 1; // Indicates if this LclVar is a CSE variable. unsigned char lvHasLdAddrOp : 1; // has ldloca or ldarga opcode on this local. unsigned char lvStackByref : 1; // This is a compiler temporary of TYP_BYREF that is known to point into our local // stack frame. unsigned char lvHasILStoreOp : 1; // there is at least one STLOC or STARG on this local unsigned char lvHasMultipleILStoreOp : 1; // there is more than one STLOC on this local unsigned char lvIsTemp : 1; // Short-lifetime compiler temp #if defined(TARGET_AMD64) || defined(TARGET_ARM64) unsigned char lvIsImplicitByRef : 1; // Set if the argument is an implicit byref. #endif // defined(TARGET_AMD64) || defined(TARGET_ARM64) unsigned char lvIsBoolean : 1; // set if variable is boolean unsigned char lvSingleDef : 1; // variable has a single def // before lvaMarkLocalVars: identifies ref type locals that can get type updates // after lvaMarkLocalVars: identifies locals that are suitable for optAddCopies unsigned char lvSingleDefRegCandidate : 1; // variable has a single def and hence is a register candidate // Currently, this is only used to decide if an EH variable can be // a register candiate or not. unsigned char lvDisqualifySingleDefRegCandidate : 1; // tracks variable that are disqualified from register // candidancy unsigned char lvSpillAtSingleDef : 1; // variable has a single def (as determined by LSRA interval scan) // and is spilled making it candidate to spill right after the // first (and only) definition. // Note: We cannot reuse lvSingleDefRegCandidate because it is set // in earlier phase and the information might not be appropriate // in LSRA. unsigned char lvDisqualify : 1; // variable is no longer OK for add copy optimization unsigned char lvVolatileHint : 1; // hint for AssertionProp #ifndef TARGET_64BIT unsigned char lvStructDoubleAlign : 1; // Must we double align this struct? #endif // !TARGET_64BIT #ifdef TARGET_64BIT unsigned char lvQuirkToLong : 1; // Quirk to allocate this LclVar as a 64-bit long #endif #ifdef DEBUG unsigned char lvKeepType : 1; // Don't change the type of this variable unsigned char lvNoLclFldStress : 1; // Can't apply local field stress on this one #endif unsigned char lvIsPtr : 1; // Might this be used in an address computation? (used by buffer overflow security // checks) unsigned char lvIsUnsafeBuffer : 1; // Does this contain an unsafe buffer requiring buffer overflow security checks? unsigned char lvPromoted : 1; // True when this local is a promoted struct, a normed struct, or a "split" long on a // 32-bit target. For implicit byref parameters, this gets hijacked between // fgRetypeImplicitByRefArgs and fgMarkDemotedImplicitByRefArgs to indicate whether // references to the arg are being rewritten as references to a promoted shadow local. unsigned char lvIsStructField : 1; // Is this local var a field of a promoted struct local? unsigned char lvOverlappingFields : 1; // True when we have a struct with possibly overlapping fields unsigned char lvContainsHoles : 1; // True when we have a promoted struct that contains holes unsigned char lvCustomLayout : 1; // True when this struct has "CustomLayout" unsigned char lvIsMultiRegArg : 1; // true if this is a multireg LclVar struct used in an argument context unsigned char lvIsMultiRegRet : 1; // true if this is a multireg LclVar struct assigned from a multireg call #ifdef FEATURE_HFA_FIELDS_PRESENT CorInfoHFAElemType _lvHfaElemKind : 3; // What kind of an HFA this is (CORINFO_HFA_ELEM_NONE if it is not an HFA). #endif // FEATURE_HFA_FIELDS_PRESENT #ifdef DEBUG // TODO-Cleanup: See the note on lvSize() - this flag is only in use by asserts that are checking for struct // types, and is needed because of cases where TYP_STRUCT is bashed to an integral type. // Consider cleaning this up so this workaround is not required. unsigned char lvUnusedStruct : 1; // All references to this promoted struct are through its field locals. // I.e. there is no longer any reference to the struct directly. // In this case we can simply remove this struct local. unsigned char lvUndoneStructPromotion : 1; // The struct promotion was undone and hence there should be no // reference to the fields of this struct. #endif unsigned char lvLRACandidate : 1; // Tracked for linear scan register allocation purposes #ifdef FEATURE_SIMD // Note that both SIMD vector args and locals are marked as lvSIMDType = true, but the // type of an arg node is TYP_BYREF and a local node is TYP_SIMD*. unsigned char lvSIMDType : 1; // This is a SIMD struct unsigned char lvUsedInSIMDIntrinsic : 1; // This tells lclvar is used for simd intrinsic unsigned char lvSimdBaseJitType : 5; // Note: this only packs because CorInfoType has less than 32 entries CorInfoType GetSimdBaseJitType() const { return (CorInfoType)lvSimdBaseJitType; } void SetSimdBaseJitType(CorInfoType simdBaseJitType) { assert(simdBaseJitType < (1 << 5)); lvSimdBaseJitType = (unsigned char)simdBaseJitType; } var_types GetSimdBaseType() const; #endif // FEATURE_SIMD unsigned char lvRegStruct : 1; // This is a reg-sized non-field-addressed struct. unsigned char lvClassIsExact : 1; // lvClassHandle is the exact type #ifdef DEBUG unsigned char lvClassInfoUpdated : 1; // true if this var has updated class handle or exactness #endif unsigned char lvImplicitlyReferenced : 1; // true if there are non-IR references to this local (prolog, epilog, gc, // eh) unsigned char lvSuppressedZeroInit : 1; // local needs zero init if we transform tail call to loop unsigned char lvHasExplicitInit : 1; // The local is explicitly initialized and doesn't need zero initialization in // the prolog. If the local has gc pointers, there are no gc-safe points // between the prolog and the explicit initialization. union { unsigned lvFieldLclStart; // The index of the local var representing the first field in the promoted struct // local. For implicit byref parameters, this gets hijacked between // fgRetypeImplicitByRefArgs and fgMarkDemotedImplicitByRefArgs to point to the // struct local created to model the parameter's struct promotion, if any. unsigned lvParentLcl; // The index of the local var representing the parent (i.e. the promoted struct local). // Valid on promoted struct local fields. }; unsigned char lvFieldCnt; // Number of fields in the promoted VarDsc. unsigned char lvFldOffset; unsigned char lvFldOrdinal; #ifdef DEBUG unsigned char lvSingleDefDisqualifyReason = 'H'; #endif #if FEATURE_MULTIREG_ARGS regNumber lvRegNumForSlot(unsigned slotNum) { if (slotNum == 0) { return (regNumber)_lvArgReg; } else if (slotNum == 1) { return GetOtherArgReg(); } else { assert(false && "Invalid slotNum!"); } unreached(); } #endif // FEATURE_MULTIREG_ARGS CorInfoHFAElemType GetLvHfaElemKind() const { #ifdef FEATURE_HFA_FIELDS_PRESENT return _lvHfaElemKind; #else NOWAY_MSG("GetLvHfaElemKind"); return CORINFO_HFA_ELEM_NONE; #endif // FEATURE_HFA_FIELDS_PRESENT } void SetLvHfaElemKind(CorInfoHFAElemType elemKind) { #ifdef FEATURE_HFA_FIELDS_PRESENT _lvHfaElemKind = elemKind; #else NOWAY_MSG("SetLvHfaElemKind"); #endif // FEATURE_HFA_FIELDS_PRESENT } bool lvIsHfa() const { if (GlobalJitOptions::compFeatureHfa) { return IsHfa(GetLvHfaElemKind()); } else { return false; } } bool lvIsHfaRegArg() const { if (GlobalJitOptions::compFeatureHfa) { return lvIsRegArg && lvIsHfa(); } else { return false; } } //------------------------------------------------------------------------------ // lvHfaSlots: Get the number of slots used by an HFA local // // Return Value: // On Arm64 - Returns 1-4 indicating the number of register slots used by the HFA // On Arm32 - Returns the total number of single FP register slots used by the HFA, max is 8 // unsigned lvHfaSlots() const { assert(lvIsHfa()); assert(varTypeIsStruct(lvType)); unsigned slots = 0; #ifdef TARGET_ARM slots = lvExactSize / sizeof(float); assert(slots <= 8); #elif defined(TARGET_ARM64) switch (GetLvHfaElemKind()) { case CORINFO_HFA_ELEM_NONE: assert(!"lvHfaSlots called for non-HFA"); break; case CORINFO_HFA_ELEM_FLOAT: assert((lvExactSize % 4) == 0); slots = lvExactSize >> 2; break; case CORINFO_HFA_ELEM_DOUBLE: case CORINFO_HFA_ELEM_VECTOR64: assert((lvExactSize % 8) == 0); slots = lvExactSize >> 3; break; case CORINFO_HFA_ELEM_VECTOR128: assert((lvExactSize % 16) == 0); slots = lvExactSize >> 4; break; default: unreached(); } assert(slots <= 4); #endif // TARGET_ARM64 return slots; } // lvIsMultiRegArgOrRet() // returns true if this is a multireg LclVar struct used in an argument context // or if this is a multireg LclVar struct assigned from a multireg call bool lvIsMultiRegArgOrRet() { return lvIsMultiRegArg || lvIsMultiRegRet; } #if defined(DEBUG) private: DoNotEnregisterReason m_doNotEnregReason; AddressExposedReason m_addrExposedReason; public: void SetDoNotEnregReason(DoNotEnregisterReason reason) { m_doNotEnregReason = reason; } DoNotEnregisterReason GetDoNotEnregReason() const { return m_doNotEnregReason; } AddressExposedReason GetAddrExposedReason() const { return m_addrExposedReason; } #endif // DEBUG public: void SetAddressExposed(bool value DEBUGARG(AddressExposedReason reason)) { m_addrExposed = value; INDEBUG(m_addrExposedReason = reason); } void CleanAddressExposed() { m_addrExposed = false; } bool IsAddressExposed() const { return m_addrExposed; } private: regNumberSmall _lvRegNum; // Used to store the register this variable is in (or, the low register of a // register pair). It is set during codegen any time the // variable is enregistered (lvRegister is only set // to non-zero if the variable gets the same register assignment for its entire // lifetime). #if !defined(TARGET_64BIT) regNumberSmall _lvOtherReg; // Used for "upper half" of long var. #endif // !defined(TARGET_64BIT) regNumberSmall _lvArgReg; // The (first) register in which this argument is passed. #if FEATURE_MULTIREG_ARGS regNumberSmall _lvOtherArgReg; // Used for the second part of the struct passed in a register. // Note this is defined but not used by ARM32 #endif // FEATURE_MULTIREG_ARGS regNumberSmall _lvArgInitReg; // the register into which the argument is moved at entry public: // The register number is stored in a small format (8 bits), but the getters return and the setters take // a full-size (unsigned) format, to localize the casts here. ///////////////////// regNumber GetRegNum() const { return (regNumber)_lvRegNum; } void SetRegNum(regNumber reg) { _lvRegNum = (regNumberSmall)reg; assert(_lvRegNum == reg); } ///////////////////// #if defined(TARGET_64BIT) regNumber GetOtherReg() const { assert(!"shouldn't get here"); // can't use "unreached();" because it's NORETURN, which causes C4072 // "unreachable code" warnings return REG_NA; } void SetOtherReg(regNumber reg) { assert(!"shouldn't get here"); // can't use "unreached();" because it's NORETURN, which causes C4072 // "unreachable code" warnings } #else // !TARGET_64BIT regNumber GetOtherReg() const { return (regNumber)_lvOtherReg; } void SetOtherReg(regNumber reg) { _lvOtherReg = (regNumberSmall)reg; assert(_lvOtherReg == reg); } #endif // !TARGET_64BIT ///////////////////// regNumber GetArgReg() const { return (regNumber)_lvArgReg; } void SetArgReg(regNumber reg) { _lvArgReg = (regNumberSmall)reg; assert(_lvArgReg == reg); } #if FEATURE_MULTIREG_ARGS regNumber GetOtherArgReg() const { return (regNumber)_lvOtherArgReg; } void SetOtherArgReg(regNumber reg) { _lvOtherArgReg = (regNumberSmall)reg; assert(_lvOtherArgReg == reg); } #endif // FEATURE_MULTIREG_ARGS #ifdef FEATURE_SIMD // Is this is a SIMD struct? bool lvIsSIMDType() const { return lvSIMDType; } // Is this is a SIMD struct which is used for SIMD intrinsic? bool lvIsUsedInSIMDIntrinsic() const { return lvUsedInSIMDIntrinsic; } #else // If feature_simd not enabled, return false bool lvIsSIMDType() const { return false; } bool lvIsUsedInSIMDIntrinsic() const { return false; } #endif ///////////////////// regNumber GetArgInitReg() const { return (regNumber)_lvArgInitReg; } void SetArgInitReg(regNumber reg) { _lvArgInitReg = (regNumberSmall)reg; assert(_lvArgInitReg == reg); } ///////////////////// bool lvIsRegCandidate() const { return lvLRACandidate != 0; } bool lvIsInReg() const { return lvIsRegCandidate() && (GetRegNum() != REG_STK); } regMaskTP lvRegMask() const { regMaskTP regMask = RBM_NONE; if (varTypeUsesFloatReg(TypeGet())) { if (GetRegNum() != REG_STK) { regMask = genRegMaskFloat(GetRegNum(), TypeGet()); } } else { if (GetRegNum() != REG_STK) { regMask = genRegMask(GetRegNum()); } } return regMask; } unsigned short lvVarIndex; // variable tracking index private: unsigned short m_lvRefCnt; // unweighted (real) reference count. For implicit by reference // parameters, this gets hijacked from fgResetImplicitByRefRefCount // through fgMarkDemotedImplicitByRefArgs, to provide a static // appearance count (computed during address-exposed analysis) // that fgMakeOutgoingStructArgCopy consults during global morph // to determine if eliding its copy is legal. weight_t m_lvRefCntWtd; // weighted reference count public: unsigned short lvRefCnt(RefCountState state = RCS_NORMAL) const; void incLvRefCnt(unsigned short delta, RefCountState state = RCS_NORMAL); void setLvRefCnt(unsigned short newValue, RefCountState state = RCS_NORMAL); weight_t lvRefCntWtd(RefCountState state = RCS_NORMAL) const; void incLvRefCntWtd(weight_t delta, RefCountState state = RCS_NORMAL); void setLvRefCntWtd(weight_t newValue, RefCountState state = RCS_NORMAL); private: int lvStkOffs; // stack offset of home in bytes. public: int GetStackOffset() const { return lvStkOffs; } void SetStackOffset(int offset) { lvStkOffs = offset; } unsigned lvExactSize; // (exact) size of the type in bytes // Is this a promoted struct? // This method returns true only for structs (including SIMD structs), not for // locals that are split on a 32-bit target. // It is only necessary to use this: // 1) if only structs are wanted, and // 2) if Lowering has already been done. // Otherwise lvPromoted is valid. bool lvPromotedStruct() { #if !defined(TARGET_64BIT) return (lvPromoted && !varTypeIsLong(lvType)); #else // defined(TARGET_64BIT) return lvPromoted; #endif // defined(TARGET_64BIT) } unsigned lvSize() const; size_t lvArgStackSize() const; unsigned lvSlotNum; // original slot # (if remapped) typeInfo lvVerTypeInfo; // type info needed for verification // class handle for the local or null if not known or not a class, // for a struct handle use `GetStructHnd()`. CORINFO_CLASS_HANDLE lvClassHnd; // Get class handle for a struct local or implicitByRef struct local. CORINFO_CLASS_HANDLE GetStructHnd() const { #ifdef FEATURE_SIMD if (lvSIMDType && (m_layout == nullptr)) { return NO_CLASS_HANDLE; } #endif assert(m_layout != nullptr); #if defined(TARGET_AMD64) || defined(TARGET_ARM64) assert(varTypeIsStruct(TypeGet()) || (lvIsImplicitByRef && (TypeGet() == TYP_BYREF))); #else assert(varTypeIsStruct(TypeGet())); #endif CORINFO_CLASS_HANDLE structHnd = m_layout->GetClassHandle(); assert(structHnd != NO_CLASS_HANDLE); return structHnd; } CORINFO_FIELD_HANDLE lvFieldHnd; // field handle for promoted struct fields private: ClassLayout* m_layout; // layout info for structs public: BlockSet lvRefBlks; // Set of blocks that contain refs Statement* lvDefStmt; // Pointer to the statement with the single definition void lvaDisqualifyVar(); // Call to disqualify a local variable from use in optAddCopies var_types TypeGet() const { return (var_types)lvType; } bool lvStackAligned() const { assert(lvIsStructField); return ((lvFldOffset % TARGET_POINTER_SIZE) == 0); } bool lvNormalizeOnLoad() const { return varTypeIsSmall(TypeGet()) && // lvIsStructField is treated the same as the aliased local, see fgDoNormalizeOnStore. (lvIsParam || m_addrExposed || lvIsStructField); } bool lvNormalizeOnStore() const { return varTypeIsSmall(TypeGet()) && // lvIsStructField is treated the same as the aliased local, see fgDoNormalizeOnStore. !(lvIsParam || m_addrExposed || lvIsStructField); } void incRefCnts(weight_t weight, Compiler* pComp, RefCountState state = RCS_NORMAL, bool propagate = true); var_types GetHfaType() const { if (GlobalJitOptions::compFeatureHfa) { assert(lvIsHfa()); return HfaTypeFromElemKind(GetLvHfaElemKind()); } else { return TYP_UNDEF; } } void SetHfaType(var_types type) { if (GlobalJitOptions::compFeatureHfa) { CorInfoHFAElemType elemKind = HfaElemKindFromType(type); SetLvHfaElemKind(elemKind); // Ensure we've allocated enough bits. assert(GetLvHfaElemKind() == elemKind); } } // Returns true if this variable contains GC pointers (including being a GC pointer itself). bool HasGCPtr() const { return varTypeIsGC(lvType) || ((lvType == TYP_STRUCT) && m_layout->HasGCPtr()); } // Returns the layout of a struct variable. ClassLayout* GetLayout() const { assert(varTypeIsStruct(lvType)); return m_layout; } // Sets the layout of a struct variable. void SetLayout(ClassLayout* layout) { assert(varTypeIsStruct(lvType)); assert((m_layout == nullptr) || ClassLayout::AreCompatible(m_layout, layout)); m_layout = layout; } SsaDefArray<LclSsaVarDsc> lvPerSsaData; // Returns the address of the per-Ssa data for the given ssaNum (which is required // not to be the SsaConfig::RESERVED_SSA_NUM, which indicates that the variable is // not an SSA variable). LclSsaVarDsc* GetPerSsaData(unsigned ssaNum) { return lvPerSsaData.GetSsaDef(ssaNum); } // Returns the SSA number for "ssaDef". Requires "ssaDef" to be a valid definition // of this variable. unsigned GetSsaNumForSsaDef(LclSsaVarDsc* ssaDef) { return lvPerSsaData.GetSsaNum(ssaDef); } var_types GetRegisterType(const GenTreeLclVarCommon* tree) const; var_types GetRegisterType() const; var_types GetActualRegisterType() const; bool IsEnregisterableType() const { return GetRegisterType() != TYP_UNDEF; } bool IsEnregisterableLcl() const { if (lvDoNotEnregister) { return false; } return IsEnregisterableType(); } //----------------------------------------------------------------------------- // IsAlwaysAliveInMemory: Determines if this variable's value is always // up-to-date on stack. This is possible if this is an EH-var or // we decided to spill after single-def. // bool IsAlwaysAliveInMemory() const { return lvLiveInOutOfHndlr || lvSpillAtSingleDef; } bool CanBeReplacedWithItsField(Compiler* comp) const; #ifdef DEBUG public: const char* lvReason; void PrintVarReg() const { printf("%s", getRegName(GetRegNum())); } #endif // DEBUG }; // class LclVarDsc enum class SymbolicIntegerValue : int32_t { LongMin, IntMin, ShortMin, ByteMin, Zero, One, ByteMax, UByteMax, ShortMax, UShortMax, IntMax, UIntMax, LongMax, }; inline constexpr bool operator>(SymbolicIntegerValue left, SymbolicIntegerValue right) { return static_cast<int32_t>(left) > static_cast<int32_t>(right); } inline constexpr bool operator>=(SymbolicIntegerValue left, SymbolicIntegerValue right) { return static_cast<int32_t>(left) >= static_cast<int32_t>(right); } inline constexpr bool operator<(SymbolicIntegerValue left, SymbolicIntegerValue right) { return static_cast<int32_t>(left) < static_cast<int32_t>(right); } inline constexpr bool operator<=(SymbolicIntegerValue left, SymbolicIntegerValue right) { return static_cast<int32_t>(left) <= static_cast<int32_t>(right); } // Represents an integral range useful for reasoning about integral casts. // It uses a symbolic representation for lower and upper bounds so // that it can efficiently handle integers of all sizes on all hosts. // // Note that the ranges represented by this class are **always** in the // "signed" domain. This is so that if we know the range a node produces, it // can be trivially used to determine if a cast above the node does or does not // overflow, which requires that the interpretation of integers be the same both // for the "input" and "output". We choose signed interpretation here because it // produces nice continuous ranges and because IR uses sign-extension for constants. // // Some examples of how ranges are computed for casts: // 1. CAST_OVF(ubyte <- uint): does not overflow for [0..UBYTE_MAX], produces the // same range - all casts that do not change the representation, i. e. have the same // "actual" input and output type, have the same "input" and "output" range. // 2. CAST_OVF(ulong <- uint): never oveflows => the "input" range is [INT_MIN..INT_MAX] // (aka all possible 32 bit integers). Produces [0..UINT_MAX] (aka all possible 32 // bit integers zero-extended to 64 bits). // 3. CAST_OVF(int <- uint): overflows for inputs larger than INT_MAX <=> less than 0 // when interpreting as signed => the "input" range is [0..INT_MAX], the same range // being the produced one as the node does not change the width of the integer. // class IntegralRange { private: SymbolicIntegerValue m_lowerBound; SymbolicIntegerValue m_upperBound; public: IntegralRange() = default; IntegralRange(SymbolicIntegerValue lowerBound, SymbolicIntegerValue upperBound) : m_lowerBound(lowerBound), m_upperBound(upperBound) { assert(lowerBound <= upperBound); } bool Contains(int64_t value) const; bool Contains(IntegralRange other) const { return (m_lowerBound <= other.m_lowerBound) && (other.m_upperBound <= m_upperBound); } bool IsPositive() { return m_lowerBound >= SymbolicIntegerValue::Zero; } bool Equals(IntegralRange other) const { return (m_lowerBound == other.m_lowerBound) && (m_upperBound == other.m_upperBound); } static int64_t SymbolicToRealValue(SymbolicIntegerValue value); static SymbolicIntegerValue LowerBoundForType(var_types type); static SymbolicIntegerValue UpperBoundForType(var_types type); static IntegralRange ForType(var_types type) { return {LowerBoundForType(type), UpperBoundForType(type)}; } static IntegralRange ForNode(GenTree* node, Compiler* compiler); static IntegralRange ForCastInput(GenTreeCast* cast); static IntegralRange ForCastOutput(GenTreeCast* cast); #ifdef DEBUG static void Print(IntegralRange range); #endif // DEBUG }; /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX TempsInfo XX XX XX XX The temporary lclVars allocated by the compiler for code generation XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ /***************************************************************************** * * The following keeps track of temporaries allocated in the stack frame * during code-generation (after register allocation). These spill-temps are * only used if we run out of registers while evaluating a tree. * * These are different from the more common temps allocated by lvaGrabTemp(). */ class TempDsc { public: TempDsc* tdNext; private: int tdOffs; #ifdef DEBUG static const int BAD_TEMP_OFFSET = 0xDDDDDDDD; // used as a sentinel "bad value" for tdOffs in DEBUG #endif // DEBUG int tdNum; BYTE tdSize; var_types tdType; public: TempDsc(int _tdNum, unsigned _tdSize, var_types _tdType) : tdNum(_tdNum), tdSize((BYTE)_tdSize), tdType(_tdType) { #ifdef DEBUG // temps must have a negative number (so they have a different number from all local variables) assert(tdNum < 0); tdOffs = BAD_TEMP_OFFSET; #endif // DEBUG if (tdNum != _tdNum) { IMPL_LIMITATION("too many spill temps"); } } #ifdef DEBUG bool tdLegalOffset() const { return tdOffs != BAD_TEMP_OFFSET; } #endif // DEBUG int tdTempOffs() const { assert(tdLegalOffset()); return tdOffs; } void tdSetTempOffs(int offs) { tdOffs = offs; assert(tdLegalOffset()); } void tdAdjustTempOffs(int offs) { tdOffs += offs; assert(tdLegalOffset()); } int tdTempNum() const { assert(tdNum < 0); return tdNum; } unsigned tdTempSize() const { return tdSize; } var_types tdTempType() const { return tdType; } }; // interface to hide linearscan implementation from rest of compiler class LinearScanInterface { public: virtual void doLinearScan() = 0; virtual void recordVarLocationsAtStartOfBB(BasicBlock* bb) = 0; virtual bool willEnregisterLocalVars() const = 0; #if TRACK_LSRA_STATS virtual void dumpLsraStatsCsv(FILE* file) = 0; virtual void dumpLsraStatsSummary(FILE* file) = 0; #endif // TRACK_LSRA_STATS }; LinearScanInterface* getLinearScanAllocator(Compiler* comp); // Information about arrays: their element type and size, and the offset of the first element. // We label GT_IND's that are array indices with GTF_IND_ARR_INDEX, and, for such nodes, // associate an array info via the map retrieved by GetArrayInfoMap(). This information is used, // for example, in value numbering of array index expressions. struct ArrayInfo { var_types m_elemType; CORINFO_CLASS_HANDLE m_elemStructType; unsigned m_elemSize; unsigned m_elemOffset; ArrayInfo() : m_elemType(TYP_UNDEF), m_elemStructType(nullptr), m_elemSize(0), m_elemOffset(0) { } ArrayInfo(var_types elemType, unsigned elemSize, unsigned elemOffset, CORINFO_CLASS_HANDLE elemStructType) : m_elemType(elemType), m_elemStructType(elemStructType), m_elemSize(elemSize), m_elemOffset(elemOffset) { } }; // This enumeration names the phases into which we divide compilation. The phases should completely // partition a compilation. enum Phases { #define CompPhaseNameMacro(enum_nm, string_nm, short_nm, hasChildren, parent, measureIR) enum_nm, #include "compphases.h" PHASE_NUMBER_OF }; extern const char* PhaseNames[]; extern const char* PhaseEnums[]; extern const LPCWSTR PhaseShortNames[]; // Specify which checks should be run after each phase // enum class PhaseChecks { CHECK_NONE, CHECK_ALL }; // Specify compiler data that a phase might modify enum class PhaseStatus : unsigned { MODIFIED_NOTHING, MODIFIED_EVERYTHING }; // The following enum provides a simple 1:1 mapping to CLR API's enum API_ICorJitInfo_Names { #define DEF_CLR_API(name) API_##name, #include "ICorJitInfo_API_names.h" API_COUNT }; //--------------------------------------------------------------- // Compilation time. // // A "CompTimeInfo" is a structure for tracking the compilation time of one or more methods. // We divide a compilation into a sequence of contiguous phases, and track the total (per-thread) cycles // of the compilation, as well as the cycles for each phase. We also track the number of bytecodes. // If there is a failure in reading a timer at any point, the "CompTimeInfo" becomes invalid, as indicated // by "m_timerFailure" being true. // If FEATURE_JIT_METHOD_PERF is not set, we define a minimal form of this, enough to let other code compile. struct CompTimeInfo { #ifdef FEATURE_JIT_METHOD_PERF // The string names of the phases. static const char* PhaseNames[]; static bool PhaseHasChildren[]; static int PhaseParent[]; static bool PhaseReportsIRSize[]; unsigned m_byteCodeBytes; unsigned __int64 m_totalCycles; unsigned __int64 m_invokesByPhase[PHASE_NUMBER_OF]; unsigned __int64 m_cyclesByPhase[PHASE_NUMBER_OF]; #if MEASURE_CLRAPI_CALLS unsigned __int64 m_CLRinvokesByPhase[PHASE_NUMBER_OF]; unsigned __int64 m_CLRcyclesByPhase[PHASE_NUMBER_OF]; #endif unsigned m_nodeCountAfterPhase[PHASE_NUMBER_OF]; // For better documentation, we call EndPhase on // non-leaf phases. We should also call EndPhase on the // last leaf subphase; obviously, the elapsed cycles between the EndPhase // for the last leaf subphase and the EndPhase for an ancestor should be very small. // We add all such "redundant end phase" intervals to this variable below; we print // it out in a report, so we can verify that it is, indeed, very small. If it ever // isn't, this means that we're doing something significant between the end of the last // declared subphase and the end of its parent. unsigned __int64 m_parentPhaseEndSlop; bool m_timerFailure; #if MEASURE_CLRAPI_CALLS // The following measures the time spent inside each individual CLR API call. unsigned m_allClrAPIcalls; unsigned m_perClrAPIcalls[API_ICorJitInfo_Names::API_COUNT]; unsigned __int64 m_allClrAPIcycles; unsigned __int64 m_perClrAPIcycles[API_ICorJitInfo_Names::API_COUNT]; unsigned __int32 m_maxClrAPIcycles[API_ICorJitInfo_Names::API_COUNT]; #endif // MEASURE_CLRAPI_CALLS CompTimeInfo(unsigned byteCodeBytes); #endif }; #ifdef FEATURE_JIT_METHOD_PERF #if MEASURE_CLRAPI_CALLS struct WrapICorJitInfo; #endif // This class summarizes the JIT time information over the course of a run: the number of methods compiled, // and the total and maximum timings. (These are instances of the "CompTimeInfo" type described above). // The operation of adding a single method's timing to the summary may be performed concurrently by several // threads, so it is protected by a lock. // This class is intended to be used as a singleton type, with only a single instance. class CompTimeSummaryInfo { // This lock protects the fields of all CompTimeSummaryInfo(s) (of which we expect there to be one). static CritSecObject s_compTimeSummaryLock; int m_numMethods; int m_totMethods; CompTimeInfo m_total; CompTimeInfo m_maximum; int m_numFilteredMethods; CompTimeInfo m_filtered; // This can use what ever data you want to determine if the value to be added // belongs in the filtered section (it's always included in the unfiltered section) bool IncludedInFilteredData(CompTimeInfo& info); public: // This is the unique CompTimeSummaryInfo object for this instance of the runtime. static CompTimeSummaryInfo s_compTimeSummary; CompTimeSummaryInfo() : m_numMethods(0), m_totMethods(0), m_total(0), m_maximum(0), m_numFilteredMethods(0), m_filtered(0) { } // Assumes that "info" is a completed CompTimeInfo for a compilation; adds it to the summary. // This is thread safe. void AddInfo(CompTimeInfo& info, bool includePhases); // Print the summary information to "f". // This is not thread-safe; assumed to be called by only one thread. void Print(FILE* f); }; // A JitTimer encapsulates a CompTimeInfo for a single compilation. It also tracks the start of compilation, // and when the current phase started. This is intended to be part of a Compilation object. // class JitTimer { unsigned __int64 m_start; // Start of the compilation. unsigned __int64 m_curPhaseStart; // Start of the current phase. #if MEASURE_CLRAPI_CALLS unsigned __int64 m_CLRcallStart; // Start of the current CLR API call (if any). unsigned __int64 m_CLRcallInvokes; // CLR API invokes under current outer so far unsigned __int64 m_CLRcallCycles; // CLR API cycles under current outer so far. int m_CLRcallAPInum; // The enum/index of the current CLR API call (or -1). static double s_cyclesPerSec; // Cached for speedier measurements #endif #ifdef DEBUG Phases m_lastPhase; // The last phase that was completed (or (Phases)-1 to start). #endif CompTimeInfo m_info; // The CompTimeInfo for this compilation. static CritSecObject s_csvLock; // Lock to protect the time log file. static FILE* s_csvFile; // The time log file handle. void PrintCsvMethodStats(Compiler* comp); private: void* operator new(size_t); void* operator new[](size_t); void operator delete(void*); void operator delete[](void*); public: // Initialized the timer instance JitTimer(unsigned byteCodeSize); static JitTimer* Create(Compiler* comp, unsigned byteCodeSize) { return ::new (comp, CMK_Unknown) JitTimer(byteCodeSize); } static void PrintCsvHeader(); // Ends the current phase (argument is for a redundant check). void EndPhase(Compiler* compiler, Phases phase); #if MEASURE_CLRAPI_CALLS // Start and end a timed CLR API call. void CLRApiCallEnter(unsigned apix); void CLRApiCallLeave(unsigned apix); #endif // MEASURE_CLRAPI_CALLS // Completes the timing of the current method, which is assumed to have "byteCodeBytes" bytes of bytecode, // and adds it to "sum". void Terminate(Compiler* comp, CompTimeSummaryInfo& sum, bool includePhases); // Attempts to query the cycle counter of the current thread. If successful, returns "true" and sets // *cycles to the cycle counter value. Otherwise, returns false and sets the "m_timerFailure" flag of // "m_info" to true. bool GetThreadCycles(unsigned __int64* cycles) { bool res = CycleTimer::GetThreadCyclesS(cycles); if (!res) { m_info.m_timerFailure = true; } return res; } static void Shutdown(); }; #endif // FEATURE_JIT_METHOD_PERF //------------------- Function/Funclet info ------------------------------- enum FuncKind : BYTE { FUNC_ROOT, // The main/root function (always id==0) FUNC_HANDLER, // a funclet associated with an EH handler (finally, fault, catch, filter handler) FUNC_FILTER, // a funclet associated with an EH filter FUNC_COUNT }; class emitLocation; struct FuncInfoDsc { FuncKind funKind; BYTE funFlags; // Currently unused, just here for padding unsigned short funEHIndex; // index, into the ebd table, of innermost EH clause corresponding to this // funclet. It is only valid if funKind field indicates this is a // EH-related funclet: FUNC_HANDLER or FUNC_FILTER #if defined(TARGET_AMD64) // TODO-AMD64-Throughput: make the AMD64 info more like the ARM info to avoid having this large static array. emitLocation* startLoc; emitLocation* endLoc; emitLocation* coldStartLoc; // locations for the cold section, if there is one. emitLocation* coldEndLoc; UNWIND_INFO unwindHeader; // Maximum of 255 UNWIND_CODE 'nodes' and then the unwind header. If there are an odd // number of codes, the VM or Zapper will 4-byte align the whole thing. BYTE unwindCodes[offsetof(UNWIND_INFO, UnwindCode) + (0xFF * sizeof(UNWIND_CODE))]; unsigned unwindCodeSlot; #elif defined(TARGET_X86) emitLocation* startLoc; emitLocation* endLoc; emitLocation* coldStartLoc; // locations for the cold section, if there is one. emitLocation* coldEndLoc; #elif defined(TARGET_ARMARCH) UnwindInfo uwi; // Unwind information for this function/funclet's hot section UnwindInfo* uwiCold; // Unwind information for this function/funclet's cold section // Note: we only have a pointer here instead of the actual object, // to save memory in the JIT case (compared to the NGEN case), // where we don't have any cold section. // Note 2: we currently don't support hot/cold splitting in functions // with EH, so uwiCold will be NULL for all funclets. emitLocation* startLoc; emitLocation* endLoc; emitLocation* coldStartLoc; // locations for the cold section, if there is one. emitLocation* coldEndLoc; #endif // TARGET_ARMARCH #if defined(FEATURE_CFI_SUPPORT) jitstd::vector<CFI_CODE>* cfiCodes; #endif // FEATURE_CFI_SUPPORT // Eventually we may want to move rsModifiedRegsMask, lvaOutgoingArgSize, and anything else // that isn't shared between the main function body and funclets. }; struct fgArgTabEntry { GenTreeCall::Use* use; // Points to the argument's GenTreeCall::Use in gtCallArgs or gtCallThisArg. GenTreeCall::Use* lateUse; // Points to the argument's GenTreeCall::Use in gtCallLateArgs, if any. // Get the node that coresponds to this argument entry. // This is the "real" node and not a placeholder or setup node. GenTree* GetNode() const { return lateUse == nullptr ? use->GetNode() : lateUse->GetNode(); } unsigned argNum; // The original argument number, also specifies the required argument evaluation order from the IL private: regNumberSmall regNums[MAX_ARG_REG_COUNT]; // The registers to use when passing this argument, set to REG_STK for // arguments passed on the stack public: unsigned numRegs; // Count of number of registers that this argument uses. // Note that on ARM, if we have a double hfa, this reflects the number // of DOUBLE registers. #if defined(UNIX_AMD64_ABI) // Unix amd64 will split floating point types and integer types in structs // between floating point and general purpose registers. Keep track of that // information so we do not need to recompute it later. unsigned structIntRegs; unsigned structFloatRegs; #endif // UNIX_AMD64_ABI #if defined(DEBUG_ARG_SLOTS) // These fields were used to calculate stack size in stack slots for arguments // but now they are replaced by precise `m_byteOffset/m_byteSize` because of // arm64 apple abi requirements. // A slot is a pointer sized region in the OutArg area. unsigned slotNum; // When an argument is passed in the OutArg area this is the slot number in the OutArg area unsigned numSlots; // Count of number of slots that this argument uses #endif // DEBUG_ARG_SLOTS // Return number of stack slots that this argument is taking. // TODO-Cleanup: this function does not align with arm64 apple model, // delete it. In most cases we just want to know if we it is using stack or not // but in some cases we are checking if it is a multireg arg, like: // `numRegs + GetStackSlotsNumber() > 1` that is harder to replace. // unsigned GetStackSlotsNumber() const { return roundUp(GetStackByteSize(), TARGET_POINTER_SIZE) / TARGET_POINTER_SIZE; } private: unsigned _lateArgInx; // index into gtCallLateArgs list; UINT_MAX if this is not a late arg. public: unsigned tmpNum; // the LclVar number if we had to force evaluation of this arg var_types argType; // The type used to pass this argument. This is generally the original argument type, but when a // struct is passed as a scalar type, this is that type. // Note that if a struct is passed by reference, this will still be the struct type. bool needTmp : 1; // True when we force this argument's evaluation into a temp LclVar bool needPlace : 1; // True when we must replace this argument with a placeholder node bool isTmp : 1; // True when we setup a temp LclVar for this argument due to size issues with the struct bool processed : 1; // True when we have decided the evaluation order for this argument in the gtCallLateArgs bool isBackFilled : 1; // True when the argument fills a register slot skipped due to alignment requirements of // previous arguments. NonStandardArgKind nonStandardArgKind : 4; // The non-standard arg kind. Non-standard args are args that are forced // to be in certain registers or on the stack, regardless of where they // appear in the arg list. bool isStruct : 1; // True if this is a struct arg bool _isVararg : 1; // True if the argument is in a vararg context. bool passedByRef : 1; // True iff the argument is passed by reference. #if FEATURE_ARG_SPLIT bool _isSplit : 1; // True when this argument is split between the registers and OutArg area #endif // FEATURE_ARG_SPLIT #ifdef FEATURE_HFA_FIELDS_PRESENT CorInfoHFAElemType _hfaElemKind : 3; // What kind of an HFA this is (CORINFO_HFA_ELEM_NONE if it is not an HFA). #endif CorInfoHFAElemType GetHfaElemKind() const { #ifdef FEATURE_HFA_FIELDS_PRESENT return _hfaElemKind; #else NOWAY_MSG("GetHfaElemKind"); return CORINFO_HFA_ELEM_NONE; #endif } void SetHfaElemKind(CorInfoHFAElemType elemKind) { #ifdef FEATURE_HFA_FIELDS_PRESENT _hfaElemKind = elemKind; #else NOWAY_MSG("SetHfaElemKind"); #endif } bool isNonStandard() const { return nonStandardArgKind != NonStandardArgKind::None; } // Returns true if the IR node for this non-standarg arg is added by fgInitArgInfo. // In this case, it must be removed by GenTreeCall::ResetArgInfo. bool isNonStandardArgAddedLate() const { switch (static_cast<NonStandardArgKind>(nonStandardArgKind)) { case NonStandardArgKind::None: case NonStandardArgKind::PInvokeFrame: case NonStandardArgKind::ShiftLow: case NonStandardArgKind::ShiftHigh: case NonStandardArgKind::FixedRetBuffer: case NonStandardArgKind::ValidateIndirectCallTarget: return false; case NonStandardArgKind::WrapperDelegateCell: case NonStandardArgKind::VirtualStubCell: case NonStandardArgKind::PInvokeCookie: case NonStandardArgKind::PInvokeTarget: case NonStandardArgKind::R2RIndirectionCell: return true; default: unreached(); } } bool isLateArg() const { bool isLate = (_lateArgInx != UINT_MAX); return isLate; } unsigned GetLateArgInx() const { assert(isLateArg()); return _lateArgInx; } void SetLateArgInx(unsigned inx) { _lateArgInx = inx; } regNumber GetRegNum() const { return (regNumber)regNums[0]; } regNumber GetOtherRegNum() const { return (regNumber)regNums[1]; } #if defined(UNIX_AMD64_ABI) SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR structDesc; #endif void setRegNum(unsigned int i, regNumber regNum) { assert(i < MAX_ARG_REG_COUNT); regNums[i] = (regNumberSmall)regNum; } regNumber GetRegNum(unsigned int i) { assert(i < MAX_ARG_REG_COUNT); return (regNumber)regNums[i]; } bool IsSplit() const { #if FEATURE_ARG_SPLIT return compFeatureArgSplit() && _isSplit; #else // FEATURE_ARG_SPLIT return false; #endif } void SetSplit(bool value) { #if FEATURE_ARG_SPLIT _isSplit = value; #endif } bool IsVararg() const { return compFeatureVarArg() && _isVararg; } void SetIsVararg(bool value) { if (compFeatureVarArg()) { _isVararg = value; } } bool IsHfaArg() const { if (GlobalJitOptions::compFeatureHfa) { return IsHfa(GetHfaElemKind()); } else { return false; } } bool IsHfaRegArg() const { if (GlobalJitOptions::compFeatureHfa) { return IsHfa(GetHfaElemKind()) && isPassedInRegisters(); } else { return false; } } unsigned intRegCount() const { #if defined(UNIX_AMD64_ABI) if (this->isStruct) { return this->structIntRegs; } #endif // defined(UNIX_AMD64_ABI) if (!this->isPassedInFloatRegisters()) { return this->numRegs; } return 0; } unsigned floatRegCount() const { #if defined(UNIX_AMD64_ABI) if (this->isStruct) { return this->structFloatRegs; } #endif // defined(UNIX_AMD64_ABI) if (this->isPassedInFloatRegisters()) { return this->numRegs; } return 0; } // Get the number of bytes that this argument is occupying on the stack, // including padding up to the target pointer size for platforms // where a stack argument can't take less. unsigned GetStackByteSize() const { if (!IsSplit() && numRegs > 0) { return 0; } assert(!IsHfaArg() || !IsSplit()); assert(GetByteSize() > TARGET_POINTER_SIZE * numRegs); const unsigned stackByteSize = GetByteSize() - TARGET_POINTER_SIZE * numRegs; return stackByteSize; } var_types GetHfaType() const { if (GlobalJitOptions::compFeatureHfa) { return HfaTypeFromElemKind(GetHfaElemKind()); } else { return TYP_UNDEF; } } void SetHfaType(var_types type, unsigned hfaSlots) { if (GlobalJitOptions::compFeatureHfa) { if (type != TYP_UNDEF) { // We must already have set the passing mode. assert(numRegs != 0 || GetStackByteSize() != 0); // We originally set numRegs according to the size of the struct, but if the size of the // hfaType is not the same as the pointer size, we need to correct it. // Note that hfaSlots is the number of registers we will use. For ARM, that is twice // the number of "double registers". unsigned numHfaRegs = hfaSlots; #ifdef TARGET_ARM if (type == TYP_DOUBLE) { // Must be an even number of registers. assert((numRegs & 1) == 0); numHfaRegs = hfaSlots / 2; } #endif // TARGET_ARM if (!IsHfaArg()) { // We haven't previously set this; do so now. CorInfoHFAElemType elemKind = HfaElemKindFromType(type); SetHfaElemKind(elemKind); // Ensure we've allocated enough bits. assert(GetHfaElemKind() == elemKind); if (isPassedInRegisters()) { numRegs = numHfaRegs; } } else { // We've already set this; ensure that it's consistent. if (isPassedInRegisters()) { assert(numRegs == numHfaRegs); } assert(type == HfaTypeFromElemKind(GetHfaElemKind())); } } } } #ifdef TARGET_ARM void SetIsBackFilled(bool backFilled) { isBackFilled = backFilled; } bool IsBackFilled() const { return isBackFilled; } #else // !TARGET_ARM void SetIsBackFilled(bool backFilled) { } bool IsBackFilled() const { return false; } #endif // !TARGET_ARM bool isPassedInRegisters() const { return !IsSplit() && (numRegs != 0); } bool isPassedInFloatRegisters() const { #ifdef TARGET_X86 return false; #else return isValidFloatArgReg(GetRegNum()); #endif } // Can we replace the struct type of this node with a primitive type for argument passing? bool TryPassAsPrimitive() const { return !IsSplit() && ((numRegs == 1) || (m_byteSize <= TARGET_POINTER_SIZE)); } #if defined(DEBUG_ARG_SLOTS) // Returns the number of "slots" used, where for this purpose a // register counts as a slot. unsigned getSlotCount() const { if (isBackFilled) { assert(isPassedInRegisters()); assert(numRegs == 1); } else if (GetRegNum() == REG_STK) { assert(!isPassedInRegisters()); assert(numRegs == 0); } else { assert(numRegs > 0); } return numSlots + numRegs; } #endif #if defined(DEBUG_ARG_SLOTS) // Returns the size as a multiple of pointer-size. // For targets without HFAs, this is the same as getSlotCount(). unsigned getSize() const { unsigned size = getSlotCount(); if (GlobalJitOptions::compFeatureHfa) { if (IsHfaRegArg()) { #ifdef TARGET_ARM // We counted the number of regs, but if they are DOUBLE hfa regs we have to double the size. if (GetHfaType() == TYP_DOUBLE) { assert(!IsSplit()); size <<= 1; } #elif defined(TARGET_ARM64) // We counted the number of regs, but if they are FLOAT hfa regs we have to halve the size, // or if they are SIMD16 vector hfa regs we have to double the size. if (GetHfaType() == TYP_FLOAT) { // Round up in case of odd HFA count. size = (size + 1) >> 1; } #ifdef FEATURE_SIMD else if (GetHfaType() == TYP_SIMD16) { size <<= 1; } #endif // FEATURE_SIMD #endif // TARGET_ARM64 } } return size; } #endif // DEBUG_ARG_SLOTS private: unsigned m_byteOffset; // byte size that this argument takes including the padding after. // For example, 1-byte arg on x64 with 8-byte alignment // will have `m_byteSize == 8`, the same arg on apple arm64 will have `m_byteSize == 1`. unsigned m_byteSize; unsigned m_byteAlignment; // usually 4 or 8 bytes (slots/registers). public: void SetByteOffset(unsigned byteOffset) { DEBUG_ARG_SLOTS_ASSERT(byteOffset / TARGET_POINTER_SIZE == slotNum); m_byteOffset = byteOffset; } unsigned GetByteOffset() const { DEBUG_ARG_SLOTS_ASSERT(m_byteOffset / TARGET_POINTER_SIZE == slotNum); return m_byteOffset; } void SetByteSize(unsigned byteSize, bool isStruct, bool isFloatHfa) { unsigned roundedByteSize; if (compMacOsArm64Abi()) { // Only struct types need extension or rounding to pointer size, but HFA<float> does not. if (isStruct && !isFloatHfa) { roundedByteSize = roundUp(byteSize, TARGET_POINTER_SIZE); } else { roundedByteSize = byteSize; } } else { roundedByteSize = roundUp(byteSize, TARGET_POINTER_SIZE); } #if !defined(TARGET_ARM) // Arm32 could have a struct with 8 byte alignment // which rounded size % 8 is not 0. assert(m_byteAlignment != 0); assert(roundedByteSize % m_byteAlignment == 0); #endif // TARGET_ARM #if defined(DEBUG_ARG_SLOTS) if (!compMacOsArm64Abi() && !isStruct) { assert(roundedByteSize == getSlotCount() * TARGET_POINTER_SIZE); } #endif m_byteSize = roundedByteSize; } unsigned GetByteSize() const { return m_byteSize; } void SetByteAlignment(unsigned byteAlignment) { m_byteAlignment = byteAlignment; } unsigned GetByteAlignment() const { return m_byteAlignment; } // Set the register numbers for a multireg argument. // There's nothing to do on x64/Ux because the structDesc has already been used to set the // register numbers. void SetMultiRegNums() { #if FEATURE_MULTIREG_ARGS && !defined(UNIX_AMD64_ABI) if (numRegs == 1) { return; } regNumber argReg = GetRegNum(0); #ifdef TARGET_ARM unsigned int regSize = (GetHfaType() == TYP_DOUBLE) ? 2 : 1; #else unsigned int regSize = 1; #endif if (numRegs > MAX_ARG_REG_COUNT) NO_WAY("Multireg argument exceeds the maximum length"); for (unsigned int regIndex = 1; regIndex < numRegs; regIndex++) { argReg = (regNumber)(argReg + regSize); setRegNum(regIndex, argReg); } #endif // FEATURE_MULTIREG_ARGS && !defined(UNIX_AMD64_ABI) } #ifdef DEBUG // Check that the value of 'isStruct' is consistent. // A struct arg must be one of the following: // - A node of struct type, // - A GT_FIELD_LIST, or // - A node of a scalar type, passed in a single register or slot // (or two slots in the case of a struct pass on the stack as TYP_DOUBLE). // void checkIsStruct() const { GenTree* node = GetNode(); if (isStruct) { if (!varTypeIsStruct(node) && !node->OperIs(GT_FIELD_LIST)) { // This is the case where we are passing a struct as a primitive type. // On most targets, this is always a single register or slot. // However, on ARM this could be two slots if it is TYP_DOUBLE. bool isPassedAsPrimitiveType = ((numRegs == 1) || ((numRegs == 0) && (GetByteSize() <= TARGET_POINTER_SIZE))); #ifdef TARGET_ARM if (!isPassedAsPrimitiveType) { if (node->TypeGet() == TYP_DOUBLE && numRegs == 0 && (numSlots == 2)) { isPassedAsPrimitiveType = true; } } #endif // TARGET_ARM assert(isPassedAsPrimitiveType); } } else { assert(!varTypeIsStruct(node)); } } void Dump() const; #endif }; //------------------------------------------------------------------------- // // The class fgArgInfo is used to handle the arguments // when morphing a GT_CALL node. // class fgArgInfo { Compiler* compiler; // Back pointer to the compiler instance so that we can allocate memory GenTreeCall* callTree; // Back pointer to the GT_CALL node for this fgArgInfo unsigned argCount; // Updatable arg count value #if defined(DEBUG_ARG_SLOTS) unsigned nextSlotNum; // Updatable slot count value #endif unsigned nextStackByteOffset; unsigned stkLevel; // Stack depth when we make this call (for x86) #if defined(UNIX_X86_ABI) bool alignmentDone; // Updateable flag, set to 'true' after we've done any required alignment. unsigned stkSizeBytes; // Size of stack used by this call, in bytes. Calculated during fgMorphArgs(). unsigned padStkAlign; // Stack alignment in bytes required before arguments are pushed for this call. // Computed dynamically during codegen, based on stkSizeBytes and the current // stack level (genStackLevel) when the first stack adjustment is made for // this call. #endif #if FEATURE_FIXED_OUT_ARGS unsigned outArgSize; // Size of the out arg area for the call, will be at least MIN_ARG_AREA_FOR_CALL #endif unsigned argTableSize; // size of argTable array (equal to the argCount when done with fgMorphArgs) bool hasRegArgs; // true if we have one or more register arguments bool hasStackArgs; // true if we have one or more stack arguments bool argsComplete; // marker for state bool argsSorted; // marker for state bool needsTemps; // one or more arguments must be copied to a temp by EvalArgsToTemps fgArgTabEntry** argTable; // variable sized array of per argument descrption: (i.e. argTable[argTableSize]) private: void AddArg(fgArgTabEntry* curArgTabEntry); public: fgArgInfo(Compiler* comp, GenTreeCall* call, unsigned argCount); fgArgInfo(GenTreeCall* newCall, GenTreeCall* oldCall); fgArgTabEntry* AddRegArg(unsigned argNum, GenTree* node, GenTreeCall::Use* use, regNumber regNum, unsigned numRegs, unsigned byteSize, unsigned byteAlignment, bool isStruct, bool isFloatHfa, bool isVararg = false); #ifdef UNIX_AMD64_ABI fgArgTabEntry* AddRegArg(unsigned argNum, GenTree* node, GenTreeCall::Use* use, regNumber regNum, unsigned numRegs, unsigned byteSize, unsigned byteAlignment, const bool isStruct, const bool isFloatHfa, const bool isVararg, const regNumber otherRegNum, const unsigned structIntRegs, const unsigned structFloatRegs, const SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR* const structDescPtr = nullptr); #endif // UNIX_AMD64_ABI fgArgTabEntry* AddStkArg(unsigned argNum, GenTree* node, GenTreeCall::Use* use, unsigned numSlots, unsigned byteSize, unsigned byteAlignment, bool isStruct, bool isFloatHfa, bool isVararg = false); void RemorphReset(); void UpdateRegArg(fgArgTabEntry* argEntry, GenTree* node, bool reMorphing); void UpdateStkArg(fgArgTabEntry* argEntry, GenTree* node, bool reMorphing); void SplitArg(unsigned argNum, unsigned numRegs, unsigned numSlots); void EvalToTmp(fgArgTabEntry* curArgTabEntry, unsigned tmpNum, GenTree* newNode); void ArgsComplete(); void SortArgs(); void EvalArgsToTemps(); unsigned ArgCount() const { return argCount; } fgArgTabEntry** ArgTable() const { return argTable; } #if defined(DEBUG_ARG_SLOTS) unsigned GetNextSlotNum() const { return nextSlotNum; } #endif unsigned GetNextSlotByteOffset() const { return nextStackByteOffset; } bool HasRegArgs() const { return hasRegArgs; } bool NeedsTemps() const { return needsTemps; } bool HasStackArgs() const { return hasStackArgs; } bool AreArgsComplete() const { return argsComplete; } #if FEATURE_FIXED_OUT_ARGS unsigned GetOutArgSize() const { return outArgSize; } void SetOutArgSize(unsigned newVal) { outArgSize = newVal; } #endif // FEATURE_FIXED_OUT_ARGS #if defined(UNIX_X86_ABI) void ComputeStackAlignment(unsigned curStackLevelInBytes) { padStkAlign = AlignmentPad(curStackLevelInBytes, STACK_ALIGN); } unsigned GetStkAlign() const { return padStkAlign; } void SetStkSizeBytes(unsigned newStkSizeBytes) { stkSizeBytes = newStkSizeBytes; } unsigned GetStkSizeBytes() const { return stkSizeBytes; } bool IsStkAlignmentDone() const { return alignmentDone; } void SetStkAlignmentDone() { alignmentDone = true; } #endif // defined(UNIX_X86_ABI) // Get the fgArgTabEntry for the arg at position argNum. fgArgTabEntry* GetArgEntry(unsigned argNum, bool reMorphing = true) const { fgArgTabEntry* curArgTabEntry = nullptr; if (!reMorphing) { // The arg table has not yet been sorted. curArgTabEntry = argTable[argNum]; assert(curArgTabEntry->argNum == argNum); return curArgTabEntry; } for (unsigned i = 0; i < argCount; i++) { curArgTabEntry = argTable[i]; if (curArgTabEntry->argNum == argNum) { return curArgTabEntry; } } noway_assert(!"GetArgEntry: argNum not found"); return nullptr; } void SetNeedsTemps() { needsTemps = true; } // Get the node for the arg at position argIndex. // Caller must ensure that this index is a valid arg index. GenTree* GetArgNode(unsigned argIndex) const { return GetArgEntry(argIndex)->GetNode(); } void Dump(Compiler* compiler) const; }; #ifdef DEBUG // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // We have the ability to mark source expressions with "Test Labels." // These drive assertions within the JIT, or internal JIT testing. For example, we could label expressions // that should be CSE defs, and other expressions that should uses of those defs, with a shared label. enum TestLabel // This must be kept identical to System.Runtime.CompilerServices.JitTestLabel.TestLabel. { TL_SsaName, TL_VN, // Defines a "VN equivalence class". (For full VN, including exceptions thrown). TL_VNNorm, // Like above, but uses the non-exceptional value of the expression. TL_CSE_Def, // This must be identified in the JIT as a CSE def TL_CSE_Use, // This must be identified in the JIT as a CSE use TL_LoopHoist, // Expression must (or must not) be hoisted out of the loop. }; struct TestLabelAndNum { TestLabel m_tl; ssize_t m_num; TestLabelAndNum() : m_tl(TestLabel(0)), m_num(0) { } }; typedef JitHashTable<GenTree*, JitPtrKeyFuncs<GenTree>, TestLabelAndNum> NodeToTestDataMap; // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #endif // DEBUG //------------------------------------------------------------------------- // LoopFlags: flags for the loop table. // enum LoopFlags : unsigned short { LPFLG_EMPTY = 0, // LPFLG_UNUSED = 0x0001, // LPFLG_UNUSED = 0x0002, LPFLG_ITER = 0x0004, // loop of form: for (i = icon or lclVar; test_condition(); i++) // LPFLG_UNUSED = 0x0008, LPFLG_CONTAINS_CALL = 0x0010, // If executing the loop body *may* execute a call LPFLG_VAR_INIT = 0x0020, // iterator is initialized with a local var (var # found in lpVarInit) LPFLG_CONST_INIT = 0x0040, // iterator is initialized with a constant (found in lpConstInit) LPFLG_SIMD_LIMIT = 0x0080, // iterator is compared with vector element count (found in lpConstLimit) LPFLG_VAR_LIMIT = 0x0100, // iterator is compared with a local var (var # found in lpVarLimit) LPFLG_CONST_LIMIT = 0x0200, // iterator is compared with a constant (found in lpConstLimit) LPFLG_ARRLEN_LIMIT = 0x0400, // iterator is compared with a.len or a[i].len (found in lpArrLenLimit) LPFLG_HAS_PREHEAD = 0x0800, // lpHead is known to be a preHead for this loop LPFLG_REMOVED = 0x1000, // has been removed from the loop table (unrolled or optimized away) LPFLG_DONT_UNROLL = 0x2000, // do not unroll this loop LPFLG_ASGVARS_YES = 0x4000, // "lpAsgVars" has been computed LPFLG_ASGVARS_INC = 0x8000, // "lpAsgVars" is incomplete -- vars beyond those representable in an AllVarSet // type are assigned to. }; inline constexpr LoopFlags operator~(LoopFlags a) { return (LoopFlags)(~(unsigned short)a); } inline constexpr LoopFlags operator|(LoopFlags a, LoopFlags b) { return (LoopFlags)((unsigned short)a | (unsigned short)b); } inline constexpr LoopFlags operator&(LoopFlags a, LoopFlags b) { return (LoopFlags)((unsigned short)a & (unsigned short)b); } inline LoopFlags& operator|=(LoopFlags& a, LoopFlags b) { return a = (LoopFlags)((unsigned short)a | (unsigned short)b); } inline LoopFlags& operator&=(LoopFlags& a, LoopFlags b) { return a = (LoopFlags)((unsigned short)a & (unsigned short)b); } // The following holds information about instr offsets in terms of generated code. enum class IPmappingDscKind { Prolog, // The mapping represents the start of a prolog. Epilog, // The mapping represents the start of an epilog. NoMapping, // This does not map to any IL offset. Normal, // The mapping maps to an IL offset. }; struct IPmappingDsc { emitLocation ipmdNativeLoc; // the emitter location of the native code corresponding to the IL offset IPmappingDscKind ipmdKind; // The kind of mapping ILLocation ipmdLoc; // The location for normal mappings bool ipmdIsLabel; // Can this code be a branch label? }; struct PreciseIPMapping { emitLocation nativeLoc; DebugInfo debugInfo; }; /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX The big guy. The sections are currently organized as : XX XX XX XX o GenTree and BasicBlock XX XX o LclVarsInfo XX XX o Importer XX XX o FlowGraph XX XX o Optimizer XX XX o RegAlloc XX XX o EEInterface XX XX o TempsInfo XX XX o RegSet XX XX o GCInfo XX XX o Instruction XX XX o ScopeInfo XX XX o PrologScopeInfo XX XX o CodeGenerator XX XX o UnwindInfo XX XX o Compiler XX XX o typeInfo XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ struct HWIntrinsicInfo; class Compiler { friend class emitter; friend class UnwindInfo; friend class UnwindFragmentInfo; friend class UnwindEpilogInfo; friend class JitTimer; friend class LinearScan; friend class fgArgInfo; friend class Rationalizer; friend class Phase; friend class Lowering; friend class CSE_DataFlow; friend class CSE_Heuristic; friend class CodeGenInterface; friend class CodeGen; friend class LclVarDsc; friend class TempDsc; friend class LIR; friend class ObjectAllocator; friend class LocalAddressVisitor; friend struct GenTree; friend class MorphInitBlockHelper; friend class MorphCopyBlockHelper; #ifdef FEATURE_HW_INTRINSICS friend struct HWIntrinsicInfo; #endif // FEATURE_HW_INTRINSICS #ifndef TARGET_64BIT friend class DecomposeLongs; #endif // !TARGET_64BIT /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX Misc structs definitions XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ public: hashBvGlobalData hbvGlobalData; // Used by the hashBv bitvector package. #ifdef DEBUG bool verbose; bool verboseTrees; bool shouldUseVerboseTrees(); bool asciiTrees; // If true, dump trees using only ASCII characters bool shouldDumpASCIITrees(); bool verboseSsa; // If true, produce especially verbose dump output in SSA construction. bool shouldUseVerboseSsa(); bool treesBeforeAfterMorph; // If true, print trees before/after morphing (paired by an intra-compilation id: int morphNum; // This counts the the trees that have been morphed, allowing us to label each uniquely. bool doExtraSuperPmiQueries; void makeExtraStructQueries(CORINFO_CLASS_HANDLE structHandle, int level); // Make queries recursively 'level' deep. const char* VarNameToStr(VarName name) { return name; } DWORD expensiveDebugCheckLevel; #endif #if FEATURE_MULTIREG_RET GenTree* impAssignMultiRegTypeToVar(GenTree* op, CORINFO_CLASS_HANDLE hClass DEBUGARG(CorInfoCallConvExtension callConv)); #endif // FEATURE_MULTIREG_RET #ifdef TARGET_X86 bool isTrivialPointerSizedStruct(CORINFO_CLASS_HANDLE clsHnd) const; #endif // TARGET_X86 //------------------------------------------------------------------------- // Functions to handle homogeneous floating-point aggregates (HFAs) in ARM/ARM64. // HFAs are one to four element structs where each element is the same // type, either all float or all double. We handle HVAs (one to four elements of // vector types) uniformly with HFAs. HFAs are treated specially // in the ARM/ARM64 Procedure Call Standards, specifically, they are passed in // floating-point registers instead of the general purpose registers. // bool IsHfa(CORINFO_CLASS_HANDLE hClass); bool IsHfa(GenTree* tree); var_types GetHfaType(GenTree* tree); unsigned GetHfaCount(GenTree* tree); var_types GetHfaType(CORINFO_CLASS_HANDLE hClass); unsigned GetHfaCount(CORINFO_CLASS_HANDLE hClass); bool IsMultiRegReturnedType(CORINFO_CLASS_HANDLE hClass, CorInfoCallConvExtension callConv); //------------------------------------------------------------------------- // The following is used for validating format of EH table // struct EHNodeDsc; typedef struct EHNodeDsc* pEHNodeDsc; EHNodeDsc* ehnTree; // root of the tree comprising the EHnodes. EHNodeDsc* ehnNext; // root of the tree comprising the EHnodes. struct EHNodeDsc { enum EHBlockType { TryNode, FilterNode, HandlerNode, FinallyNode, FaultNode }; EHBlockType ehnBlockType; // kind of EH block IL_OFFSET ehnStartOffset; // IL offset of start of the EH block IL_OFFSET ehnEndOffset; // IL offset past end of the EH block. (TODO: looks like verInsertEhNode() sets this to // the last IL offset, not "one past the last one", i.e., the range Start to End is // inclusive). pEHNodeDsc ehnNext; // next (non-nested) block in sequential order pEHNodeDsc ehnChild; // leftmost nested block union { pEHNodeDsc ehnTryNode; // for filters and handlers, the corresponding try node pEHNodeDsc ehnHandlerNode; // for a try node, the corresponding handler node }; pEHNodeDsc ehnFilterNode; // if this is a try node and has a filter, otherwise 0 pEHNodeDsc ehnEquivalent; // if blockType=tryNode, start offset and end offset is same, void ehnSetTryNodeType() { ehnBlockType = TryNode; } void ehnSetFilterNodeType() { ehnBlockType = FilterNode; } void ehnSetHandlerNodeType() { ehnBlockType = HandlerNode; } void ehnSetFinallyNodeType() { ehnBlockType = FinallyNode; } void ehnSetFaultNodeType() { ehnBlockType = FaultNode; } bool ehnIsTryBlock() { return ehnBlockType == TryNode; } bool ehnIsFilterBlock() { return ehnBlockType == FilterNode; } bool ehnIsHandlerBlock() { return ehnBlockType == HandlerNode; } bool ehnIsFinallyBlock() { return ehnBlockType == FinallyNode; } bool ehnIsFaultBlock() { return ehnBlockType == FaultNode; } // returns true if there is any overlap between the two nodes static bool ehnIsOverlap(pEHNodeDsc node1, pEHNodeDsc node2) { if (node1->ehnStartOffset < node2->ehnStartOffset) { return (node1->ehnEndOffset >= node2->ehnStartOffset); } else { return (node1->ehnStartOffset <= node2->ehnEndOffset); } } // fails with BADCODE if inner is not completely nested inside outer static bool ehnIsNested(pEHNodeDsc inner, pEHNodeDsc outer) { return ((inner->ehnStartOffset >= outer->ehnStartOffset) && (inner->ehnEndOffset <= outer->ehnEndOffset)); } }; //------------------------------------------------------------------------- // Exception handling functions // #if !defined(FEATURE_EH_FUNCLETS) bool ehNeedsShadowSPslots() { return (info.compXcptnsCount || opts.compDbgEnC); } // 0 for methods with no EH // 1 for methods with non-nested EH, or where only the try blocks are nested // 2 for a method with a catch within a catch // etc. unsigned ehMaxHndNestingCount; #endif // !FEATURE_EH_FUNCLETS static bool jitIsBetween(unsigned value, unsigned start, unsigned end); static bool jitIsBetweenInclusive(unsigned value, unsigned start, unsigned end); bool bbInCatchHandlerILRange(BasicBlock* blk); bool bbInFilterILRange(BasicBlock* blk); bool bbInTryRegions(unsigned regionIndex, BasicBlock* blk); bool bbInExnFlowRegions(unsigned regionIndex, BasicBlock* blk); bool bbInHandlerRegions(unsigned regionIndex, BasicBlock* blk); bool bbInCatchHandlerRegions(BasicBlock* tryBlk, BasicBlock* hndBlk); unsigned short bbFindInnermostCommonTryRegion(BasicBlock* bbOne, BasicBlock* bbTwo); unsigned short bbFindInnermostTryRegionContainingHandlerRegion(unsigned handlerIndex); unsigned short bbFindInnermostHandlerRegionContainingTryRegion(unsigned tryIndex); // Returns true if "block" is the start of a try region. bool bbIsTryBeg(BasicBlock* block); // Returns true if "block" is the start of a handler or filter region. bool bbIsHandlerBeg(BasicBlock* block); // Returns true iff "block" is where control flows if an exception is raised in the // try region, and sets "*regionIndex" to the index of the try for the handler. // Differs from "IsHandlerBeg" in the case of filters, where this is true for the first // block of the filter, but not for the filter's handler. bool bbIsExFlowBlock(BasicBlock* block, unsigned* regionIndex); bool ehHasCallableHandlers(); // Return the EH descriptor for the given region index. EHblkDsc* ehGetDsc(unsigned regionIndex); // Return the EH index given a region descriptor. unsigned ehGetIndex(EHblkDsc* ehDsc); // Return the EH descriptor index of the enclosing try, for the given region index. unsigned ehGetEnclosingTryIndex(unsigned regionIndex); // Return the EH descriptor index of the enclosing handler, for the given region index. unsigned ehGetEnclosingHndIndex(unsigned regionIndex); // Return the EH descriptor for the most nested 'try' region this BasicBlock is a member of (or nullptr if this // block is not in a 'try' region). EHblkDsc* ehGetBlockTryDsc(BasicBlock* block); // Return the EH descriptor for the most nested filter or handler region this BasicBlock is a member of (or nullptr // if this block is not in a filter or handler region). EHblkDsc* ehGetBlockHndDsc(BasicBlock* block); // Return the EH descriptor for the most nested region that may handle exceptions raised in this BasicBlock (or // nullptr if this block's exceptions propagate to caller). EHblkDsc* ehGetBlockExnFlowDsc(BasicBlock* block); EHblkDsc* ehIsBlockTryLast(BasicBlock* block); EHblkDsc* ehIsBlockHndLast(BasicBlock* block); bool ehIsBlockEHLast(BasicBlock* block); bool ehBlockHasExnFlowDsc(BasicBlock* block); // Return the region index of the most nested EH region this block is in. unsigned ehGetMostNestedRegionIndex(BasicBlock* block, bool* inTryRegion); // Find the true enclosing try index, ignoring 'mutual protect' try. Uses IL ranges to check. unsigned ehTrueEnclosingTryIndexIL(unsigned regionIndex); // Return the index of the most nested enclosing region for a particular EH region. Returns NO_ENCLOSING_INDEX // if there is no enclosing region. If the returned index is not NO_ENCLOSING_INDEX, then '*inTryRegion' // is set to 'true' if the enclosing region is a 'try', or 'false' if the enclosing region is a handler. // (It can never be a filter.) unsigned ehGetEnclosingRegionIndex(unsigned regionIndex, bool* inTryRegion); // A block has been deleted. Update the EH table appropriately. void ehUpdateForDeletedBlock(BasicBlock* block); // Determine whether a block can be deleted while preserving the EH normalization rules. bool ehCanDeleteEmptyBlock(BasicBlock* block); // Update the 'last' pointers in the EH table to reflect new or deleted blocks in an EH region. void ehUpdateLastBlocks(BasicBlock* oldLast, BasicBlock* newLast); // For a finally handler, find the region index that the BBJ_CALLFINALLY lives in that calls the handler, // or NO_ENCLOSING_INDEX if the BBJ_CALLFINALLY lives in the main function body. Normally, the index // is the same index as the handler (and the BBJ_CALLFINALLY lives in the 'try' region), but for AMD64 the // BBJ_CALLFINALLY lives in the enclosing try or handler region, whichever is more nested, or the main function // body. If the returned index is not NO_ENCLOSING_INDEX, then '*inTryRegion' is set to 'true' if the // BBJ_CALLFINALLY lives in the returned index's 'try' region, or 'false' if lives in the handler region. (It never // lives in a filter.) unsigned ehGetCallFinallyRegionIndex(unsigned finallyIndex, bool* inTryRegion); // Find the range of basic blocks in which all BBJ_CALLFINALLY will be found that target the 'finallyIndex' region's // handler. Set begBlk to the first block, and endBlk to the block after the last block of the range // (nullptr if the last block is the last block in the program). // Precondition: 'finallyIndex' is the EH region of a try/finally clause. void ehGetCallFinallyBlockRange(unsigned finallyIndex, BasicBlock** begBlk, BasicBlock** endBlk); #ifdef DEBUG // Given a BBJ_CALLFINALLY block and the EH region index of the finally it is calling, return // 'true' if the BBJ_CALLFINALLY is in the correct EH region. bool ehCallFinallyInCorrectRegion(BasicBlock* blockCallFinally, unsigned finallyIndex); #endif // DEBUG #if defined(FEATURE_EH_FUNCLETS) // Do we need a PSPSym in the main function? For codegen purposes, we only need one // if there is a filter that protects a region with a nested EH clause (such as a // try/catch nested in the 'try' body of a try/filter/filter-handler). See // genFuncletProlog() for more details. However, the VM seems to use it for more // purposes, maybe including debugging. Until we are sure otherwise, always create // a PSPSym for functions with any EH. bool ehNeedsPSPSym() const { #ifdef TARGET_X86 return false; #else // TARGET_X86 return compHndBBtabCount > 0; #endif // TARGET_X86 } bool ehAnyFunclets(); // Are there any funclets in this function? unsigned ehFuncletCount(); // Return the count of funclets in the function unsigned bbThrowIndex(BasicBlock* blk); // Get the index to use as the cache key for sharing throw blocks #else // !FEATURE_EH_FUNCLETS bool ehAnyFunclets() { return false; } unsigned ehFuncletCount() { return 0; } unsigned bbThrowIndex(BasicBlock* blk) { return blk->bbTryIndex; } // Get the index to use as the cache key for sharing throw blocks #endif // !FEATURE_EH_FUNCLETS // Returns a flowList representing the "EH predecessors" of "blk". These are the normal predecessors of // "blk", plus one special case: if "blk" is the first block of a handler, considers the predecessor(s) of the first // first block of the corresponding try region to be "EH predecessors". (If there is a single such predecessor, // for example, we want to consider that the immediate dominator of the catch clause start block, so it's // convenient to also consider it a predecessor.) flowList* BlockPredsWithEH(BasicBlock* blk); // This table is useful for memoization of the method above. typedef JitHashTable<BasicBlock*, JitPtrKeyFuncs<BasicBlock>, flowList*> BlockToFlowListMap; BlockToFlowListMap* m_blockToEHPreds; BlockToFlowListMap* GetBlockToEHPreds() { if (m_blockToEHPreds == nullptr) { m_blockToEHPreds = new (getAllocator()) BlockToFlowListMap(getAllocator()); } return m_blockToEHPreds; } void* ehEmitCookie(BasicBlock* block); UNATIVE_OFFSET ehCodeOffset(BasicBlock* block); EHblkDsc* ehInitHndRange(BasicBlock* src, IL_OFFSET* hndBeg, IL_OFFSET* hndEnd, bool* inFilter); EHblkDsc* ehInitTryRange(BasicBlock* src, IL_OFFSET* tryBeg, IL_OFFSET* tryEnd); EHblkDsc* ehInitHndBlockRange(BasicBlock* blk, BasicBlock** hndBeg, BasicBlock** hndLast, bool* inFilter); EHblkDsc* ehInitTryBlockRange(BasicBlock* blk, BasicBlock** tryBeg, BasicBlock** tryLast); void fgSetTryBeg(EHblkDsc* handlerTab, BasicBlock* newTryBeg); void fgSetTryEnd(EHblkDsc* handlerTab, BasicBlock* newTryLast); void fgSetHndEnd(EHblkDsc* handlerTab, BasicBlock* newHndLast); void fgSkipRmvdBlocks(EHblkDsc* handlerTab); void fgAllocEHTable(); void fgRemoveEHTableEntry(unsigned XTnum); #if defined(FEATURE_EH_FUNCLETS) EHblkDsc* fgAddEHTableEntry(unsigned XTnum); #endif // FEATURE_EH_FUNCLETS #if !FEATURE_EH void fgRemoveEH(); #endif // !FEATURE_EH void fgSortEHTable(); // Causes the EH table to obey some well-formedness conditions, by inserting // empty BB's when necessary: // * No block is both the first block of a handler and the first block of a try. // * No block is the first block of multiple 'try' regions. // * No block is the last block of multiple EH regions. void fgNormalizeEH(); bool fgNormalizeEHCase1(); bool fgNormalizeEHCase2(); bool fgNormalizeEHCase3(); void fgCheckForLoopsInHandlers(); #ifdef DEBUG void dispIncomingEHClause(unsigned num, const CORINFO_EH_CLAUSE& clause); void dispOutgoingEHClause(unsigned num, const CORINFO_EH_CLAUSE& clause); void fgVerifyHandlerTab(); void fgDispHandlerTab(); #endif // DEBUG bool fgNeedToSortEHTable; void verInitEHTree(unsigned numEHClauses); void verInsertEhNode(CORINFO_EH_CLAUSE* clause, EHblkDsc* handlerTab); void verInsertEhNodeInTree(EHNodeDsc** ppRoot, EHNodeDsc* node); void verInsertEhNodeParent(EHNodeDsc** ppRoot, EHNodeDsc* node); void verCheckNestingLevel(EHNodeDsc* initRoot); /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX GenTree and BasicBlock XX XX XX XX Functions to allocate and display the GenTrees and BasicBlocks XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ // Functions to create nodes Statement* gtNewStmt(GenTree* expr = nullptr); Statement* gtNewStmt(GenTree* expr, const DebugInfo& di); // For unary opers. GenTree* gtNewOperNode(genTreeOps oper, var_types type, GenTree* op1, bool doSimplifications = TRUE); // For binary opers. GenTree* gtNewOperNode(genTreeOps oper, var_types type, GenTree* op1, GenTree* op2); GenTreeQmark* gtNewQmarkNode(var_types type, GenTree* cond, GenTreeColon* colon); GenTree* gtNewLargeOperNode(genTreeOps oper, var_types type = TYP_I_IMPL, GenTree* op1 = nullptr, GenTree* op2 = nullptr); GenTreeIntCon* gtNewIconNode(ssize_t value, var_types type = TYP_INT); GenTreeIntCon* gtNewIconNode(unsigned fieldOffset, FieldSeqNode* fieldSeq); GenTree* gtNewPhysRegNode(regNumber reg, var_types type); GenTree* gtNewJmpTableNode(); GenTree* gtNewIndOfIconHandleNode(var_types indType, size_t value, GenTreeFlags iconFlags, bool isInvariant); GenTree* gtNewIconHandleNode(size_t value, GenTreeFlags flags, FieldSeqNode* fields = nullptr); GenTreeFlags gtTokenToIconFlags(unsigned token); GenTree* gtNewIconEmbHndNode(void* value, void* pValue, GenTreeFlags flags, void* compileTimeHandle); GenTree* gtNewIconEmbScpHndNode(CORINFO_MODULE_HANDLE scpHnd); GenTree* gtNewIconEmbClsHndNode(CORINFO_CLASS_HANDLE clsHnd); GenTree* gtNewIconEmbMethHndNode(CORINFO_METHOD_HANDLE methHnd); GenTree* gtNewIconEmbFldHndNode(CORINFO_FIELD_HANDLE fldHnd); GenTree* gtNewStringLiteralNode(InfoAccessType iat, void* pValue); GenTreeIntCon* gtNewStringLiteralLength(GenTreeStrCon* node); GenTree* gtNewLconNode(__int64 value); GenTree* gtNewDconNode(double value, var_types type = TYP_DOUBLE); GenTree* gtNewSconNode(int CPX, CORINFO_MODULE_HANDLE scpHandle); GenTree* gtNewZeroConNode(var_types type); GenTree* gtNewOneConNode(var_types type); GenTreeLclVar* gtNewStoreLclVar(unsigned dstLclNum, GenTree* src); #ifdef FEATURE_SIMD GenTree* gtNewSIMDVectorZero(var_types simdType, CorInfoType simdBaseJitType, unsigned simdSize); #endif GenTree* gtNewBlkOpNode(GenTree* dst, GenTree* srcOrFillVal, bool isVolatile, bool isCopyBlock); GenTree* gtNewPutArgReg(var_types type, GenTree* arg, regNumber argReg); GenTree* gtNewBitCastNode(var_types type, GenTree* arg); protected: void gtBlockOpInit(GenTree* result, GenTree* dst, GenTree* srcOrFillVal, bool isVolatile); public: GenTreeObj* gtNewObjNode(CORINFO_CLASS_HANDLE structHnd, GenTree* addr); void gtSetObjGcInfo(GenTreeObj* objNode); GenTree* gtNewStructVal(CORINFO_CLASS_HANDLE structHnd, GenTree* addr); GenTree* gtNewBlockVal(GenTree* addr, unsigned size); GenTree* gtNewCpObjNode(GenTree* dst, GenTree* src, CORINFO_CLASS_HANDLE structHnd, bool isVolatile); GenTreeCall::Use* gtNewCallArgs(GenTree* node); GenTreeCall::Use* gtNewCallArgs(GenTree* node1, GenTree* node2); GenTreeCall::Use* gtNewCallArgs(GenTree* node1, GenTree* node2, GenTree* node3); GenTreeCall::Use* gtNewCallArgs(GenTree* node1, GenTree* node2, GenTree* node3, GenTree* node4); GenTreeCall::Use* gtPrependNewCallArg(GenTree* node, GenTreeCall::Use* args); GenTreeCall::Use* gtInsertNewCallArgAfter(GenTree* node, GenTreeCall::Use* after); GenTreeCall* gtNewCallNode(gtCallTypes callType, CORINFO_METHOD_HANDLE handle, var_types type, GenTreeCall::Use* args, const DebugInfo& di = DebugInfo()); GenTreeCall* gtNewIndCallNode(GenTree* addr, var_types type, GenTreeCall::Use* args, const DebugInfo& di = DebugInfo()); GenTreeCall* gtNewHelperCallNode(unsigned helper, var_types type, GenTreeCall::Use* args = nullptr); GenTreeCall* gtNewRuntimeLookupHelperCallNode(CORINFO_RUNTIME_LOOKUP* pRuntimeLookup, GenTree* ctxTree, void* compileTimeHandle); GenTreeLclVar* gtNewLclvNode(unsigned lnum, var_types type DEBUGARG(IL_OFFSET offs = BAD_IL_OFFSET)); GenTreeLclVar* gtNewLclLNode(unsigned lnum, var_types type DEBUGARG(IL_OFFSET offs = BAD_IL_OFFSET)); GenTreeLclVar* gtNewLclVarAddrNode(unsigned lclNum, var_types type = TYP_I_IMPL); GenTreeLclFld* gtNewLclFldAddrNode(unsigned lclNum, unsigned lclOffs, FieldSeqNode* fieldSeq, var_types type = TYP_I_IMPL); #ifdef FEATURE_SIMD GenTreeSIMD* gtNewSIMDNode( var_types type, GenTree* op1, SIMDIntrinsicID simdIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize); GenTreeSIMD* gtNewSIMDNode(var_types type, GenTree* op1, GenTree* op2, SIMDIntrinsicID simdIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize); void SetOpLclRelatedToSIMDIntrinsic(GenTree* op); #endif #ifdef FEATURE_HW_INTRINSICS GenTreeHWIntrinsic* gtNewSimdHWIntrinsicNode(var_types type, NamedIntrinsic hwIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic = false); GenTreeHWIntrinsic* gtNewSimdHWIntrinsicNode(var_types type, GenTree* op1, NamedIntrinsic hwIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic = false); GenTreeHWIntrinsic* gtNewSimdHWIntrinsicNode(var_types type, GenTree* op1, GenTree* op2, NamedIntrinsic hwIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic = false); GenTreeHWIntrinsic* gtNewSimdHWIntrinsicNode(var_types type, GenTree* op1, GenTree* op2, GenTree* op3, NamedIntrinsic hwIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic = false); GenTreeHWIntrinsic* gtNewSimdHWIntrinsicNode(var_types type, GenTree* op1, GenTree* op2, GenTree* op3, GenTree* op4, NamedIntrinsic hwIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic = false); GenTreeHWIntrinsic* gtNewSimdHWIntrinsicNode(var_types type, GenTree** operands, size_t operandCount, NamedIntrinsic hwIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic = false); GenTreeHWIntrinsic* gtNewSimdHWIntrinsicNode(var_types type, IntrinsicNodeBuilder&& nodeBuilder, NamedIntrinsic hwIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic = false); GenTreeHWIntrinsic* gtNewSimdAsHWIntrinsicNode(var_types type, NamedIntrinsic hwIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize) { bool isSimdAsHWIntrinsic = true; return gtNewSimdHWIntrinsicNode(type, hwIntrinsicID, simdBaseJitType, simdSize, isSimdAsHWIntrinsic); } GenTreeHWIntrinsic* gtNewSimdAsHWIntrinsicNode( var_types type, GenTree* op1, NamedIntrinsic hwIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize) { bool isSimdAsHWIntrinsic = true; return gtNewSimdHWIntrinsicNode(type, op1, hwIntrinsicID, simdBaseJitType, simdSize, isSimdAsHWIntrinsic); } GenTreeHWIntrinsic* gtNewSimdAsHWIntrinsicNode(var_types type, GenTree* op1, GenTree* op2, NamedIntrinsic hwIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize) { bool isSimdAsHWIntrinsic = true; return gtNewSimdHWIntrinsicNode(type, op1, op2, hwIntrinsicID, simdBaseJitType, simdSize, isSimdAsHWIntrinsic); } GenTreeHWIntrinsic* gtNewSimdAsHWIntrinsicNode(var_types type, GenTree* op1, GenTree* op2, GenTree* op3, NamedIntrinsic hwIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize) { bool isSimdAsHWIntrinsic = true; return gtNewSimdHWIntrinsicNode(type, op1, op2, op3, hwIntrinsicID, simdBaseJitType, simdSize, isSimdAsHWIntrinsic); } GenTree* gtNewSimdAbsNode( var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdBinOpNode(genTreeOps op, var_types type, GenTree* op1, GenTree* op2, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdCeilNode( var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdCmpOpNode(genTreeOps op, var_types type, GenTree* op1, GenTree* op2, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdCmpOpAllNode(genTreeOps op, var_types type, GenTree* op1, GenTree* op2, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdCmpOpAnyNode(genTreeOps op, var_types type, GenTree* op1, GenTree* op2, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdCndSelNode(var_types type, GenTree* op1, GenTree* op2, GenTree* op3, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdCreateBroadcastNode( var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdDotProdNode(var_types type, GenTree* op1, GenTree* op2, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdFloorNode( var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdGetElementNode(var_types type, GenTree* op1, GenTree* op2, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdMaxNode(var_types type, GenTree* op1, GenTree* op2, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdMinNode(var_types type, GenTree* op1, GenTree* op2, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdNarrowNode(var_types type, GenTree* op1, GenTree* op2, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdSqrtNode( var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdSumNode( var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdUnOpNode(genTreeOps op, var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdWidenLowerNode( var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdWidenUpperNode( var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdWithElementNode(var_types type, GenTree* op1, GenTree* op2, GenTree* op3, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdZeroNode(var_types type, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTreeHWIntrinsic* gtNewScalarHWIntrinsicNode(var_types type, NamedIntrinsic hwIntrinsicID); GenTreeHWIntrinsic* gtNewScalarHWIntrinsicNode(var_types type, GenTree* op1, NamedIntrinsic hwIntrinsicID); GenTreeHWIntrinsic* gtNewScalarHWIntrinsicNode(var_types type, GenTree* op1, GenTree* op2, NamedIntrinsic hwIntrinsicID); GenTreeHWIntrinsic* gtNewScalarHWIntrinsicNode( var_types type, GenTree* op1, GenTree* op2, GenTree* op3, NamedIntrinsic hwIntrinsicID); CORINFO_CLASS_HANDLE gtGetStructHandleForHWSIMD(var_types simdType, CorInfoType simdBaseJitType); CorInfoType getBaseJitTypeFromArgIfNeeded(NamedIntrinsic intrinsic, CORINFO_CLASS_HANDLE clsHnd, CORINFO_SIG_INFO* sig, CorInfoType simdBaseJitType); #endif // FEATURE_HW_INTRINSICS GenTree* gtNewMustThrowException(unsigned helper, var_types type, CORINFO_CLASS_HANDLE clsHnd); GenTreeLclFld* gtNewLclFldNode(unsigned lnum, var_types type, unsigned offset); GenTree* gtNewInlineCandidateReturnExpr(GenTree* inlineCandidate, var_types type, BasicBlockFlags bbFlags); GenTree* gtNewFieldRef(var_types type, CORINFO_FIELD_HANDLE fldHnd, GenTree* obj = nullptr, DWORD offset = 0); GenTree* gtNewIndexRef(var_types typ, GenTree* arrayOp, GenTree* indexOp); GenTreeArrLen* gtNewArrLen(var_types typ, GenTree* arrayOp, int lenOffset, BasicBlock* block); GenTreeIndir* gtNewIndir(var_types typ, GenTree* addr); GenTree* gtNewNullCheck(GenTree* addr, BasicBlock* basicBlock); var_types gtTypeForNullCheck(GenTree* tree); void gtChangeOperToNullCheck(GenTree* tree, BasicBlock* block); static fgArgTabEntry* gtArgEntryByArgNum(GenTreeCall* call, unsigned argNum); static fgArgTabEntry* gtArgEntryByNode(GenTreeCall* call, GenTree* node); fgArgTabEntry* gtArgEntryByLateArgIndex(GenTreeCall* call, unsigned lateArgInx); static GenTree* gtArgNodeByLateArgInx(GenTreeCall* call, unsigned lateArgInx); GenTreeOp* gtNewAssignNode(GenTree* dst, GenTree* src); GenTree* gtNewTempAssign(unsigned tmp, GenTree* val, Statement** pAfterStmt = nullptr, const DebugInfo& di = DebugInfo(), BasicBlock* block = nullptr); GenTree* gtNewRefCOMfield(GenTree* objPtr, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_ACCESS_FLAGS access, CORINFO_FIELD_INFO* pFieldInfo, var_types lclTyp, CORINFO_CLASS_HANDLE structType, GenTree* assg); GenTree* gtNewNothingNode(); GenTree* gtNewArgPlaceHolderNode(var_types type, CORINFO_CLASS_HANDLE clsHnd); GenTree* gtUnusedValNode(GenTree* expr); GenTree* gtNewKeepAliveNode(GenTree* op); GenTreeCast* gtNewCastNode(var_types typ, GenTree* op1, bool fromUnsigned, var_types castType); GenTreeCast* gtNewCastNodeL(var_types typ, GenTree* op1, bool fromUnsigned, var_types castType); GenTreeAllocObj* gtNewAllocObjNode( unsigned int helper, bool helperHasSideEffects, CORINFO_CLASS_HANDLE clsHnd, var_types type, GenTree* op1); GenTreeAllocObj* gtNewAllocObjNode(CORINFO_RESOLVED_TOKEN* pResolvedToken, bool useParent); GenTree* gtNewRuntimeLookup(CORINFO_GENERIC_HANDLE hnd, CorInfoGenericHandleType hndTyp, GenTree* lookupTree); GenTreeIndir* gtNewMethodTableLookup(GenTree* obj); //------------------------------------------------------------------------ // Other GenTree functions GenTree* gtClone(GenTree* tree, bool complexOK = false); // If `tree` is a lclVar with lclNum `varNum`, return an IntCns with value `varVal`; otherwise, // create a copy of `tree`, adding specified flags, replacing uses of lclVar `deepVarNum` with // IntCnses with value `deepVarVal`. GenTree* gtCloneExpr( GenTree* tree, GenTreeFlags addFlags, unsigned varNum, int varVal, unsigned deepVarNum, int deepVarVal); // Create a copy of `tree`, optionally adding specifed flags, and optionally mapping uses of local // `varNum` to int constants with value `varVal`. GenTree* gtCloneExpr(GenTree* tree, GenTreeFlags addFlags = GTF_EMPTY, unsigned varNum = BAD_VAR_NUM, int varVal = 0) { return gtCloneExpr(tree, addFlags, varNum, varVal, varNum, varVal); } Statement* gtCloneStmt(Statement* stmt) { GenTree* exprClone = gtCloneExpr(stmt->GetRootNode()); return gtNewStmt(exprClone, stmt->GetDebugInfo()); } // Internal helper for cloning a call GenTreeCall* gtCloneExprCallHelper(GenTreeCall* call, GenTreeFlags addFlags = GTF_EMPTY, unsigned deepVarNum = BAD_VAR_NUM, int deepVarVal = 0); // Create copy of an inline or guarded devirtualization candidate tree. GenTreeCall* gtCloneCandidateCall(GenTreeCall* call); void gtUpdateSideEffects(Statement* stmt, GenTree* tree); void gtUpdateTreeAncestorsSideEffects(GenTree* tree); void gtUpdateStmtSideEffects(Statement* stmt); void gtUpdateNodeSideEffects(GenTree* tree); void gtUpdateNodeOperSideEffects(GenTree* tree); void gtUpdateNodeOperSideEffectsPost(GenTree* tree); // Returns "true" iff the complexity (not formally defined, but first interpretation // is #of nodes in subtree) of "tree" is greater than "limit". // (This is somewhat redundant with the "GetCostEx()/GetCostSz()" fields, but can be used // before they have been set.) bool gtComplexityExceeds(GenTree** tree, unsigned limit); GenTree* gtReverseCond(GenTree* tree); static bool gtHasRef(GenTree* tree, ssize_t lclNum); bool gtHasLocalsWithAddrOp(GenTree* tree); unsigned gtSetCallArgsOrder(const GenTreeCall::UseList& args, bool lateArgs, int* callCostEx, int* callCostSz); unsigned gtSetMultiOpOrder(GenTreeMultiOp* multiOp); void gtWalkOp(GenTree** op1, GenTree** op2, GenTree* base, bool constOnly); #ifdef DEBUG unsigned gtHashValue(GenTree* tree); GenTree* gtWalkOpEffectiveVal(GenTree* op); #endif void gtPrepareCost(GenTree* tree); bool gtIsLikelyRegVar(GenTree* tree); // Returns true iff the secondNode can be swapped with firstNode. bool gtCanSwapOrder(GenTree* firstNode, GenTree* secondNode); // Given an address expression, compute its costs and addressing mode opportunities, // and mark addressing mode candidates as GTF_DONT_CSE. // TODO-Throughput - Consider actually instantiating these early, to avoid // having to re-run the algorithm that looks for them (might also improve CQ). bool gtMarkAddrMode(GenTree* addr, int* costEx, int* costSz, var_types type); unsigned gtSetEvalOrder(GenTree* tree); void gtSetStmtInfo(Statement* stmt); // Returns "true" iff "node" has any of the side effects in "flags". bool gtNodeHasSideEffects(GenTree* node, GenTreeFlags flags); // Returns "true" iff "tree" or its (transitive) children have any of the side effects in "flags". bool gtTreeHasSideEffects(GenTree* tree, GenTreeFlags flags); // Appends 'expr' in front of 'list' // 'list' will typically start off as 'nullptr' // when 'list' is non-null a GT_COMMA node is used to insert 'expr' GenTree* gtBuildCommaList(GenTree* list, GenTree* expr); void gtExtractSideEffList(GenTree* expr, GenTree** pList, GenTreeFlags GenTreeFlags = GTF_SIDE_EFFECT, bool ignoreRoot = false); GenTree* gtGetThisArg(GenTreeCall* call); // Static fields of struct types (and sometimes the types that those are reduced to) are represented by having the // static field contain an object pointer to the boxed struct. This simplifies the GC implementation...but // complicates the JIT somewhat. This predicate returns "true" iff a node with type "fieldNodeType", representing // the given "fldHnd", is such an object pointer. bool gtIsStaticFieldPtrToBoxedStruct(var_types fieldNodeType, CORINFO_FIELD_HANDLE fldHnd); // Return true if call is a recursive call; return false otherwise. // Note when inlining, this looks for calls back to the root method. bool gtIsRecursiveCall(GenTreeCall* call) { return gtIsRecursiveCall(call->gtCallMethHnd); } bool gtIsRecursiveCall(CORINFO_METHOD_HANDLE callMethodHandle) { return (callMethodHandle == impInlineRoot()->info.compMethodHnd); } //------------------------------------------------------------------------- GenTree* gtFoldExpr(GenTree* tree); GenTree* gtFoldExprConst(GenTree* tree); GenTree* gtFoldExprSpecial(GenTree* tree); GenTree* gtFoldBoxNullable(GenTree* tree); GenTree* gtFoldExprCompare(GenTree* tree); GenTree* gtCreateHandleCompare(genTreeOps oper, GenTree* op1, GenTree* op2, CorInfoInlineTypeCheck typeCheckInliningResult); GenTree* gtFoldExprCall(GenTreeCall* call); GenTree* gtFoldTypeCompare(GenTree* tree); GenTree* gtFoldTypeEqualityCall(bool isEq, GenTree* op1, GenTree* op2); // Options to control behavior of gtTryRemoveBoxUpstreamEffects enum BoxRemovalOptions { BR_REMOVE_AND_NARROW, // remove effects, minimize remaining work, return possibly narrowed source tree BR_REMOVE_AND_NARROW_WANT_TYPE_HANDLE, // remove effects and minimize remaining work, return type handle tree BR_REMOVE_BUT_NOT_NARROW, // remove effects, return original source tree BR_DONT_REMOVE, // check if removal is possible, return copy source tree BR_DONT_REMOVE_WANT_TYPE_HANDLE, // check if removal is possible, return type handle tree BR_MAKE_LOCAL_COPY // revise box to copy to temp local and return local's address }; GenTree* gtTryRemoveBoxUpstreamEffects(GenTree* tree, BoxRemovalOptions options = BR_REMOVE_AND_NARROW); GenTree* gtOptimizeEnumHasFlag(GenTree* thisOp, GenTree* flagOp); //------------------------------------------------------------------------- // Get the handle, if any. CORINFO_CLASS_HANDLE gtGetStructHandleIfPresent(GenTree* tree); // Get the handle, and assert if not found. CORINFO_CLASS_HANDLE gtGetStructHandle(GenTree* tree); // Get the handle for a ref type. CORINFO_CLASS_HANDLE gtGetClassHandle(GenTree* tree, bool* pIsExact, bool* pIsNonNull); // Get the class handle for an helper call CORINFO_CLASS_HANDLE gtGetHelperCallClassHandle(GenTreeCall* call, bool* pIsExact, bool* pIsNonNull); // Get the element handle for an array of ref type. CORINFO_CLASS_HANDLE gtGetArrayElementClassHandle(GenTree* array); // Get a class handle from a helper call argument CORINFO_CLASS_HANDLE gtGetHelperArgClassHandle(GenTree* array); // Get the class handle for a field CORINFO_CLASS_HANDLE gtGetFieldClassHandle(CORINFO_FIELD_HANDLE fieldHnd, bool* pIsExact, bool* pIsNonNull); // Check if this tree is a gc static base helper call bool gtIsStaticGCBaseHelperCall(GenTree* tree); //------------------------------------------------------------------------- // Functions to display the trees #ifdef DEBUG void gtDispNode(GenTree* tree, IndentStack* indentStack, _In_z_ const char* msg, bool isLIR); void gtDispConst(GenTree* tree); void gtDispLeaf(GenTree* tree, IndentStack* indentStack); void gtDispNodeName(GenTree* tree); #if FEATURE_MULTIREG_RET unsigned gtDispRegCount(GenTree* tree); #endif void gtDispRegVal(GenTree* tree); void gtDispZeroFieldSeq(GenTree* tree); void gtDispVN(GenTree* tree); void gtDispCommonEndLine(GenTree* tree); enum IndentInfo { IINone, IIArc, IIArcTop, IIArcBottom, IIEmbedded, IIError, IndentInfoCount }; void gtDispChild(GenTree* child, IndentStack* indentStack, IndentInfo arcType, _In_opt_ const char* msg = nullptr, bool topOnly = false); void gtDispTree(GenTree* tree, IndentStack* indentStack = nullptr, _In_opt_ const char* msg = nullptr, bool topOnly = false, bool isLIR = false); void gtGetLclVarNameInfo(unsigned lclNum, const char** ilKindOut, const char** ilNameOut, unsigned* ilNumOut); int gtGetLclVarName(unsigned lclNum, char* buf, unsigned buf_remaining); char* gtGetLclVarName(unsigned lclNum); void gtDispLclVar(unsigned lclNum, bool padForBiggestDisp = true); void gtDispLclVarStructType(unsigned lclNum); void gtDispClassLayout(ClassLayout* layout, var_types type); void gtDispILLocation(const ILLocation& loc); void gtDispStmt(Statement* stmt, const char* msg = nullptr); void gtDispBlockStmts(BasicBlock* block); void gtGetArgMsg(GenTreeCall* call, GenTree* arg, unsigned argNum, char* bufp, unsigned bufLength); void gtGetLateArgMsg(GenTreeCall* call, GenTree* arg, int argNum, char* bufp, unsigned bufLength); void gtDispArgList(GenTreeCall* call, GenTree* lastCallOperand, IndentStack* indentStack); void gtDispAnyFieldSeq(FieldSeqNode* fieldSeq); void gtDispFieldSeq(FieldSeqNode* pfsn); void gtDispRange(LIR::ReadOnlyRange const& range); void gtDispTreeRange(LIR::Range& containingRange, GenTree* tree); void gtDispLIRNode(GenTree* node, const char* prefixMsg = nullptr); #endif // For tree walks enum fgWalkResult { WALK_CONTINUE, WALK_SKIP_SUBTREES, WALK_ABORT }; struct fgWalkData; typedef fgWalkResult(fgWalkPreFn)(GenTree** pTree, fgWalkData* data); typedef fgWalkResult(fgWalkPostFn)(GenTree** pTree, fgWalkData* data); static fgWalkPreFn gtMarkColonCond; static fgWalkPreFn gtClearColonCond; struct FindLinkData { GenTree* nodeToFind; GenTree** result; GenTree* parent; }; FindLinkData gtFindLink(Statement* stmt, GenTree* node); bool gtHasCatchArg(GenTree* tree); typedef ArrayStack<GenTree*> GenTreeStack; static bool gtHasCallOnStack(GenTreeStack* parentStack); //========================================================================= // BasicBlock functions #ifdef DEBUG // This is a debug flag we will use to assert when creating block during codegen // as this interferes with procedure splitting. If you know what you're doing, set // it to true before creating the block. (DEBUG only) bool fgSafeBasicBlockCreation; #endif BasicBlock* bbNewBasicBlock(BBjumpKinds jumpKind); void placeLoopAlignInstructions(); /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX LclVarsInfo XX XX XX XX The variables to be used by the code generator. XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ // // For both PROMOTION_TYPE_NONE and PROMOTION_TYPE_DEPENDENT the struct will // be placed in the stack frame and it's fields must be laid out sequentially. // // For PROMOTION_TYPE_INDEPENDENT each of the struct's fields is replaced by // a local variable that can be enregistered or placed in the stack frame. // The fields do not need to be laid out sequentially // enum lvaPromotionType { PROMOTION_TYPE_NONE, // The struct local is not promoted PROMOTION_TYPE_INDEPENDENT, // The struct local is promoted, // and its field locals are independent of its parent struct local. PROMOTION_TYPE_DEPENDENT // The struct local is promoted, // but its field locals depend on its parent struct local. }; /*****************************************************************************/ enum FrameLayoutState { NO_FRAME_LAYOUT, INITIAL_FRAME_LAYOUT, PRE_REGALLOC_FRAME_LAYOUT, REGALLOC_FRAME_LAYOUT, TENTATIVE_FRAME_LAYOUT, FINAL_FRAME_LAYOUT }; public: RefCountState lvaRefCountState; // Current local ref count state bool lvaLocalVarRefCounted() const { return lvaRefCountState == RCS_NORMAL; } bool lvaTrackedFixed; // true: We cannot add new 'tracked' variable unsigned lvaCount; // total number of locals, which includes function arguments, // special arguments, IL local variables, and JIT temporary variables LclVarDsc* lvaTable; // variable descriptor table unsigned lvaTableCnt; // lvaTable size (>= lvaCount) unsigned lvaTrackedCount; // actual # of locals being tracked unsigned lvaTrackedCountInSizeTUnits; // min # of size_t's sufficient to hold a bit for all the locals being tracked #ifdef DEBUG VARSET_TP lvaTrackedVars; // set of tracked variables #endif #ifndef TARGET_64BIT VARSET_TP lvaLongVars; // set of long (64-bit) variables #endif VARSET_TP lvaFloatVars; // set of floating-point (32-bit and 64-bit) variables unsigned lvaCurEpoch; // VarSets are relative to a specific set of tracked var indices. // It that changes, this changes. VarSets from different epochs // cannot be meaningfully combined. unsigned GetCurLVEpoch() { return lvaCurEpoch; } // reverse map of tracked number to var number unsigned lvaTrackedToVarNumSize; unsigned* lvaTrackedToVarNum; #if DOUBLE_ALIGN #ifdef DEBUG // # of procs compiled a with double-aligned stack static unsigned s_lvaDoubleAlignedProcsCount; #endif #endif // Getters and setters for address-exposed and do-not-enregister local var properties. bool lvaVarAddrExposed(unsigned varNum) const; void lvaSetVarAddrExposed(unsigned varNum DEBUGARG(AddressExposedReason reason)); void lvaSetVarLiveInOutOfHandler(unsigned varNum); bool lvaVarDoNotEnregister(unsigned varNum); void lvSetMinOptsDoNotEnreg(); bool lvaEnregEHVars; bool lvaEnregMultiRegVars; void lvaSetVarDoNotEnregister(unsigned varNum DEBUGARG(DoNotEnregisterReason reason)); unsigned lvaVarargsHandleArg; #ifdef TARGET_X86 unsigned lvaVarargsBaseOfStkArgs; // Pointer (computed based on incoming varargs handle) to the start of the stack // arguments #endif // TARGET_X86 unsigned lvaInlinedPInvokeFrameVar; // variable representing the InlinedCallFrame unsigned lvaReversePInvokeFrameVar; // variable representing the reverse PInvoke frame #if FEATURE_FIXED_OUT_ARGS unsigned lvaPInvokeFrameRegSaveVar; // variable representing the RegSave for PInvoke inlining. #endif unsigned lvaMonAcquired; // boolean variable introduced into in synchronized methods // that tracks whether the lock has been taken unsigned lvaArg0Var; // The lclNum of arg0. Normally this will be info.compThisArg. // However, if there is a "ldarga 0" or "starg 0" in the IL, // we will redirect all "ldarg(a) 0" and "starg 0" to this temp. unsigned lvaInlineeReturnSpillTemp; // The temp to spill the non-VOID return expression // in case there are multiple BBJ_RETURN blocks in the inlinee // or if the inlinee has GC ref locals. #if FEATURE_FIXED_OUT_ARGS unsigned lvaOutgoingArgSpaceVar; // dummy TYP_LCLBLK var for fixed outgoing argument space PhasedVar<unsigned> lvaOutgoingArgSpaceSize; // size of fixed outgoing argument space #endif // FEATURE_FIXED_OUT_ARGS static unsigned GetOutgoingArgByteSize(unsigned sizeWithoutPadding) { return roundUp(sizeWithoutPadding, TARGET_POINTER_SIZE); } // Variable representing the return address. The helper-based tailcall // mechanism passes the address of the return address to a runtime helper // where it is used to detect tail-call chains. unsigned lvaRetAddrVar; #if defined(DEBUG) && defined(TARGET_XARCH) unsigned lvaReturnSpCheck; // Stores SP to confirm it is not corrupted on return. #endif // defined(DEBUG) && defined(TARGET_XARCH) #if defined(DEBUG) && defined(TARGET_X86) unsigned lvaCallSpCheck; // Stores SP to confirm it is not corrupted after every call. #endif // defined(DEBUG) && defined(TARGET_X86) bool lvaGenericsContextInUse; bool lvaKeepAliveAndReportThis(); // Synchronized instance method of a reference type, or // CORINFO_GENERICS_CTXT_FROM_THIS? bool lvaReportParamTypeArg(); // Exceptions and CORINFO_GENERICS_CTXT_FROM_PARAMTYPEARG? //------------------------------------------------------------------------- // All these frame offsets are inter-related and must be kept in sync #if !defined(FEATURE_EH_FUNCLETS) // This is used for the callable handlers unsigned lvaShadowSPslotsVar; // TYP_BLK variable for all the shadow SP slots #endif // FEATURE_EH_FUNCLETS int lvaCachedGenericContextArgOffs; int lvaCachedGenericContextArgOffset(); // For CORINFO_CALLCONV_PARAMTYPE and if generic context is passed as // THIS pointer #ifdef JIT32_GCENCODER unsigned lvaLocAllocSPvar; // variable which stores the value of ESP after the the last alloca/localloc #endif // JIT32_GCENCODER unsigned lvaNewObjArrayArgs; // variable with arguments for new MD array helper // TODO-Review: Prior to reg predict we reserve 24 bytes for Spill temps. // after the reg predict we will use a computed maxTmpSize // which is based upon the number of spill temps predicted by reg predict // All this is necessary because if we under-estimate the size of the spill // temps we could fail when encoding instructions that reference stack offsets for ARM. // // Pre codegen max spill temp size. static const unsigned MAX_SPILL_TEMP_SIZE = 24; //------------------------------------------------------------------------- unsigned lvaGetMaxSpillTempSize(); #ifdef TARGET_ARM bool lvaIsPreSpilled(unsigned lclNum, regMaskTP preSpillMask); #endif // TARGET_ARM void lvaAssignFrameOffsets(FrameLayoutState curState); void lvaFixVirtualFrameOffsets(); void lvaUpdateArgWithInitialReg(LclVarDsc* varDsc); void lvaUpdateArgsWithInitialReg(); void lvaAssignVirtualFrameOffsetsToArgs(); #ifdef UNIX_AMD64_ABI int lvaAssignVirtualFrameOffsetToArg(unsigned lclNum, unsigned argSize, int argOffs, int* callerArgOffset); #else // !UNIX_AMD64_ABI int lvaAssignVirtualFrameOffsetToArg(unsigned lclNum, unsigned argSize, int argOffs); #endif // !UNIX_AMD64_ABI void lvaAssignVirtualFrameOffsetsToLocals(); int lvaAllocLocalAndSetVirtualOffset(unsigned lclNum, unsigned size, int stkOffs); #ifdef TARGET_AMD64 // Returns true if compCalleeRegsPushed (including RBP if used as frame pointer) is even. bool lvaIsCalleeSavedIntRegCountEven(); #endif void lvaAlignFrame(); void lvaAssignFrameOffsetsToPromotedStructs(); int lvaAllocateTemps(int stkOffs, bool mustDoubleAlign); #ifdef DEBUG void lvaDumpRegLocation(unsigned lclNum); void lvaDumpFrameLocation(unsigned lclNum); void lvaDumpEntry(unsigned lclNum, FrameLayoutState curState, size_t refCntWtdWidth = 6); void lvaTableDump(FrameLayoutState curState = NO_FRAME_LAYOUT); // NO_FRAME_LAYOUT means use the current frame // layout state defined by lvaDoneFrameLayout #endif // Limit frames size to 1GB. The maximum is 2GB in theory - make it intentionally smaller // to avoid bugs from borderline cases. #define MAX_FrameSize 0x3FFFFFFF void lvaIncrementFrameSize(unsigned size); unsigned lvaFrameSize(FrameLayoutState curState); // Returns the caller-SP-relative offset for the SP/FP relative offset determined by FP based. int lvaToCallerSPRelativeOffset(int offs, bool isFpBased, bool forRootFrame = true) const; // Returns the caller-SP-relative offset for the local variable "varNum." int lvaGetCallerSPRelativeOffset(unsigned varNum); // Returns the SP-relative offset for the local variable "varNum". Illegal to ask this for functions with localloc. int lvaGetSPRelativeOffset(unsigned varNum); int lvaToInitialSPRelativeOffset(unsigned offset, bool isFpBased); int lvaGetInitialSPRelativeOffset(unsigned varNum); // True if this is an OSR compilation and this local is potentially // located on the original method stack frame. bool lvaIsOSRLocal(unsigned varNum); //------------------------ For splitting types ---------------------------- void lvaInitTypeRef(); void lvaInitArgs(InitVarDscInfo* varDscInfo); void lvaInitThisPtr(InitVarDscInfo* varDscInfo); void lvaInitRetBuffArg(InitVarDscInfo* varDscInfo, bool useFixedRetBufReg); void lvaInitUserArgs(InitVarDscInfo* varDscInfo, unsigned skipArgs, unsigned takeArgs); void lvaInitGenericsCtxt(InitVarDscInfo* varDscInfo); void lvaInitVarArgsHandle(InitVarDscInfo* varDscInfo); void lvaInitVarDsc(LclVarDsc* varDsc, unsigned varNum, CorInfoType corInfoType, CORINFO_CLASS_HANDLE typeHnd, CORINFO_ARG_LIST_HANDLE varList, CORINFO_SIG_INFO* varSig); static unsigned lvaTypeRefMask(var_types type); var_types lvaGetActualType(unsigned lclNum); var_types lvaGetRealType(unsigned lclNum); //------------------------------------------------------------------------- void lvaInit(); LclVarDsc* lvaGetDesc(unsigned lclNum) { assert(lclNum < lvaCount); return &lvaTable[lclNum]; } LclVarDsc* lvaGetDesc(unsigned lclNum) const { assert(lclNum < lvaCount); return &lvaTable[lclNum]; } LclVarDsc* lvaGetDesc(const GenTreeLclVarCommon* lclVar) { return lvaGetDesc(lclVar->GetLclNum()); } unsigned lvaTrackedIndexToLclNum(unsigned trackedIndex) { assert(trackedIndex < lvaTrackedCount); unsigned lclNum = lvaTrackedToVarNum[trackedIndex]; assert(lclNum < lvaCount); return lclNum; } LclVarDsc* lvaGetDescByTrackedIndex(unsigned trackedIndex) { return lvaGetDesc(lvaTrackedIndexToLclNum(trackedIndex)); } unsigned lvaGetLclNum(const LclVarDsc* varDsc) { assert((lvaTable <= varDsc) && (varDsc < lvaTable + lvaCount)); // varDsc must point within the table assert(((char*)varDsc - (char*)lvaTable) % sizeof(LclVarDsc) == 0); // varDsc better not point in the middle of a variable unsigned varNum = (unsigned)(varDsc - lvaTable); assert(varDsc == &lvaTable[varNum]); return varNum; } unsigned lvaLclSize(unsigned varNum); unsigned lvaLclExactSize(unsigned varNum); bool lvaHaveManyLocals() const; unsigned lvaGrabTemp(bool shortLifetime DEBUGARG(const char* reason)); unsigned lvaGrabTemps(unsigned cnt DEBUGARG(const char* reason)); unsigned lvaGrabTempWithImplicitUse(bool shortLifetime DEBUGARG(const char* reason)); void lvaSortByRefCount(); void lvaMarkLocalVars(); // Local variable ref-counting void lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers); void lvaMarkLocalVars(BasicBlock* block, bool isRecompute); void lvaAllocOutgoingArgSpaceVar(); // Set up lvaOutgoingArgSpaceVar VARSET_VALRET_TP lvaStmtLclMask(Statement* stmt); #ifdef DEBUG struct lvaStressLclFldArgs { Compiler* m_pCompiler; bool m_bFirstPass; }; static fgWalkPreFn lvaStressLclFldCB; void lvaStressLclFld(); void lvaDispVarSet(VARSET_VALARG_TP set, VARSET_VALARG_TP allVars); void lvaDispVarSet(VARSET_VALARG_TP set); #endif #ifdef TARGET_ARM int lvaFrameAddress(int varNum, bool mustBeFPBased, regNumber* pBaseReg, int addrModeOffset, bool isFloatUsage); #else int lvaFrameAddress(int varNum, bool* pFPbased); #endif bool lvaIsParameter(unsigned varNum); bool lvaIsRegArgument(unsigned varNum); bool lvaIsOriginalThisArg(unsigned varNum); // Is this varNum the original this argument? bool lvaIsOriginalThisReadOnly(); // return true if there is no place in the code // that writes to arg0 // For x64 this is 3, 5, 6, 7, >8 byte structs that are passed by reference. // For ARM64, this is structs larger than 16 bytes that are passed by reference. bool lvaIsImplicitByRefLocal(unsigned varNum) { #if defined(TARGET_AMD64) || defined(TARGET_ARM64) LclVarDsc* varDsc = lvaGetDesc(varNum); if (varDsc->lvIsImplicitByRef) { assert(varDsc->lvIsParam); assert(varTypeIsStruct(varDsc) || (varDsc->lvType == TYP_BYREF)); return true; } #endif // defined(TARGET_AMD64) || defined(TARGET_ARM64) return false; } // Returns true if this local var is a multireg struct bool lvaIsMultiregStruct(LclVarDsc* varDsc, bool isVararg); // If the local is a TYP_STRUCT, get/set a class handle describing it CORINFO_CLASS_HANDLE lvaGetStruct(unsigned varNum); void lvaSetStruct(unsigned varNum, CORINFO_CLASS_HANDLE typeHnd, bool unsafeValueClsCheck, bool setTypeInfo = true); void lvaSetStructUsedAsVarArg(unsigned varNum); // If the local is TYP_REF, set or update the associated class information. void lvaSetClass(unsigned varNum, CORINFO_CLASS_HANDLE clsHnd, bool isExact = false); void lvaSetClass(unsigned varNum, GenTree* tree, CORINFO_CLASS_HANDLE stackHandle = nullptr); void lvaUpdateClass(unsigned varNum, CORINFO_CLASS_HANDLE clsHnd, bool isExact = false); void lvaUpdateClass(unsigned varNum, GenTree* tree, CORINFO_CLASS_HANDLE stackHandle = nullptr); #define MAX_NumOfFieldsInPromotableStruct 4 // Maximum number of fields in promotable struct // Info about struct type fields. struct lvaStructFieldInfo { CORINFO_FIELD_HANDLE fldHnd; unsigned char fldOffset; unsigned char fldOrdinal; var_types fldType; unsigned fldSize; CORINFO_CLASS_HANDLE fldTypeHnd; lvaStructFieldInfo() : fldHnd(nullptr), fldOffset(0), fldOrdinal(0), fldType(TYP_UNDEF), fldSize(0), fldTypeHnd(nullptr) { } }; // Info about a struct type, instances of which may be candidates for promotion. struct lvaStructPromotionInfo { CORINFO_CLASS_HANDLE typeHnd; bool canPromote; bool containsHoles; bool customLayout; bool fieldsSorted; unsigned char fieldCnt; lvaStructFieldInfo fields[MAX_NumOfFieldsInPromotableStruct]; lvaStructPromotionInfo(CORINFO_CLASS_HANDLE typeHnd = nullptr) : typeHnd(typeHnd) , canPromote(false) , containsHoles(false) , customLayout(false) , fieldsSorted(false) , fieldCnt(0) { } }; struct lvaFieldOffsetCmp { bool operator()(const lvaStructFieldInfo& field1, const lvaStructFieldInfo& field2); }; // This class is responsible for checking validity and profitability of struct promotion. // If it is both legal and profitable, then TryPromoteStructVar promotes the struct and initializes // nessesary information for fgMorphStructField to use. class StructPromotionHelper { public: StructPromotionHelper(Compiler* compiler); bool CanPromoteStructType(CORINFO_CLASS_HANDLE typeHnd); bool TryPromoteStructVar(unsigned lclNum); void Clear() { structPromotionInfo.typeHnd = NO_CLASS_HANDLE; } #ifdef DEBUG void CheckRetypedAsScalar(CORINFO_FIELD_HANDLE fieldHnd, var_types requestedType); #endif // DEBUG private: bool CanPromoteStructVar(unsigned lclNum); bool ShouldPromoteStructVar(unsigned lclNum); void PromoteStructVar(unsigned lclNum); void SortStructFields(); lvaStructFieldInfo GetFieldInfo(CORINFO_FIELD_HANDLE fieldHnd, BYTE ordinal); bool TryPromoteStructField(lvaStructFieldInfo& outerFieldInfo); private: Compiler* compiler; lvaStructPromotionInfo structPromotionInfo; #ifdef DEBUG typedef JitHashTable<CORINFO_FIELD_HANDLE, JitPtrKeyFuncs<CORINFO_FIELD_STRUCT_>, var_types> RetypedAsScalarFieldsMap; RetypedAsScalarFieldsMap retypedFieldsMap; #endif // DEBUG }; StructPromotionHelper* structPromotionHelper; unsigned lvaGetFieldLocal(const LclVarDsc* varDsc, unsigned int fldOffset); lvaPromotionType lvaGetPromotionType(const LclVarDsc* varDsc); lvaPromotionType lvaGetPromotionType(unsigned varNum); lvaPromotionType lvaGetParentPromotionType(const LclVarDsc* varDsc); lvaPromotionType lvaGetParentPromotionType(unsigned varNum); bool lvaIsFieldOfDependentlyPromotedStruct(const LclVarDsc* varDsc); bool lvaIsGCTracked(const LclVarDsc* varDsc); #if defined(FEATURE_SIMD) bool lvaMapSimd12ToSimd16(const LclVarDsc* varDsc) { assert(varDsc->lvType == TYP_SIMD12); assert(varDsc->lvExactSize == 12); #if defined(TARGET_64BIT) assert(compMacOsArm64Abi() || varDsc->lvSize() == 16); #endif // defined(TARGET_64BIT) // We make local variable SIMD12 types 16 bytes instead of just 12. // lvSize() will return 16 bytes for SIMD12, even for fields. // However, we can't do that mapping if the var is a dependently promoted struct field. // Such a field must remain its exact size within its parent struct unless it is a single // field *and* it is the only field in a struct of 16 bytes. if (varDsc->lvSize() != 16) { return false; } if (lvaIsFieldOfDependentlyPromotedStruct(varDsc)) { LclVarDsc* parentVarDsc = lvaGetDesc(varDsc->lvParentLcl); return (parentVarDsc->lvFieldCnt == 1) && (parentVarDsc->lvSize() == 16); } return true; } #endif // defined(FEATURE_SIMD) unsigned lvaGSSecurityCookie; // LclVar number bool lvaTempsHaveLargerOffsetThanVars(); // Returns "true" iff local variable "lclNum" is in SSA form. bool lvaInSsa(unsigned lclNum) { assert(lclNum < lvaCount); return lvaTable[lclNum].lvInSsa; } unsigned lvaStubArgumentVar; // variable representing the secret stub argument coming in EAX #if defined(FEATURE_EH_FUNCLETS) unsigned lvaPSPSym; // variable representing the PSPSym #endif InlineInfo* impInlineInfo; // Only present for inlinees InlineStrategy* m_inlineStrategy; InlineContext* compInlineContext; // Always present // The Compiler* that is the root of the inlining tree of which "this" is a member. Compiler* impInlineRoot(); #if defined(DEBUG) || defined(INLINE_DATA) unsigned __int64 getInlineCycleCount() { return m_compCycles; } #endif // defined(DEBUG) || defined(INLINE_DATA) bool fgNoStructPromotion; // Set to TRUE to turn off struct promotion for this method. bool fgNoStructParamPromotion; // Set to TRUE to turn off struct promotion for parameters this method. //========================================================================= // PROTECTED //========================================================================= protected: //---------------- Local variable ref-counting ---------------------------- void lvaMarkLclRefs(GenTree* tree, BasicBlock* block, Statement* stmt, bool isRecompute); bool IsDominatedByExceptionalEntry(BasicBlock* block); void SetVolatileHint(LclVarDsc* varDsc); // Keeps the mapping from SSA #'s to VN's for the implicit memory variables. SsaDefArray<SsaMemDef> lvMemoryPerSsaData; public: // Returns the address of the per-Ssa data for memory at the given ssaNum (which is required // not to be the SsaConfig::RESERVED_SSA_NUM, which indicates that the variable is // not an SSA variable). SsaMemDef* GetMemoryPerSsaData(unsigned ssaNum) { return lvMemoryPerSsaData.GetSsaDef(ssaNum); } /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX Importer XX XX XX XX Imports the given method and converts it to semantic trees XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ private: // For prefixFlags enum { PREFIX_TAILCALL_EXPLICIT = 0x00000001, // call has "tail" IL prefix PREFIX_TAILCALL_IMPLICIT = 0x00000010, // call is treated as having "tail" prefix even though there is no "tail" IL prefix PREFIX_TAILCALL_STRESS = 0x00000100, // call doesn't "tail" IL prefix but is treated as explicit because of tail call stress PREFIX_TAILCALL = (PREFIX_TAILCALL_EXPLICIT | PREFIX_TAILCALL_IMPLICIT | PREFIX_TAILCALL_STRESS), PREFIX_VOLATILE = 0x00001000, PREFIX_UNALIGNED = 0x00010000, PREFIX_CONSTRAINED = 0x00100000, PREFIX_READONLY = 0x01000000 }; static void impValidateMemoryAccessOpcode(const BYTE* codeAddr, const BYTE* codeEndp, bool volatilePrefix); static OPCODE impGetNonPrefixOpcode(const BYTE* codeAddr, const BYTE* codeEndp); static bool impOpcodeIsCallOpcode(OPCODE opcode); public: void impInit(); void impImport(); CORINFO_CLASS_HANDLE impGetRefAnyClass(); CORINFO_CLASS_HANDLE impGetRuntimeArgumentHandle(); CORINFO_CLASS_HANDLE impGetTypeHandleClass(); CORINFO_CLASS_HANDLE impGetStringClass(); CORINFO_CLASS_HANDLE impGetObjectClass(); // Returns underlying type of handles returned by ldtoken instruction var_types GetRuntimeHandleUnderlyingType() { // RuntimeTypeHandle is backed by raw pointer on CoreRT and by object reference on other runtimes return IsTargetAbi(CORINFO_CORERT_ABI) ? TYP_I_IMPL : TYP_REF; } void impDevirtualizeCall(GenTreeCall* call, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_METHOD_HANDLE* method, unsigned* methodFlags, CORINFO_CONTEXT_HANDLE* contextHandle, CORINFO_CONTEXT_HANDLE* exactContextHandle, bool isLateDevirtualization, bool isExplicitTailCall, IL_OFFSET ilOffset = BAD_IL_OFFSET); //========================================================================= // PROTECTED //========================================================================= protected: //-------------------- Stack manipulation --------------------------------- unsigned impStkSize; // Size of the full stack #define SMALL_STACK_SIZE 16 // number of elements in impSmallStack struct SavedStack // used to save/restore stack contents. { unsigned ssDepth; // number of values on stack StackEntry* ssTrees; // saved tree values }; bool impIsPrimitive(CorInfoType type); bool impILConsumesAddr(const BYTE* codeAddr); void impResolveToken(const BYTE* addr, CORINFO_RESOLVED_TOKEN* pResolvedToken, CorInfoTokenKind kind); void impPushOnStack(GenTree* tree, typeInfo ti); void impPushNullObjRefOnStack(); StackEntry impPopStack(); StackEntry& impStackTop(unsigned n = 0); unsigned impStackHeight(); void impSaveStackState(SavedStack* savePtr, bool copy); void impRestoreStackState(SavedStack* savePtr); GenTree* impImportLdvirtftn(GenTree* thisPtr, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_CALL_INFO* pCallInfo); int impBoxPatternMatch(CORINFO_RESOLVED_TOKEN* pResolvedToken, const BYTE* codeAddr, const BYTE* codeEndp, bool makeInlineObservation = false); void impImportAndPushBox(CORINFO_RESOLVED_TOKEN* pResolvedToken); void impImportNewObjArray(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_CALL_INFO* pCallInfo); bool impCanPInvokeInline(); bool impCanPInvokeInlineCallSite(BasicBlock* block); void impCheckForPInvokeCall( GenTreeCall* call, CORINFO_METHOD_HANDLE methHnd, CORINFO_SIG_INFO* sig, unsigned mflags, BasicBlock* block); GenTreeCall* impImportIndirectCall(CORINFO_SIG_INFO* sig, const DebugInfo& di = DebugInfo()); void impPopArgsForUnmanagedCall(GenTree* call, CORINFO_SIG_INFO* sig); void impInsertHelperCall(CORINFO_HELPER_DESC* helperCall); void impHandleAccessAllowed(CorInfoIsAccessAllowedResult result, CORINFO_HELPER_DESC* helperCall); void impHandleAccessAllowedInternal(CorInfoIsAccessAllowedResult result, CORINFO_HELPER_DESC* helperCall); var_types impImportCall(OPCODE opcode, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken, // Is this a "constrained." call on a // type parameter? GenTree* newobjThis, int prefixFlags, CORINFO_CALL_INFO* callInfo, IL_OFFSET rawILOffset); CORINFO_CLASS_HANDLE impGetSpecialIntrinsicExactReturnType(CORINFO_METHOD_HANDLE specialIntrinsicHandle); bool impMethodInfo_hasRetBuffArg(CORINFO_METHOD_INFO* methInfo, CorInfoCallConvExtension callConv); GenTree* impFixupCallStructReturn(GenTreeCall* call, CORINFO_CLASS_HANDLE retClsHnd); GenTree* impFixupStructReturnType(GenTree* op, CORINFO_CLASS_HANDLE retClsHnd, CorInfoCallConvExtension unmgdCallConv); #ifdef DEBUG var_types impImportJitTestLabelMark(int numArgs); #endif // DEBUG GenTree* impInitClass(CORINFO_RESOLVED_TOKEN* pResolvedToken); GenTree* impImportStaticReadOnlyField(void* fldAddr, var_types lclTyp); GenTree* impImportStaticFieldAccess(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_ACCESS_FLAGS access, CORINFO_FIELD_INFO* pFieldInfo, var_types lclTyp); static void impBashVarAddrsToI(GenTree* tree1, GenTree* tree2 = nullptr); GenTree* impImplicitIorI4Cast(GenTree* tree, var_types dstTyp); GenTree* impImplicitR4orR8Cast(GenTree* tree, var_types dstTyp); void impImportLeave(BasicBlock* block); void impResetLeaveBlock(BasicBlock* block, unsigned jmpAddr); GenTree* impTypeIsAssignable(GenTree* typeTo, GenTree* typeFrom); GenTree* impIntrinsic(GenTree* newobjThis, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig, unsigned methodFlags, int memberRef, bool readonlyCall, bool tailCall, CORINFO_RESOLVED_TOKEN* pContstrainedResolvedToken, CORINFO_THIS_TRANSFORM constraintCallThisTransform, NamedIntrinsic* pIntrinsicName, bool* isSpecialIntrinsic = nullptr); GenTree* impMathIntrinsic(CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig, var_types callType, NamedIntrinsic intrinsicName, bool tailCall); NamedIntrinsic lookupNamedIntrinsic(CORINFO_METHOD_HANDLE method); GenTree* impUnsupportedNamedIntrinsic(unsigned helper, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig, bool mustExpand); #ifdef FEATURE_HW_INTRINSICS GenTree* impHWIntrinsic(NamedIntrinsic intrinsic, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig, bool mustExpand); GenTree* impSimdAsHWIntrinsic(NamedIntrinsic intrinsic, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig, GenTree* newobjThis); protected: bool compSupportsHWIntrinsic(CORINFO_InstructionSet isa); GenTree* impSimdAsHWIntrinsicSpecial(NamedIntrinsic intrinsic, CORINFO_CLASS_HANDLE clsHnd, CORINFO_SIG_INFO* sig, var_types retType, CorInfoType simdBaseJitType, unsigned simdSize, GenTree* newobjThis); GenTree* impSpecialIntrinsic(NamedIntrinsic intrinsic, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig, CorInfoType simdBaseJitType, var_types retType, unsigned simdSize); GenTree* getArgForHWIntrinsic(var_types argType, CORINFO_CLASS_HANDLE argClass, bool expectAddr = false, GenTree* newobjThis = nullptr); GenTree* impNonConstFallback(NamedIntrinsic intrinsic, var_types simdType, CorInfoType simdBaseJitType); GenTree* addRangeCheckIfNeeded( NamedIntrinsic intrinsic, GenTree* immOp, bool mustExpand, int immLowerBound, int immUpperBound); GenTree* addRangeCheckForHWIntrinsic(GenTree* immOp, int immLowerBound, int immUpperBound); #ifdef TARGET_XARCH GenTree* impBaseIntrinsic(NamedIntrinsic intrinsic, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig, CorInfoType simdBaseJitType, var_types retType, unsigned simdSize); GenTree* impSSEIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); GenTree* impSSE2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); GenTree* impAvxOrAvx2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); GenTree* impBMI1OrBMI2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); #endif // TARGET_XARCH #endif // FEATURE_HW_INTRINSICS GenTree* impArrayAccessIntrinsic(CORINFO_CLASS_HANDLE clsHnd, CORINFO_SIG_INFO* sig, int memberRef, bool readonlyCall, NamedIntrinsic intrinsicName); GenTree* impInitializeArrayIntrinsic(CORINFO_SIG_INFO* sig); GenTree* impCreateSpanIntrinsic(CORINFO_SIG_INFO* sig); GenTree* impKeepAliveIntrinsic(GenTree* objToKeepAlive); GenTree* impMethodPointer(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_CALL_INFO* pCallInfo); GenTree* impTransformThis(GenTree* thisPtr, CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken, CORINFO_THIS_TRANSFORM transform); //----------------- Manipulating the trees and stmts ---------------------- Statement* impStmtList; // Statements for the BB being imported. Statement* impLastStmt; // The last statement for the current BB. public: enum { CHECK_SPILL_ALL = -1, CHECK_SPILL_NONE = -2 }; void impBeginTreeList(); void impEndTreeList(BasicBlock* block, Statement* firstStmt, Statement* lastStmt); void impEndTreeList(BasicBlock* block); void impAppendStmtCheck(Statement* stmt, unsigned chkLevel); void impAppendStmt(Statement* stmt, unsigned chkLevel, bool checkConsumedDebugInfo = true); void impAppendStmt(Statement* stmt); void impInsertStmtBefore(Statement* stmt, Statement* stmtBefore); Statement* impAppendTree(GenTree* tree, unsigned chkLevel, const DebugInfo& di, bool checkConsumedDebugInfo = true); void impInsertTreeBefore(GenTree* tree, const DebugInfo& di, Statement* stmtBefore); void impAssignTempGen(unsigned tmp, GenTree* val, unsigned curLevel, Statement** pAfterStmt = nullptr, const DebugInfo& di = DebugInfo(), BasicBlock* block = nullptr); void impAssignTempGen(unsigned tmpNum, GenTree* val, CORINFO_CLASS_HANDLE structHnd, unsigned curLevel, Statement** pAfterStmt = nullptr, const DebugInfo& di = DebugInfo(), BasicBlock* block = nullptr); Statement* impExtractLastStmt(); GenTree* impCloneExpr(GenTree* tree, GenTree** clone, CORINFO_CLASS_HANDLE structHnd, unsigned curLevel, Statement** pAfterStmt DEBUGARG(const char* reason)); GenTree* impAssignStruct(GenTree* dest, GenTree* src, CORINFO_CLASS_HANDLE structHnd, unsigned curLevel, Statement** pAfterStmt = nullptr, const DebugInfo& di = DebugInfo(), BasicBlock* block = nullptr); GenTree* impAssignStructPtr(GenTree* dest, GenTree* src, CORINFO_CLASS_HANDLE structHnd, unsigned curLevel, Statement** pAfterStmt = nullptr, const DebugInfo& di = DebugInfo(), BasicBlock* block = nullptr); GenTree* impGetStructAddr(GenTree* structVal, CORINFO_CLASS_HANDLE structHnd, unsigned curLevel, bool willDeref); var_types impNormStructType(CORINFO_CLASS_HANDLE structHnd, CorInfoType* simdBaseJitType = nullptr); GenTree* impNormStructVal(GenTree* structVal, CORINFO_CLASS_HANDLE structHnd, unsigned curLevel, bool forceNormalization = false); GenTree* impTokenToHandle(CORINFO_RESOLVED_TOKEN* pResolvedToken, bool* pRuntimeLookup = nullptr, bool mustRestoreHandle = false, bool importParent = false); GenTree* impParentClassTokenToHandle(CORINFO_RESOLVED_TOKEN* pResolvedToken, bool* pRuntimeLookup = nullptr, bool mustRestoreHandle = false) { return impTokenToHandle(pResolvedToken, pRuntimeLookup, mustRestoreHandle, true); } GenTree* impLookupToTree(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_LOOKUP* pLookup, GenTreeFlags flags, void* compileTimeHandle); GenTree* getRuntimeContextTree(CORINFO_RUNTIME_LOOKUP_KIND kind); GenTree* impRuntimeLookupToTree(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_LOOKUP* pLookup, void* compileTimeHandle); GenTree* impReadyToRunLookupToTree(CORINFO_CONST_LOOKUP* pLookup, GenTreeFlags flags, void* compileTimeHandle); GenTreeCall* impReadyToRunHelperToTree(CORINFO_RESOLVED_TOKEN* pResolvedToken, CorInfoHelpFunc helper, var_types type, GenTreeCall::Use* args = nullptr, CORINFO_LOOKUP_KIND* pGenericLookupKind = nullptr); bool impIsCastHelperEligibleForClassProbe(GenTree* tree); bool impIsCastHelperMayHaveProfileData(GenTree* tree); GenTree* impCastClassOrIsInstToTree( GenTree* op1, GenTree* op2, CORINFO_RESOLVED_TOKEN* pResolvedToken, bool isCastClass, IL_OFFSET ilOffset); GenTree* impOptimizeCastClassOrIsInst(GenTree* op1, CORINFO_RESOLVED_TOKEN* pResolvedToken, bool isCastClass); bool VarTypeIsMultiByteAndCanEnreg(var_types type, CORINFO_CLASS_HANDLE typeClass, unsigned* typeSize, bool forReturn, bool isVarArg, CorInfoCallConvExtension callConv); bool IsIntrinsicImplementedByUserCall(NamedIntrinsic intrinsicName); bool IsTargetIntrinsic(NamedIntrinsic intrinsicName); bool IsMathIntrinsic(NamedIntrinsic intrinsicName); bool IsMathIntrinsic(GenTree* tree); private: //----------------- Importing the method ---------------------------------- CORINFO_CONTEXT_HANDLE impTokenLookupContextHandle; // The context used for looking up tokens. #ifdef DEBUG unsigned impCurOpcOffs; const char* impCurOpcName; bool impNestedStackSpill; // For displaying instrs with generated native code (-n:B) Statement* impLastILoffsStmt; // oldest stmt added for which we did not call SetLastILOffset(). void impNoteLastILoffs(); #endif // Debug info of current statement being imported. It gets set to contain // no IL location (!impCurStmtDI.GetLocation().IsValid) after it has been // set in the appended trees. Then it gets updated at IL instructions for // which we have to report mapping info. // It will always contain the current inline context. DebugInfo impCurStmtDI; DebugInfo impCreateDIWithCurrentStackInfo(IL_OFFSET offs, bool isCall); void impCurStmtOffsSet(IL_OFFSET offs); void impNoteBranchOffs(); unsigned impInitBlockLineInfo(); bool impIsThis(GenTree* obj); bool impIsLDFTN_TOKEN(const BYTE* delegateCreateStart, const BYTE* newobjCodeAddr); bool impIsDUP_LDVIRTFTN_TOKEN(const BYTE* delegateCreateStart, const BYTE* newobjCodeAddr); bool impIsAnySTLOC(OPCODE opcode) { return ((opcode == CEE_STLOC) || (opcode == CEE_STLOC_S) || ((opcode >= CEE_STLOC_0) && (opcode <= CEE_STLOC_3))); } GenTreeCall::Use* impPopCallArgs(unsigned count, CORINFO_SIG_INFO* sig, GenTreeCall::Use* prefixArgs = nullptr); bool impCheckImplicitArgumentCoercion(var_types sigType, var_types nodeType) const; GenTreeCall::Use* impPopReverseCallArgs(unsigned count, CORINFO_SIG_INFO* sig, unsigned skipReverseCount = 0); //---------------- Spilling the importer stack ---------------------------- // The maximum number of bytes of IL processed without clean stack state. // It allows to limit the maximum tree size and depth. static const unsigned MAX_TREE_SIZE = 200; bool impCanSpillNow(OPCODE prevOpcode); struct PendingDsc { PendingDsc* pdNext; BasicBlock* pdBB; SavedStack pdSavedStack; ThisInitState pdThisPtrInit; }; PendingDsc* impPendingList; // list of BBs currently waiting to be imported. PendingDsc* impPendingFree; // Freed up dscs that can be reused // We keep a byte-per-block map (dynamically extended) in the top-level Compiler object of a compilation. JitExpandArray<BYTE> impPendingBlockMembers; // Return the byte for "b" (allocating/extending impPendingBlockMembers if necessary.) // Operates on the map in the top-level ancestor. BYTE impGetPendingBlockMember(BasicBlock* blk) { return impInlineRoot()->impPendingBlockMembers.Get(blk->bbInd()); } // Set the byte for "b" to "val" (allocating/extending impPendingBlockMembers if necessary.) // Operates on the map in the top-level ancestor. void impSetPendingBlockMember(BasicBlock* blk, BYTE val) { impInlineRoot()->impPendingBlockMembers.Set(blk->bbInd(), val); } bool impCanReimport; bool impSpillStackEntry(unsigned level, unsigned varNum #ifdef DEBUG , bool bAssertOnRecursion, const char* reason #endif ); void impSpillStackEnsure(bool spillLeaves = false); void impEvalSideEffects(); void impSpillSpecialSideEff(); void impSpillSideEffects(bool spillGlobEffects, unsigned chkLevel DEBUGARG(const char* reason)); void impSpillValueClasses(); void impSpillEvalStack(); static fgWalkPreFn impFindValueClasses; void impSpillLclRefs(ssize_t lclNum); BasicBlock* impPushCatchArgOnStack(BasicBlock* hndBlk, CORINFO_CLASS_HANDLE clsHnd, bool isSingleBlockFilter); bool impBlockIsInALoop(BasicBlock* block); void impImportBlockCode(BasicBlock* block); void impReimportMarkBlock(BasicBlock* block); void impReimportMarkSuccessors(BasicBlock* block); void impVerifyEHBlock(BasicBlock* block, bool isTryStart); void impImportBlockPending(BasicBlock* block); // Similar to impImportBlockPending, but assumes that block has already been imported once and is being // reimported for some reason. It specifically does *not* look at verCurrentState to set the EntryState // for the block, but instead, just re-uses the block's existing EntryState. void impReimportBlockPending(BasicBlock* block); var_types impGetByRefResultType(genTreeOps oper, bool fUnsigned, GenTree** pOp1, GenTree** pOp2); void impImportBlock(BasicBlock* block); // Assumes that "block" is a basic block that completes with a non-empty stack. We will assign the values // on the stack to local variables (the "spill temp" variables). The successor blocks will assume that // its incoming stack contents are in those locals. This requires "block" and its successors to agree on // the variables that will be used -- and for all the predecessors of those successors, and the // successors of those predecessors, etc. Call such a set of blocks closed under alternating // successor/predecessor edges a "spill clique." A block is a "predecessor" or "successor" member of the // clique (or, conceivably, both). Each block has a specified sequence of incoming and outgoing spill // temps. If "block" already has its outgoing spill temps assigned (they are always a contiguous series // of local variable numbers, so we represent them with the base local variable number), returns that. // Otherwise, picks a set of spill temps, and propagates this choice to all blocks in the spill clique of // which "block" is a member (asserting, in debug mode, that no block in this clique had its spill temps // chosen already. More precisely, that the incoming or outgoing spill temps are not chosen, depending // on which kind of member of the clique the block is). unsigned impGetSpillTmpBase(BasicBlock* block); // Assumes that "block" is a basic block that completes with a non-empty stack. We have previously // assigned the values on the stack to local variables (the "spill temp" variables). The successor blocks // will assume that its incoming stack contents are in those locals. This requires "block" and its // successors to agree on the variables and their types that will be used. The CLI spec allows implicit // conversions between 'int' and 'native int' or 'float' and 'double' stack types. So one predecessor can // push an int and another can push a native int. For 64-bit we have chosen to implement this by typing // the "spill temp" as native int, and then importing (or re-importing as needed) so that all the // predecessors in the "spill clique" push a native int (sign-extending if needed), and all the // successors receive a native int. Similarly float and double are unified to double. // This routine is called after a type-mismatch is detected, and it will walk the spill clique to mark // blocks for re-importation as appropriate (both successors, so they get the right incoming type, and // predecessors, so they insert an upcast if needed). void impReimportSpillClique(BasicBlock* block); // When we compute a "spill clique" (see above) these byte-maps are allocated to have a byte per basic // block, and represent the predecessor and successor members of the clique currently being computed. // *** Access to these will need to be locked in a parallel compiler. JitExpandArray<BYTE> impSpillCliquePredMembers; JitExpandArray<BYTE> impSpillCliqueSuccMembers; enum SpillCliqueDir { SpillCliquePred, SpillCliqueSucc }; // Abstract class for receiving a callback while walking a spill clique class SpillCliqueWalker { public: virtual void Visit(SpillCliqueDir predOrSucc, BasicBlock* blk) = 0; }; // This class is used for setting the bbStkTempsIn and bbStkTempsOut on the blocks within a spill clique class SetSpillTempsBase : public SpillCliqueWalker { unsigned m_baseTmp; public: SetSpillTempsBase(unsigned baseTmp) : m_baseTmp(baseTmp) { } virtual void Visit(SpillCliqueDir predOrSucc, BasicBlock* blk); }; // This class is used for implementing impReimportSpillClique part on each block within the spill clique class ReimportSpillClique : public SpillCliqueWalker { Compiler* m_pComp; public: ReimportSpillClique(Compiler* pComp) : m_pComp(pComp) { } virtual void Visit(SpillCliqueDir predOrSucc, BasicBlock* blk); }; // This is the heart of the algorithm for walking spill cliques. It invokes callback->Visit for each // predecessor or successor within the spill clique void impWalkSpillCliqueFromPred(BasicBlock* pred, SpillCliqueWalker* callback); // For a BasicBlock that has already been imported, the EntryState has an array of GenTrees for the // incoming locals. This walks that list an resets the types of the GenTrees to match the types of // the VarDscs. They get out of sync when we have int/native int issues (see impReimportSpillClique). void impRetypeEntryStateTemps(BasicBlock* blk); BYTE impSpillCliqueGetMember(SpillCliqueDir predOrSucc, BasicBlock* blk); void impSpillCliqueSetMember(SpillCliqueDir predOrSucc, BasicBlock* blk, BYTE val); void impPushVar(GenTree* op, typeInfo tiRetVal); GenTreeLclVar* impCreateLocalNode(unsigned lclNum DEBUGARG(IL_OFFSET offset)); void impLoadVar(unsigned lclNum, IL_OFFSET offset, const typeInfo& tiRetVal); void impLoadVar(unsigned lclNum, IL_OFFSET offset) { impLoadVar(lclNum, offset, lvaGetDesc(lclNum)->lvVerTypeInfo); } void impLoadArg(unsigned ilArgNum, IL_OFFSET offset); void impLoadLoc(unsigned ilLclNum, IL_OFFSET offset); bool impReturnInstruction(int prefixFlags, OPCODE& opcode); #ifdef TARGET_ARM void impMarkLclDstNotPromotable(unsigned tmpNum, GenTree* op, CORINFO_CLASS_HANDLE hClass); #endif // A free list of linked list nodes used to represent to-do stacks of basic blocks. struct BlockListNode { BasicBlock* m_blk; BlockListNode* m_next; BlockListNode(BasicBlock* blk, BlockListNode* next = nullptr) : m_blk(blk), m_next(next) { } void* operator new(size_t sz, Compiler* comp); }; BlockListNode* impBlockListNodeFreeList; void FreeBlockListNode(BlockListNode* node); bool impIsValueType(typeInfo* pTypeInfo); var_types mangleVarArgsType(var_types type); regNumber getCallArgIntRegister(regNumber floatReg); regNumber getCallArgFloatRegister(regNumber intReg); #if defined(DEBUG) static unsigned jitTotalMethodCompiled; #endif #ifdef DEBUG static LONG jitNestingLevel; #endif // DEBUG static bool impIsAddressInLocal(const GenTree* tree, GenTree** lclVarTreeOut = nullptr); void impMakeDiscretionaryInlineObservations(InlineInfo* pInlineInfo, InlineResult* inlineResult); // STATIC inlining decision based on the IL code. void impCanInlineIL(CORINFO_METHOD_HANDLE fncHandle, CORINFO_METHOD_INFO* methInfo, bool forceInline, InlineResult* inlineResult); void impCheckCanInline(GenTreeCall* call, CORINFO_METHOD_HANDLE fncHandle, unsigned methAttr, CORINFO_CONTEXT_HANDLE exactContextHnd, InlineCandidateInfo** ppInlineCandidateInfo, InlineResult* inlineResult); void impInlineRecordArgInfo(InlineInfo* pInlineInfo, GenTree* curArgVal, unsigned argNum, InlineResult* inlineResult); void impInlineInitVars(InlineInfo* pInlineInfo); unsigned impInlineFetchLocal(unsigned lclNum DEBUGARG(const char* reason)); GenTree* impInlineFetchArg(unsigned lclNum, InlArgInfo* inlArgInfo, InlLclVarInfo* lclTypeInfo); bool impInlineIsThis(GenTree* tree, InlArgInfo* inlArgInfo); bool impInlineIsGuaranteedThisDerefBeforeAnySideEffects(GenTree* additionalTree, GenTreeCall::Use* additionalCallArgs, GenTree* dereferencedAddress, InlArgInfo* inlArgInfo); void impMarkInlineCandidate(GenTree* call, CORINFO_CONTEXT_HANDLE exactContextHnd, bool exactContextNeedsRuntimeLookup, CORINFO_CALL_INFO* callInfo); void impMarkInlineCandidateHelper(GenTreeCall* call, CORINFO_CONTEXT_HANDLE exactContextHnd, bool exactContextNeedsRuntimeLookup, CORINFO_CALL_INFO* callInfo); bool impTailCallRetTypeCompatible(bool allowWidening, var_types callerRetType, CORINFO_CLASS_HANDLE callerRetTypeClass, CorInfoCallConvExtension callerCallConv, var_types calleeRetType, CORINFO_CLASS_HANDLE calleeRetTypeClass, CorInfoCallConvExtension calleeCallConv); bool impIsTailCallILPattern( bool tailPrefixed, OPCODE curOpcode, const BYTE* codeAddrOfNextOpcode, const BYTE* codeEnd, bool isRecursive); bool impIsImplicitTailCallCandidate( OPCODE curOpcode, const BYTE* codeAddrOfNextOpcode, const BYTE* codeEnd, int prefixFlags, bool isRecursive); bool impIsClassExact(CORINFO_CLASS_HANDLE classHnd); bool impCanSkipCovariantStoreCheck(GenTree* value, GenTree* array); CORINFO_RESOLVED_TOKEN* impAllocateToken(const CORINFO_RESOLVED_TOKEN& token); /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX FlowGraph XX XX XX XX Info about the basic-blocks, their contents and the flow analysis XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ public: BasicBlock* fgFirstBB; // Beginning of the basic block list BasicBlock* fgLastBB; // End of the basic block list BasicBlock* fgFirstColdBlock; // First block to be placed in the cold section BasicBlock* fgEntryBB; // For OSR, the original method's entry point BasicBlock* fgOSREntryBB; // For OSR, the logical entry point (~ patchpoint) #if defined(FEATURE_EH_FUNCLETS) BasicBlock* fgFirstFuncletBB; // First block of outlined funclets (to allow block insertion before the funclets) #endif BasicBlock* fgFirstBBScratch; // Block inserted for initialization stuff. Is nullptr if no such block has been // created. BasicBlockList* fgReturnBlocks; // list of BBJ_RETURN blocks unsigned fgEdgeCount; // # of control flow edges between the BBs unsigned fgBBcount; // # of BBs in the method #ifdef DEBUG unsigned fgBBcountAtCodegen; // # of BBs in the method at the start of codegen #endif unsigned fgBBNumMax; // The max bbNum that has been assigned to basic blocks unsigned fgDomBBcount; // # of BBs for which we have dominator and reachability information BasicBlock** fgBBInvPostOrder; // The flow graph stored in an array sorted in topological order, needed to compute // dominance. Indexed by block number. Size: fgBBNumMax + 1. // After the dominance tree is computed, we cache a DFS preorder number and DFS postorder number to compute // dominance queries in O(1). fgDomTreePreOrder and fgDomTreePostOrder are arrays giving the block's preorder and // postorder number, respectively. The arrays are indexed by basic block number. (Note that blocks are numbered // starting from one. Thus, we always waste element zero. This makes debugging easier and makes the code less likely // to suffer from bugs stemming from forgetting to add or subtract one from the block number to form an array // index). The arrays are of size fgBBNumMax + 1. unsigned* fgDomTreePreOrder; unsigned* fgDomTreePostOrder; // Dominator tree used by SSA construction and copy propagation (the two are expected to use the same tree // in order to avoid the need for SSA reconstruction and an "out of SSA" phase). DomTreeNode* fgSsaDomTree; bool fgBBVarSetsInited; // Allocate array like T* a = new T[fgBBNumMax + 1]; // Using helper so we don't keep forgetting +1. template <typename T> T* fgAllocateTypeForEachBlk(CompMemKind cmk = CMK_Unknown) { return getAllocator(cmk).allocate<T>(fgBBNumMax + 1); } // BlockSets are relative to a specific set of BasicBlock numbers. If that changes // (if the blocks are renumbered), this changes. BlockSets from different epochs // cannot be meaningfully combined. Note that new blocks can be created with higher // block numbers without changing the basic block epoch. These blocks *cannot* // participate in a block set until the blocks are all renumbered, causing the epoch // to change. This is useful if continuing to use previous block sets is valuable. // If the epoch is zero, then it is uninitialized, and block sets can't be used. unsigned fgCurBBEpoch; unsigned GetCurBasicBlockEpoch() { return fgCurBBEpoch; } // The number of basic blocks in the current epoch. When the blocks are renumbered, // this is fgBBcount. As blocks are added, fgBBcount increases, fgCurBBEpochSize remains // the same, until a new BasicBlock epoch is created, such as when the blocks are all renumbered. unsigned fgCurBBEpochSize; // The number of "size_t" elements required to hold a bitset large enough for fgCurBBEpochSize // bits. This is precomputed to avoid doing math every time BasicBlockBitSetTraits::GetArrSize() is called. unsigned fgBBSetCountInSizeTUnits; void NewBasicBlockEpoch() { INDEBUG(unsigned oldEpochArrSize = fgBBSetCountInSizeTUnits); // We have a new epoch. Compute and cache the size needed for new BlockSets. fgCurBBEpoch++; fgCurBBEpochSize = fgBBNumMax + 1; fgBBSetCountInSizeTUnits = roundUp(fgCurBBEpochSize, (unsigned)(sizeof(size_t) * 8)) / unsigned(sizeof(size_t) * 8); #ifdef DEBUG // All BlockSet objects are now invalid! fgReachabilitySetsValid = false; // the bbReach sets are now invalid! fgEnterBlksSetValid = false; // the fgEnterBlks set is now invalid! if (verbose) { unsigned epochArrSize = BasicBlockBitSetTraits::GetArrSize(this, sizeof(size_t)); printf("\nNew BlockSet epoch %d, # of blocks (including unused BB00): %u, bitset array size: %u (%s)", fgCurBBEpoch, fgCurBBEpochSize, epochArrSize, (epochArrSize <= 1) ? "short" : "long"); if ((fgCurBBEpoch != 1) && ((oldEpochArrSize <= 1) != (epochArrSize <= 1))) { // If we're not just establishing the first epoch, and the epoch array size has changed such that we're // going to change our bitset representation from short (just a size_t bitset) to long (a pointer to an // array of size_t bitsets), then print that out. printf("; NOTE: BlockSet size was previously %s!", (oldEpochArrSize <= 1) ? "short" : "long"); } printf("\n"); } #endif // DEBUG } void EnsureBasicBlockEpoch() { if (fgCurBBEpochSize != fgBBNumMax + 1) { NewBasicBlockEpoch(); } } BasicBlock* fgNewBasicBlock(BBjumpKinds jumpKind); void fgEnsureFirstBBisScratch(); bool fgFirstBBisScratch(); bool fgBBisScratch(BasicBlock* block); void fgExtendEHRegionBefore(BasicBlock* block); void fgExtendEHRegionAfter(BasicBlock* block); BasicBlock* fgNewBBbefore(BBjumpKinds jumpKind, BasicBlock* block, bool extendRegion); BasicBlock* fgNewBBafter(BBjumpKinds jumpKind, BasicBlock* block, bool extendRegion); BasicBlock* fgNewBBinRegion(BBjumpKinds jumpKind, unsigned tryIndex, unsigned hndIndex, BasicBlock* nearBlk, bool putInFilter = false, bool runRarely = false, bool insertAtEnd = false); BasicBlock* fgNewBBinRegion(BBjumpKinds jumpKind, BasicBlock* srcBlk, bool runRarely = false, bool insertAtEnd = false); BasicBlock* fgNewBBinRegion(BBjumpKinds jumpKind); BasicBlock* fgNewBBinRegionWorker(BBjumpKinds jumpKind, BasicBlock* afterBlk, unsigned xcptnIndex, bool putInTryRegion); void fgInsertBBbefore(BasicBlock* insertBeforeBlk, BasicBlock* newBlk); void fgInsertBBafter(BasicBlock* insertAfterBlk, BasicBlock* newBlk); void fgUnlinkBlock(BasicBlock* block); #ifdef FEATURE_JIT_METHOD_PERF unsigned fgMeasureIR(); #endif // FEATURE_JIT_METHOD_PERF bool fgModified; // True if the flow graph has been modified recently bool fgComputePredsDone; // Have we computed the bbPreds list bool fgCheapPredsValid; // Is the bbCheapPreds list valid? bool fgDomsComputed; // Have we computed the dominator sets? bool fgReturnBlocksComputed; // Have we computed the return blocks list? bool fgOptimizedFinally; // Did we optimize any try-finallys? bool fgHasSwitch; // any BBJ_SWITCH jumps? BlockSet fgEnterBlks; // Set of blocks which have a special transfer of control; the "entry" blocks plus EH handler // begin blocks. #if defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM) BlockSet fgAlwaysBlks; // Set of blocks which are BBJ_ALWAYS part of BBJ_CALLFINALLY/BBJ_ALWAYS pair that should // never be removed due to a requirement to use the BBJ_ALWAYS for generating code and // not have "retless" blocks. #endif // defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM) #ifdef DEBUG bool fgReachabilitySetsValid; // Are the bbReach sets valid? bool fgEnterBlksSetValid; // Is the fgEnterBlks set valid? #endif // DEBUG bool fgRemoveRestOfBlock; // true if we know that we will throw bool fgStmtRemoved; // true if we remove statements -> need new DFA // There are two modes for ordering of the trees. // - In FGOrderTree, the dominant ordering is the tree order, and the nodes contained in // each tree and sub-tree are contiguous, and can be traversed (in gtNext/gtPrev order) // by traversing the tree according to the order of the operands. // - In FGOrderLinear, the dominant ordering is the linear order. enum FlowGraphOrder { FGOrderTree, FGOrderLinear }; FlowGraphOrder fgOrder; // The following are boolean flags that keep track of the state of internal data structures bool fgStmtListThreaded; // true if the node list is now threaded bool fgCanRelocateEHRegions; // true if we are allowed to relocate the EH regions bool fgEdgeWeightsComputed; // true after we have called fgComputeEdgeWeights bool fgHaveValidEdgeWeights; // true if we were successful in computing all of the edge weights bool fgSlopUsedInEdgeWeights; // true if their was some slop used when computing the edge weights bool fgRangeUsedInEdgeWeights; // true if some of the edgeWeight are expressed in Min..Max form bool fgNeedsUpdateFlowGraph; // true if we need to run fgUpdateFlowGraph weight_t fgCalledCount; // count of the number of times this method was called // This is derived from the profile data // or is BB_UNITY_WEIGHT when we don't have profile data #if defined(FEATURE_EH_FUNCLETS) bool fgFuncletsCreated; // true if the funclet creation phase has been run #endif // FEATURE_EH_FUNCLETS bool fgGlobalMorph; // indicates if we are during the global morphing phase // since fgMorphTree can be called from several places bool impBoxTempInUse; // the temp below is valid and available unsigned impBoxTemp; // a temporary that is used for boxing #ifdef DEBUG bool jitFallbackCompile; // Are we doing a fallback compile? That is, have we executed a NO_WAY assert, // and we are trying to compile again in a "safer", minopts mode? #endif #if defined(DEBUG) unsigned impInlinedCodeSize; bool fgPrintInlinedMethods; #endif jitstd::vector<flowList*>* fgPredListSortVector; //------------------------------------------------------------------------- void fgInit(); PhaseStatus fgImport(); PhaseStatus fgTransformIndirectCalls(); PhaseStatus fgTransformPatchpoints(); PhaseStatus fgInline(); PhaseStatus fgRemoveEmptyTry(); PhaseStatus fgRemoveEmptyFinally(); PhaseStatus fgMergeFinallyChains(); PhaseStatus fgCloneFinally(); void fgCleanupContinuation(BasicBlock* continuation); #if defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM) PhaseStatus fgUpdateFinallyTargetFlags(); void fgClearAllFinallyTargetBits(); void fgAddFinallyTargetFlags(); #endif // defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM) PhaseStatus fgTailMergeThrows(); void fgTailMergeThrowsFallThroughHelper(BasicBlock* predBlock, BasicBlock* nonCanonicalBlock, BasicBlock* canonicalBlock, flowList* predEdge); void fgTailMergeThrowsJumpToHelper(BasicBlock* predBlock, BasicBlock* nonCanonicalBlock, BasicBlock* canonicalBlock, flowList* predEdge); GenTree* fgCheckCallArgUpdate(GenTree* parent, GenTree* child, var_types origType); #if defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM) // Sometimes we need to defer updating the BBF_FINALLY_TARGET bit. fgNeedToAddFinallyTargetBits signals // when this is necessary. bool fgNeedToAddFinallyTargetBits; #endif // defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM) bool fgRetargetBranchesToCanonicalCallFinally(BasicBlock* block, BasicBlock* handler, BlockToBlockMap& continuationMap); GenTree* fgGetCritSectOfStaticMethod(); #if defined(FEATURE_EH_FUNCLETS) void fgAddSyncMethodEnterExit(); GenTree* fgCreateMonitorTree(unsigned lvaMonitorBool, unsigned lvaThisVar, BasicBlock* block, bool enter); void fgConvertSyncReturnToLeave(BasicBlock* block); #endif // FEATURE_EH_FUNCLETS void fgAddReversePInvokeEnterExit(); bool fgMoreThanOneReturnBlock(); // The number of separate return points in the method. unsigned fgReturnCount; void fgAddInternal(); enum class FoldResult { FOLD_DID_NOTHING, FOLD_CHANGED_CONTROL_FLOW, FOLD_REMOVED_LAST_STMT, FOLD_ALTERED_LAST_STMT, }; FoldResult fgFoldConditional(BasicBlock* block); void fgMorphStmts(BasicBlock* block); void fgMorphBlocks(); void fgMergeBlockReturn(BasicBlock* block); bool fgMorphBlockStmt(BasicBlock* block, Statement* stmt DEBUGARG(const char* msg)); void fgSetOptions(); #ifdef DEBUG static fgWalkPreFn fgAssertNoQmark; void fgPreExpandQmarkChecks(GenTree* expr); void fgPostExpandQmarkChecks(); static void fgCheckQmarkAllowedForm(GenTree* tree); #endif IL_OFFSET fgFindBlockILOffset(BasicBlock* block); void fgFixEntryFlowForOSR(); BasicBlock* fgSplitBlockAtBeginning(BasicBlock* curr); BasicBlock* fgSplitBlockAtEnd(BasicBlock* curr); BasicBlock* fgSplitBlockAfterStatement(BasicBlock* curr, Statement* stmt); BasicBlock* fgSplitBlockAfterNode(BasicBlock* curr, GenTree* node); // for LIR BasicBlock* fgSplitEdge(BasicBlock* curr, BasicBlock* succ); Statement* fgNewStmtFromTree(GenTree* tree, BasicBlock* block, const DebugInfo& di); Statement* fgNewStmtFromTree(GenTree* tree); Statement* fgNewStmtFromTree(GenTree* tree, BasicBlock* block); Statement* fgNewStmtFromTree(GenTree* tree, const DebugInfo& di); GenTree* fgGetTopLevelQmark(GenTree* expr, GenTree** ppDst = nullptr); void fgExpandQmarkForCastInstOf(BasicBlock* block, Statement* stmt); void fgExpandQmarkStmt(BasicBlock* block, Statement* stmt); void fgExpandQmarkNodes(); // Do "simple lowering." This functionality is (conceptually) part of "general" // lowering that is distributed between fgMorph and the lowering phase of LSRA. void fgSimpleLowering(); GenTree* fgInitThisClass(); GenTreeCall* fgGetStaticsCCtorHelper(CORINFO_CLASS_HANDLE cls, CorInfoHelpFunc helper); GenTreeCall* fgGetSharedCCtor(CORINFO_CLASS_HANDLE cls); bool backendRequiresLocalVarLifetimes() { return !opts.MinOpts() || m_pLinearScan->willEnregisterLocalVars(); } void fgLocalVarLiveness(); void fgLocalVarLivenessInit(); void fgPerNodeLocalVarLiveness(GenTree* node); void fgPerBlockLocalVarLiveness(); VARSET_VALRET_TP fgGetHandlerLiveVars(BasicBlock* block); void fgLiveVarAnalysis(bool updateInternalOnly = false); void fgComputeLifeCall(VARSET_TP& life, GenTreeCall* call); void fgComputeLifeTrackedLocalUse(VARSET_TP& life, LclVarDsc& varDsc, GenTreeLclVarCommon* node); bool fgComputeLifeTrackedLocalDef(VARSET_TP& life, VARSET_VALARG_TP keepAliveVars, LclVarDsc& varDsc, GenTreeLclVarCommon* node); bool fgComputeLifeUntrackedLocal(VARSET_TP& life, VARSET_VALARG_TP keepAliveVars, LclVarDsc& varDsc, GenTreeLclVarCommon* lclVarNode); bool fgComputeLifeLocal(VARSET_TP& life, VARSET_VALARG_TP keepAliveVars, GenTree* lclVarNode); void fgComputeLife(VARSET_TP& life, GenTree* startNode, GenTree* endNode, VARSET_VALARG_TP volatileVars, bool* pStmtInfoDirty DEBUGARG(bool* treeModf)); void fgComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VARSET_VALARG_TP volatileVars); bool fgTryRemoveNonLocal(GenTree* node, LIR::Range* blockRange); void fgRemoveDeadStoreLIR(GenTree* store, BasicBlock* block); bool fgRemoveDeadStore(GenTree** pTree, LclVarDsc* varDsc, VARSET_VALARG_TP life, bool* doAgain, bool* pStmtInfoDirty, bool* pStoreRemoved DEBUGARG(bool* treeModf)); void fgInterBlockLocalVarLiveness(); // Blocks: convenience methods for enabling range-based `for` iteration over the function's blocks, e.g.: // 1. for (BasicBlock* const block : compiler->Blocks()) ... // 2. for (BasicBlock* const block : compiler->Blocks(startBlock)) ... // 3. for (BasicBlock* const block : compiler->Blocks(startBlock, endBlock)) ... // In case (1), the block list can be empty. In case (2), `startBlock` can be nullptr. In case (3), // both `startBlock` and `endBlock` must be non-null. // BasicBlockSimpleList Blocks() const { return BasicBlockSimpleList(fgFirstBB); } BasicBlockSimpleList Blocks(BasicBlock* startBlock) const { return BasicBlockSimpleList(startBlock); } BasicBlockRangeList Blocks(BasicBlock* startBlock, BasicBlock* endBlock) const { return BasicBlockRangeList(startBlock, endBlock); } // The presence of a partial definition presents some difficulties for SSA: this is both a use of some SSA name // of "x", and a def of a new SSA name for "x". The tree only has one local variable for "x", so it has to choose // whether to treat that as the use or def. It chooses the "use", and thus the old SSA name. This map allows us // to record/recover the "def" SSA number, given the lcl var node for "x" in such a tree. typedef JitHashTable<GenTree*, JitPtrKeyFuncs<GenTree>, unsigned> NodeToUnsignedMap; NodeToUnsignedMap* m_opAsgnVarDefSsaNums; NodeToUnsignedMap* GetOpAsgnVarDefSsaNums() { if (m_opAsgnVarDefSsaNums == nullptr) { m_opAsgnVarDefSsaNums = new (getAllocator()) NodeToUnsignedMap(getAllocator()); } return m_opAsgnVarDefSsaNums; } // This map tracks nodes whose value numbers explicitly or implicitly depend on memory states. // The map provides the entry block of the most closely enclosing loop that // defines the memory region accessed when defining the nodes's VN. // // This information should be consulted when considering hoisting node out of a loop, as the VN // for the node will only be valid within the indicated loop. // // It is not fine-grained enough to track memory dependence within loops, so cannot be used // for more general code motion. // // If a node does not have an entry in the map we currently assume the VN is not memory dependent // and so memory does not constrain hoisting. // typedef JitHashTable<GenTree*, JitPtrKeyFuncs<GenTree>, BasicBlock*> NodeToLoopMemoryBlockMap; NodeToLoopMemoryBlockMap* m_nodeToLoopMemoryBlockMap; NodeToLoopMemoryBlockMap* GetNodeToLoopMemoryBlockMap() { if (m_nodeToLoopMemoryBlockMap == nullptr) { m_nodeToLoopMemoryBlockMap = new (getAllocator()) NodeToLoopMemoryBlockMap(getAllocator()); } return m_nodeToLoopMemoryBlockMap; } void optRecordLoopMemoryDependence(GenTree* tree, BasicBlock* block, ValueNum memoryVN); void optCopyLoopMemoryDependence(GenTree* fromTree, GenTree* toTree); // Requires value numbering phase to have completed. Returns the value number ("gtVN") of the // "tree," EXCEPT in the case of GTF_VAR_USEASG, because the tree node's gtVN member is the // "use" VN. Performs a lookup into the map of (use asg tree -> def VN.) to return the "def's" // VN. inline ValueNum GetUseAsgDefVNOrTreeVN(GenTree* tree); // Requires that "lcl" has the GTF_VAR_DEF flag set. Returns the SSA number of "lcl". // Except: assumes that lcl is a def, and if it is // a partial def (GTF_VAR_USEASG), looks up and returns the SSA number for the "def", // rather than the "use" SSA number recorded in the tree "lcl". inline unsigned GetSsaNumForLocalVarDef(GenTree* lcl); inline bool PreciseRefCountsRequired(); // Performs SSA conversion. void fgSsaBuild(); // Reset any data structures to the state expected by "fgSsaBuild", so it can be run again. void fgResetForSsa(); unsigned fgSsaPassesCompleted; // Number of times fgSsaBuild has been run. // Returns "true" if this is a special variable that is never zero initialized in the prolog. inline bool fgVarIsNeverZeroInitializedInProlog(unsigned varNum); // Returns "true" if the variable needs explicit zero initialization. inline bool fgVarNeedsExplicitZeroInit(unsigned varNum, bool bbInALoop, bool bbIsReturn); // The value numbers for this compilation. ValueNumStore* vnStore; public: ValueNumStore* GetValueNumStore() { return vnStore; } // Do value numbering (assign a value number to each // tree node). void fgValueNumber(); // Computes new GcHeap VN via the assignment H[elemTypeEq][arrVN][inx][fldSeq] = rhsVN. // Assumes that "elemTypeEq" is the (equivalence class rep) of the array element type. // The 'indType' is the indirection type of the lhs of the assignment and will typically // match the element type of the array or fldSeq. When this type doesn't match // or if the fldSeq is 'NotAField' we invalidate the array contents H[elemTypeEq][arrVN] // ValueNum fgValueNumberArrIndexAssign(CORINFO_CLASS_HANDLE elemTypeEq, ValueNum arrVN, ValueNum inxVN, FieldSeqNode* fldSeq, ValueNum rhsVN, var_types indType); // Requires that "tree" is a GT_IND marked as an array index, and that its address argument // has been parsed to yield the other input arguments. If evaluation of the address // can raise exceptions, those should be captured in the exception set "addrXvnp". // Assumes that "elemTypeEq" is the (equivalence class rep) of the array element type. // Marks "tree" with the VN for H[elemTypeEq][arrVN][inx][fldSeq] (for the liberal VN; a new unique // VN for the conservative VN.) Also marks the tree's argument as the address of an array element. // The type tree->TypeGet() will typically match the element type of the array or fldSeq. // When this type doesn't match or if the fldSeq is 'NotAField' we return a new unique VN // ValueNum fgValueNumberArrIndexVal(GenTree* tree, CORINFO_CLASS_HANDLE elemTypeEq, ValueNum arrVN, ValueNum inxVN, ValueNumPair addrXvnp, FieldSeqNode* fldSeq); // Requires "funcApp" to be a VNF_PtrToArrElem, and "addrXvnp" to represent the exception set thrown // by evaluating the array index expression "tree". Returns the value number resulting from // dereferencing the array in the current GcHeap state. If "tree" is non-null, it must be the // "GT_IND" that does the dereference, and it is given the returned value number. ValueNum fgValueNumberArrIndexVal(GenTree* tree, VNFuncApp* funcApp, ValueNumPair addrXvnp); // Compute the value number for a byref-exposed load of the given type via the given pointerVN. ValueNum fgValueNumberByrefExposedLoad(var_types type, ValueNum pointerVN); unsigned fgVNPassesCompleted; // Number of times fgValueNumber has been run. // Utility functions for fgValueNumber. // Perform value-numbering for the trees in "blk". void fgValueNumberBlock(BasicBlock* blk); // Requires that "entryBlock" is the entry block of loop "loopNum", and that "loopNum" is the // innermost loop of which "entryBlock" is the entry. Returns the value number that should be // assumed for the memoryKind at the start "entryBlk". ValueNum fgMemoryVNForLoopSideEffects(MemoryKind memoryKind, BasicBlock* entryBlock, unsigned loopNum); // Called when an operation (performed by "tree", described by "msg") may cause the GcHeap to be mutated. // As GcHeap is a subset of ByrefExposed, this will also annotate the ByrefExposed mutation. void fgMutateGcHeap(GenTree* tree DEBUGARG(const char* msg)); // Called when an operation (performed by "tree", described by "msg") may cause an address-exposed local to be // mutated. void fgMutateAddressExposedLocal(GenTree* tree DEBUGARG(const char* msg)); // For a GC heap store at curTree, record the new curMemoryVN's and update curTree's MemorySsaMap. // As GcHeap is a subset of ByrefExposed, this will also record the ByrefExposed store. void recordGcHeapStore(GenTree* curTree, ValueNum gcHeapVN DEBUGARG(const char* msg)); // For a store to an address-exposed local at curTree, record the new curMemoryVN and update curTree's MemorySsaMap. void recordAddressExposedLocalStore(GenTree* curTree, ValueNum memoryVN DEBUGARG(const char* msg)); void fgSetCurrentMemoryVN(MemoryKind memoryKind, ValueNum newMemoryVN); // Tree caused an update in the current memory VN. If "tree" has an associated heap SSA #, record that // value in that SSA #. void fgValueNumberRecordMemorySsa(MemoryKind memoryKind, GenTree* tree); // The input 'tree' is a leaf node that is a constant // Assign the proper value number to the tree void fgValueNumberTreeConst(GenTree* tree); // If the VN store has been initialized, reassign the // proper value number to the constant tree. void fgUpdateConstTreeValueNumber(GenTree* tree); // Assumes that all inputs to "tree" have had value numbers assigned; assigns a VN to tree. // (With some exceptions: the VN of the lhs of an assignment is assigned as part of the // assignment.) void fgValueNumberTree(GenTree* tree); void fgValueNumberAssignment(GenTreeOp* tree); // Does value-numbering for a block assignment. void fgValueNumberBlockAssignment(GenTree* tree); bool fgValueNumberBlockAssignmentTypeCheck(LclVarDsc* dstVarDsc, FieldSeqNode* dstFldSeq, GenTree* src); // Does value-numbering for a cast tree. void fgValueNumberCastTree(GenTree* tree); // Does value-numbering for an intrinsic tree. void fgValueNumberIntrinsic(GenTree* tree); #ifdef FEATURE_SIMD // Does value-numbering for a GT_SIMD tree void fgValueNumberSimd(GenTreeSIMD* tree); #endif // FEATURE_SIMD #ifdef FEATURE_HW_INTRINSICS // Does value-numbering for a GT_HWINTRINSIC tree void fgValueNumberHWIntrinsic(GenTreeHWIntrinsic* tree); #endif // FEATURE_HW_INTRINSICS // Does value-numbering for a call. We interpret some helper calls. void fgValueNumberCall(GenTreeCall* call); // Does value-numbering for a helper representing a cast operation. void fgValueNumberCastHelper(GenTreeCall* call); // Does value-numbering for a helper "call" that has a VN function symbol "vnf". void fgValueNumberHelperCallFunc(GenTreeCall* call, VNFunc vnf, ValueNumPair vnpExc); // Requires "helpCall" to be a helper call. Assigns it a value number; // we understand the semantics of some of the calls. Returns "true" if // the call may modify the heap (we assume arbitrary memory side effects if so). bool fgValueNumberHelperCall(GenTreeCall* helpCall); // Requires that "helpFunc" is one of the pure Jit Helper methods. // Returns the corresponding VNFunc to use for value numbering VNFunc fgValueNumberJitHelperMethodVNFunc(CorInfoHelpFunc helpFunc); // Adds the exception set for the current tree node which has a memory indirection operation void fgValueNumberAddExceptionSetForIndirection(GenTree* tree, GenTree* baseAddr); // Adds the exception sets for the current tree node which is performing a division or modulus operation void fgValueNumberAddExceptionSetForDivision(GenTree* tree); // Adds the exception set for the current tree node which is performing a overflow checking operation void fgValueNumberAddExceptionSetForOverflow(GenTree* tree); // Adds the exception set for the current tree node which is performing a bounds check operation void fgValueNumberAddExceptionSetForBoundsCheck(GenTree* tree); // Adds the exception set for the current tree node which is performing a ckfinite operation void fgValueNumberAddExceptionSetForCkFinite(GenTree* tree); // Adds the exception sets for the current tree node void fgValueNumberAddExceptionSet(GenTree* tree); #ifdef DEBUG void fgDebugCheckExceptionSets(); void fgDebugCheckValueNumberedTree(GenTree* tree); #endif // These are the current value number for the memory implicit variables while // doing value numbering. These are the value numbers under the "liberal" interpretation // of memory values; the "conservative" interpretation needs no VN, since every access of // memory yields an unknown value. ValueNum fgCurMemoryVN[MemoryKindCount]; // Return a "pseudo"-class handle for an array element type. If "elemType" is TYP_STRUCT, // requires "elemStructType" to be non-null (and to have a low-order zero). Otherwise, low order bit // is 1, and the rest is an encoding of "elemTyp". static CORINFO_CLASS_HANDLE EncodeElemType(var_types elemTyp, CORINFO_CLASS_HANDLE elemStructType) { if (elemStructType != nullptr) { assert(varTypeIsStruct(elemTyp) || elemTyp == TYP_REF || elemTyp == TYP_BYREF || varTypeIsIntegral(elemTyp)); assert((size_t(elemStructType) & 0x1) == 0x0); // Make sure the encoding below is valid. return elemStructType; } else { assert(elemTyp != TYP_STRUCT); elemTyp = varTypeToSigned(elemTyp); return CORINFO_CLASS_HANDLE(size_t(elemTyp) << 1 | 0x1); } } // If "clsHnd" is the result of an "EncodePrim" call, returns true and sets "*pPrimType" to the // var_types it represents. Otherwise, returns TYP_STRUCT (on the assumption that "clsHnd" is // the struct type of the element). static var_types DecodeElemType(CORINFO_CLASS_HANDLE clsHnd) { size_t clsHndVal = size_t(clsHnd); if (clsHndVal & 0x1) { return var_types(clsHndVal >> 1); } else { return TYP_STRUCT; } } // Convert a BYTE which represents the VM's CorInfoGCtype to the JIT's var_types var_types getJitGCType(BYTE gcType); // Returns true if the provided type should be treated as a primitive type // for the unmanaged calling conventions. bool isNativePrimitiveStructType(CORINFO_CLASS_HANDLE clsHnd); enum structPassingKind { SPK_Unknown, // Invalid value, never returned SPK_PrimitiveType, // The struct is passed/returned using a primitive type. SPK_EnclosingType, // Like SPK_Primitive type, but used for return types that // require a primitive type temp that is larger than the struct size. // Currently used for structs of size 3, 5, 6, or 7 bytes. SPK_ByValue, // The struct is passed/returned by value (using the ABI rules) // for ARM64 and UNIX_X64 in multiple registers. (when all of the // parameters registers are used, then the stack will be used) // for X86 passed on the stack, for ARM32 passed in registers // or the stack or split between registers and the stack. SPK_ByValueAsHfa, // The struct is passed/returned as an HFA in multiple registers. SPK_ByReference }; // The struct is passed/returned by reference to a copy/buffer. // Get the "primitive" type that is is used when we are given a struct of size 'structSize'. // For pointer sized structs the 'clsHnd' is used to determine if the struct contains GC ref. // A "primitive" type is one of the scalar types: byte, short, int, long, ref, float, double // If we can't or shouldn't use a "primitive" type then TYP_UNKNOWN is returned. // // isVarArg is passed for use on Windows Arm64 to change the decision returned regarding // hfa types. // var_types getPrimitiveTypeForStruct(unsigned structSize, CORINFO_CLASS_HANDLE clsHnd, bool isVarArg); // Get the type that is used to pass values of the given struct type. // isVarArg is passed for use on Windows Arm64 to change the decision returned regarding // hfa types. // var_types getArgTypeForStruct(CORINFO_CLASS_HANDLE clsHnd, structPassingKind* wbPassStruct, bool isVarArg, unsigned structSize); // Get the type that is used to return values of the given struct type. // If the size is unknown, pass 0 and it will be determined from 'clsHnd'. var_types getReturnTypeForStruct(CORINFO_CLASS_HANDLE clsHnd, CorInfoCallConvExtension callConv, structPassingKind* wbPassStruct = nullptr, unsigned structSize = 0); #ifdef DEBUG // Print a representation of "vnp" or "vn" on standard output. // If "level" is non-zero, we also print out a partial expansion of the value. void vnpPrint(ValueNumPair vnp, unsigned level); void vnPrint(ValueNum vn, unsigned level); #endif bool fgDominate(BasicBlock* b1, BasicBlock* b2); // Return true if b1 dominates b2 // Dominator computation member functions // Not exposed outside Compiler protected: bool fgReachable(BasicBlock* b1, BasicBlock* b2); // Returns true if block b1 can reach block b2 // Compute immediate dominators, the dominator tree and and its pre/post-order travsersal numbers. void fgComputeDoms(); void fgCompDominatedByExceptionalEntryBlocks(); BlockSet_ValRet_T fgGetDominatorSet(BasicBlock* block); // Returns a set of blocks that dominate the given block. // Note: this is relatively slow compared to calling fgDominate(), // especially if dealing with a single block versus block check. void fgComputeReachabilitySets(); // Compute bbReach sets. (Also sets BBF_GC_SAFE_POINT flag on blocks.) void fgComputeReturnBlocks(); // Initialize fgReturnBlocks to a list of BBJ_RETURN blocks. void fgComputeEnterBlocksSet(); // Compute the set of entry blocks, 'fgEnterBlks'. bool fgRemoveUnreachableBlocks(); // Remove blocks determined to be unreachable by the bbReach sets. void fgComputeReachability(); // Perform flow graph node reachability analysis. BasicBlock* fgIntersectDom(BasicBlock* a, BasicBlock* b); // Intersect two immediate dominator sets. void fgDfsInvPostOrder(); // In order to compute dominance using fgIntersectDom, the flow graph nodes must be // processed in topological sort, this function takes care of that. void fgDfsInvPostOrderHelper(BasicBlock* block, BlockSet& visited, unsigned* count); BlockSet_ValRet_T fgDomFindStartNodes(); // Computes which basic blocks don't have incoming edges in the flow graph. // Returns this as a set. INDEBUG(void fgDispDomTree(DomTreeNode* domTree);) // Helper that prints out the Dominator Tree in debug builds. DomTreeNode* fgBuildDomTree(); // Once we compute all the immediate dominator sets for each node in the flow graph // (performed by fgComputeDoms), this procedure builds the dominance tree represented // adjacency lists. // In order to speed up the queries of the form 'Does A dominates B', we can perform a DFS preorder and postorder // traversal of the dominance tree and the dominance query will become A dominates B iif preOrder(A) <= preOrder(B) // && postOrder(A) >= postOrder(B) making the computation O(1). void fgNumberDomTree(DomTreeNode* domTree); // When the flow graph changes, we need to update the block numbers, predecessor lists, reachability sets, // dominators, and possibly loops. void fgUpdateChangedFlowGraph(const bool computePreds = true, const bool computeDoms = true, const bool computeReturnBlocks = false, const bool computeLoops = false); public: // Compute the predecessors of the blocks in the control flow graph. void fgComputePreds(); // Remove all predecessor information. void fgRemovePreds(); // Compute the cheap flow graph predecessors lists. This is used in some early phases // before the full predecessors lists are computed. void fgComputeCheapPreds(); private: void fgAddCheapPred(BasicBlock* block, BasicBlock* blockPred); void fgRemoveCheapPred(BasicBlock* block, BasicBlock* blockPred); public: enum GCPollType { GCPOLL_NONE, GCPOLL_CALL, GCPOLL_INLINE }; // Initialize the per-block variable sets (used for liveness analysis). void fgInitBlockVarSets(); PhaseStatus fgInsertGCPolls(); BasicBlock* fgCreateGCPoll(GCPollType pollType, BasicBlock* block); // Requires that "block" is a block that returns from // a finally. Returns the number of successors (jump targets of // of blocks in the covered "try" that did a "LEAVE".) unsigned fgNSuccsOfFinallyRet(BasicBlock* block); // Requires that "block" is a block that returns (in the sense of BBJ_EHFINALLYRET) from // a finally. Returns its "i"th successor (jump targets of // of blocks in the covered "try" that did a "LEAVE".) // Requires that "i" < fgNSuccsOfFinallyRet(block). BasicBlock* fgSuccOfFinallyRet(BasicBlock* block, unsigned i); private: // Factor out common portions of the impls of the methods above. void fgSuccOfFinallyRetWork(BasicBlock* block, unsigned i, BasicBlock** bres, unsigned* nres); public: // For many purposes, it is desirable to be able to enumerate the *distinct* targets of a switch statement, // skipping duplicate targets. (E.g., in flow analyses that are only interested in the set of possible targets.) // SwitchUniqueSuccSet contains the non-duplicated switch targets. // (Code that modifies the jump table of a switch has an obligation to call Compiler::UpdateSwitchTableTarget, // which in turn will call the "UpdateTarget" method of this type if a SwitchUniqueSuccSet has already // been computed for the switch block. If a switch block is deleted or is transformed into a non-switch, // we leave the entry associated with the block, but it will no longer be accessed.) struct SwitchUniqueSuccSet { unsigned numDistinctSuccs; // Number of distinct targets of the switch. BasicBlock** nonDuplicates; // Array of "numDistinctSuccs", containing all the distinct switch target // successors. // The switch block "switchBlk" just had an entry with value "from" modified to the value "to". // Update "this" as necessary: if "from" is no longer an element of the jump table of "switchBlk", // remove it from "this", and ensure that "to" is a member. Use "alloc" to do any required allocation. void UpdateTarget(CompAllocator alloc, BasicBlock* switchBlk, BasicBlock* from, BasicBlock* to); }; typedef JitHashTable<BasicBlock*, JitPtrKeyFuncs<BasicBlock>, SwitchUniqueSuccSet> BlockToSwitchDescMap; private: // Maps BasicBlock*'s that end in switch statements to SwitchUniqueSuccSets that allow // iteration over only the distinct successors. BlockToSwitchDescMap* m_switchDescMap; public: BlockToSwitchDescMap* GetSwitchDescMap(bool createIfNull = true) { if ((m_switchDescMap == nullptr) && createIfNull) { m_switchDescMap = new (getAllocator()) BlockToSwitchDescMap(getAllocator()); } return m_switchDescMap; } // Invalidate the map of unique switch block successors. For example, since the hash key of the map // depends on block numbers, we must invalidate the map when the blocks are renumbered, to ensure that // we don't accidentally look up and return the wrong switch data. void InvalidateUniqueSwitchSuccMap() { m_switchDescMap = nullptr; } // Requires "switchBlock" to be a block that ends in a switch. Returns // the corresponding SwitchUniqueSuccSet. SwitchUniqueSuccSet GetDescriptorForSwitch(BasicBlock* switchBlk); // The switch block "switchBlk" just had an entry with value "from" modified to the value "to". // Update "this" as necessary: if "from" is no longer an element of the jump table of "switchBlk", // remove it from "this", and ensure that "to" is a member. void UpdateSwitchTableTarget(BasicBlock* switchBlk, BasicBlock* from, BasicBlock* to); // Remove the "SwitchUniqueSuccSet" of "switchBlk" in the BlockToSwitchDescMap. void fgInvalidateSwitchDescMapEntry(BasicBlock* switchBlk); BasicBlock* fgFirstBlockOfHandler(BasicBlock* block); bool fgIsFirstBlockOfFilterOrHandler(BasicBlock* block); flowList* fgGetPredForBlock(BasicBlock* block, BasicBlock* blockPred); flowList* fgGetPredForBlock(BasicBlock* block, BasicBlock* blockPred, flowList*** ptrToPred); flowList* fgRemoveRefPred(BasicBlock* block, BasicBlock* blockPred); flowList* fgRemoveAllRefPreds(BasicBlock* block, BasicBlock* blockPred); void fgRemoveBlockAsPred(BasicBlock* block); void fgChangeSwitchBlock(BasicBlock* oldSwitchBlock, BasicBlock* newSwitchBlock); void fgReplaceSwitchJumpTarget(BasicBlock* blockSwitch, BasicBlock* newTarget, BasicBlock* oldTarget); void fgReplaceJumpTarget(BasicBlock* block, BasicBlock* newTarget, BasicBlock* oldTarget); void fgReplacePred(BasicBlock* block, BasicBlock* oldPred, BasicBlock* newPred); flowList* fgAddRefPred(BasicBlock* block, BasicBlock* blockPred, flowList* oldEdge = nullptr, bool initializingPreds = false); // Only set to 'true' when we are computing preds in // fgComputePreds() void fgFindBasicBlocks(); bool fgIsBetterFallThrough(BasicBlock* bCur, BasicBlock* bAlt); bool fgCheckEHCanInsertAfterBlock(BasicBlock* blk, unsigned regionIndex, bool putInTryRegion); BasicBlock* fgFindInsertPoint(unsigned regionIndex, bool putInTryRegion, BasicBlock* startBlk, BasicBlock* endBlk, BasicBlock* nearBlk, BasicBlock* jumpBlk, bool runRarely); unsigned fgGetNestingLevel(BasicBlock* block, unsigned* pFinallyNesting = nullptr); void fgPostImportationCleanup(); void fgRemoveStmt(BasicBlock* block, Statement* stmt DEBUGARG(bool isUnlink = false)); void fgUnlinkStmt(BasicBlock* block, Statement* stmt); bool fgCheckRemoveStmt(BasicBlock* block, Statement* stmt); void fgCreateLoopPreHeader(unsigned lnum); void fgUnreachableBlock(BasicBlock* block); void fgRemoveConditionalJump(BasicBlock* block); BasicBlock* fgLastBBInMainFunction(); BasicBlock* fgEndBBAfterMainFunction(); void fgUnlinkRange(BasicBlock* bBeg, BasicBlock* bEnd); void fgRemoveBlock(BasicBlock* block, bool unreachable); bool fgCanCompactBlocks(BasicBlock* block, BasicBlock* bNext); void fgCompactBlocks(BasicBlock* block, BasicBlock* bNext); void fgUpdateLoopsAfterCompacting(BasicBlock* block, BasicBlock* bNext); BasicBlock* fgConnectFallThrough(BasicBlock* bSrc, BasicBlock* bDst); bool fgRenumberBlocks(); bool fgExpandRarelyRunBlocks(); bool fgEhAllowsMoveBlock(BasicBlock* bBefore, BasicBlock* bAfter); void fgMoveBlocksAfter(BasicBlock* bStart, BasicBlock* bEnd, BasicBlock* insertAfterBlk); enum FG_RELOCATE_TYPE { FG_RELOCATE_TRY, // relocate the 'try' region FG_RELOCATE_HANDLER // relocate the handler region (including the filter if necessary) }; BasicBlock* fgRelocateEHRange(unsigned regionIndex, FG_RELOCATE_TYPE relocateType); #if defined(FEATURE_EH_FUNCLETS) #if defined(TARGET_ARM) void fgClearFinallyTargetBit(BasicBlock* block); #endif // defined(TARGET_ARM) bool fgIsIntraHandlerPred(BasicBlock* predBlock, BasicBlock* block); bool fgAnyIntraHandlerPreds(BasicBlock* block); void fgInsertFuncletPrologBlock(BasicBlock* block); void fgCreateFuncletPrologBlocks(); void fgCreateFunclets(); #else // !FEATURE_EH_FUNCLETS bool fgRelocateEHRegions(); #endif // !FEATURE_EH_FUNCLETS bool fgOptimizeUncondBranchToSimpleCond(BasicBlock* block, BasicBlock* target); bool fgBlockEndFavorsTailDuplication(BasicBlock* block, unsigned lclNum); bool fgBlockIsGoodTailDuplicationCandidate(BasicBlock* block, unsigned* lclNum); bool fgOptimizeEmptyBlock(BasicBlock* block); bool fgOptimizeBranchToEmptyUnconditional(BasicBlock* block, BasicBlock* bDest); bool fgOptimizeBranch(BasicBlock* bJump); bool fgOptimizeSwitchBranches(BasicBlock* block); bool fgOptimizeBranchToNext(BasicBlock* block, BasicBlock* bNext, BasicBlock* bPrev); bool fgOptimizeSwitchJumps(); #ifdef DEBUG void fgPrintEdgeWeights(); #endif void fgComputeBlockAndEdgeWeights(); weight_t fgComputeMissingBlockWeights(); void fgComputeCalledCount(weight_t returnWeight); void fgComputeEdgeWeights(); bool fgReorderBlocks(); PhaseStatus fgDetermineFirstColdBlock(); bool fgIsForwardBranch(BasicBlock* bJump, BasicBlock* bSrc = nullptr); bool fgUpdateFlowGraph(bool doTailDup = false); void fgFindOperOrder(); // method that returns if you should split here typedef bool(fgSplitPredicate)(GenTree* tree, GenTree* parent, fgWalkData* data); void fgSetBlockOrder(); void fgRemoveReturnBlock(BasicBlock* block); /* Helper code that has been factored out */ inline void fgConvertBBToThrowBB(BasicBlock* block); bool fgCastNeeded(GenTree* tree, var_types toType); GenTree* fgDoNormalizeOnStore(GenTree* tree); GenTree* fgMakeTmpArgNode(fgArgTabEntry* curArgTabEntry); // The following check for loops that don't execute calls bool fgLoopCallMarked; void fgLoopCallTest(BasicBlock* srcBB, BasicBlock* dstBB); void fgLoopCallMark(); void fgMarkLoopHead(BasicBlock* block); unsigned fgGetCodeEstimate(BasicBlock* block); #if DUMP_FLOWGRAPHS enum class PhasePosition { PrePhase, PostPhase }; const char* fgProcessEscapes(const char* nameIn, escapeMapping_t* map); static void fgDumpTree(FILE* fgxFile, GenTree* const tree); FILE* fgOpenFlowGraphFile(bool* wbDontClose, Phases phase, PhasePosition pos, LPCWSTR type); bool fgDumpFlowGraph(Phases phase, PhasePosition pos); #endif // DUMP_FLOWGRAPHS #ifdef DEBUG void fgDispDoms(); void fgDispReach(); void fgDispBBLiveness(BasicBlock* block); void fgDispBBLiveness(); void fgTableDispBasicBlock(BasicBlock* block, int ibcColWidth = 0); void fgDispBasicBlocks(BasicBlock* firstBlock, BasicBlock* lastBlock, bool dumpTrees); void fgDispBasicBlocks(bool dumpTrees = false); void fgDumpStmtTree(Statement* stmt, unsigned bbNum); void fgDumpBlock(BasicBlock* block); void fgDumpTrees(BasicBlock* firstBlock, BasicBlock* lastBlock); static fgWalkPreFn fgStress64RsltMulCB; void fgStress64RsltMul(); void fgDebugCheckUpdate(); void fgDebugCheckBBNumIncreasing(); void fgDebugCheckBBlist(bool checkBBNum = false, bool checkBBRefs = true); void fgDebugCheckBlockLinks(); void fgDebugCheckLinks(bool morphTrees = false); void fgDebugCheckStmtsList(BasicBlock* block, bool morphTrees); void fgDebugCheckNodeLinks(BasicBlock* block, Statement* stmt); void fgDebugCheckNodesUniqueness(); void fgDebugCheckLoopTable(); void fgDebugCheckFlags(GenTree* tree); void fgDebugCheckDispFlags(GenTree* tree, GenTreeFlags dispFlags, GenTreeDebugFlags debugFlags); void fgDebugCheckFlagsHelper(GenTree* tree, GenTreeFlags actualFlags, GenTreeFlags expectedFlags); void fgDebugCheckTryFinallyExits(); void fgDebugCheckProfileData(); bool fgDebugCheckIncomingProfileData(BasicBlock* block); bool fgDebugCheckOutgoingProfileData(BasicBlock* block); #endif // DEBUG static bool fgProfileWeightsEqual(weight_t weight1, weight_t weight2); static bool fgProfileWeightsConsistent(weight_t weight1, weight_t weight2); static GenTree* fgGetFirstNode(GenTree* tree); //--------------------- Walking the trees in the IR ----------------------- struct fgWalkData { Compiler* compiler; fgWalkPreFn* wtprVisitorFn; fgWalkPostFn* wtpoVisitorFn; void* pCallbackData; // user-provided data GenTree* parent; // parent of current node, provided to callback GenTreeStack* parentStack; // stack of parent nodes, if asked for bool wtprLclsOnly; // whether to only visit lclvar nodes #ifdef DEBUG bool printModified; // callback can use this #endif }; fgWalkResult fgWalkTreePre(GenTree** pTree, fgWalkPreFn* visitor, void* pCallBackData = nullptr, bool lclVarsOnly = false, bool computeStack = false); fgWalkResult fgWalkTree(GenTree** pTree, fgWalkPreFn* preVisitor, fgWalkPostFn* postVisitor, void* pCallBackData = nullptr); void fgWalkAllTreesPre(fgWalkPreFn* visitor, void* pCallBackData); //----- Postorder fgWalkResult fgWalkTreePost(GenTree** pTree, fgWalkPostFn* visitor, void* pCallBackData = nullptr, bool computeStack = false); // An fgWalkPreFn that looks for expressions that have inline throws in // minopts mode. Basically it looks for tress with gtOverflowEx() or // GTF_IND_RNGCHK. It returns WALK_ABORT if one is found. It // returns WALK_SKIP_SUBTREES if GTF_EXCEPT is not set (assumes flags // properly propagated to parent trees). It returns WALK_CONTINUE // otherwise. static fgWalkResult fgChkThrowCB(GenTree** pTree, Compiler::fgWalkData* data); static fgWalkResult fgChkLocAllocCB(GenTree** pTree, Compiler::fgWalkData* data); static fgWalkResult fgChkQmarkCB(GenTree** pTree, Compiler::fgWalkData* data); /************************************************************************** * PROTECTED *************************************************************************/ protected: friend class SsaBuilder; friend struct ValueNumberState; //--------------------- Detect the basic blocks --------------------------- BasicBlock** fgBBs; // Table of pointers to the BBs void fgInitBBLookup(); BasicBlock* fgLookupBB(unsigned addr); bool fgCanSwitchToOptimized(); void fgSwitchToOptimized(const char* reason); bool fgMayExplicitTailCall(); void fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, FixedBitVect* jumpTarget); void fgMarkBackwardJump(BasicBlock* startBlock, BasicBlock* endBlock); void fgLinkBasicBlocks(); unsigned fgMakeBasicBlocks(const BYTE* codeAddr, IL_OFFSET codeSize, FixedBitVect* jumpTarget); void fgCheckBasicBlockControlFlow(); void fgControlFlowPermitted(BasicBlock* blkSrc, BasicBlock* blkDest, bool IsLeave = false /* is the src a leave block */); bool fgFlowToFirstBlockOfInnerTry(BasicBlock* blkSrc, BasicBlock* blkDest, bool sibling); void fgObserveInlineConstants(OPCODE opcode, const FgStack& stack, bool isInlining); void fgAdjustForAddressExposedOrWrittenThis(); unsigned fgStressBBProf() { #ifdef DEBUG unsigned result = JitConfig.JitStressBBProf(); if (result == 0) { if (compStressCompile(STRESS_BB_PROFILE, 15)) { result = 1; } } return result; #else return 0; #endif } bool fgHaveProfileData(); bool fgGetProfileWeightForBasicBlock(IL_OFFSET offset, weight_t* weight); Instrumentor* fgCountInstrumentor; Instrumentor* fgClassInstrumentor; PhaseStatus fgPrepareToInstrumentMethod(); PhaseStatus fgInstrumentMethod(); PhaseStatus fgIncorporateProfileData(); void fgIncorporateBlockCounts(); void fgIncorporateEdgeCounts(); CORINFO_CLASS_HANDLE getRandomClass(ICorJitInfo::PgoInstrumentationSchema* schema, UINT32 countSchemaItems, BYTE* pInstrumentationData, int32_t ilOffset, CLRRandom* random); public: const char* fgPgoFailReason; bool fgPgoDisabled; ICorJitInfo::PgoSource fgPgoSource; ICorJitInfo::PgoInstrumentationSchema* fgPgoSchema; BYTE* fgPgoData; UINT32 fgPgoSchemaCount; HRESULT fgPgoQueryResult; UINT32 fgNumProfileRuns; UINT32 fgPgoBlockCounts; UINT32 fgPgoEdgeCounts; UINT32 fgPgoClassProfiles; unsigned fgPgoInlineePgo; unsigned fgPgoInlineeNoPgo; unsigned fgPgoInlineeNoPgoSingleBlock; void WalkSpanningTree(SpanningTreeVisitor* visitor); void fgSetProfileWeight(BasicBlock* block, weight_t weight); void fgApplyProfileScale(); bool fgHaveSufficientProfileData(); bool fgHaveTrustedProfileData(); // fgIsUsingProfileWeights - returns true if we have real profile data for this method // or if we have some fake profile data for the stress mode bool fgIsUsingProfileWeights() { return (fgHaveProfileData() || fgStressBBProf()); } // fgProfileRunsCount - returns total number of scenario runs for the profile data // or BB_UNITY_WEIGHT_UNSIGNED when we aren't using profile data. unsigned fgProfileRunsCount() { return fgIsUsingProfileWeights() ? fgNumProfileRuns : BB_UNITY_WEIGHT_UNSIGNED; } //-------- Insert a statement at the start or end of a basic block -------- #ifdef DEBUG public: static bool fgBlockContainsStatementBounded(BasicBlock* block, Statement* stmt, bool answerOnBoundExceeded = true); #endif public: Statement* fgNewStmtAtBeg(BasicBlock* block, GenTree* tree, const DebugInfo& di = DebugInfo()); void fgInsertStmtAtEnd(BasicBlock* block, Statement* stmt); Statement* fgNewStmtAtEnd(BasicBlock* block, GenTree* tree, const DebugInfo& di = DebugInfo()); Statement* fgNewStmtNearEnd(BasicBlock* block, GenTree* tree, const DebugInfo& di = DebugInfo()); private: void fgInsertStmtNearEnd(BasicBlock* block, Statement* stmt); void fgInsertStmtAtBeg(BasicBlock* block, Statement* stmt); void fgInsertStmtAfter(BasicBlock* block, Statement* insertionPoint, Statement* stmt); public: void fgInsertStmtBefore(BasicBlock* block, Statement* insertionPoint, Statement* stmt); private: Statement* fgInsertStmtListAfter(BasicBlock* block, Statement* stmtAfter, Statement* stmtList); // Create a new temporary variable to hold the result of *ppTree, // and transform the graph accordingly. GenTree* fgInsertCommaFormTemp(GenTree** ppTree, CORINFO_CLASS_HANDLE structType = nullptr); GenTree* fgMakeMultiUse(GenTree** ppTree); private: // Recognize a bitwise rotation pattern and convert into a GT_ROL or a GT_ROR node. GenTree* fgRecognizeAndMorphBitwiseRotation(GenTree* tree); bool fgOperIsBitwiseRotationRoot(genTreeOps oper); #if !defined(TARGET_64BIT) // Recognize and morph a long multiplication with 32 bit operands. GenTreeOp* fgRecognizeAndMorphLongMul(GenTreeOp* mul); GenTreeOp* fgMorphLongMul(GenTreeOp* mul); #endif //-------- Determine the order in which the trees will be evaluated ------- unsigned fgTreeSeqNum; GenTree* fgTreeSeqLst; GenTree* fgTreeSeqBeg; GenTree* fgSetTreeSeq(GenTree* tree, GenTree* prev = nullptr, bool isLIR = false); void fgSetTreeSeqHelper(GenTree* tree, bool isLIR); void fgSetTreeSeqFinish(GenTree* tree, bool isLIR); void fgSetStmtSeq(Statement* stmt); void fgSetBlockOrder(BasicBlock* block); //------------------------- Morphing -------------------------------------- unsigned fgPtrArgCntMax; public: //------------------------------------------------------------------------ // fgGetPtrArgCntMax: Return the maximum number of pointer-sized stack arguments that calls inside this method // can push on the stack. This value is calculated during morph. // // Return Value: // Returns fgPtrArgCntMax, that is a private field. // unsigned fgGetPtrArgCntMax() const { return fgPtrArgCntMax; } //------------------------------------------------------------------------ // fgSetPtrArgCntMax: Set the maximum number of pointer-sized stack arguments that calls inside this method // can push on the stack. This function is used during StackLevelSetter to fix incorrect morph calculations. // void fgSetPtrArgCntMax(unsigned argCntMax) { fgPtrArgCntMax = argCntMax; } bool compCanEncodePtrArgCntMax(); private: hashBv* fgOutgoingArgTemps; hashBv* fgCurrentlyInUseArgTemps; void fgSetRngChkTarget(GenTree* tree, bool delay = true); BasicBlock* fgSetRngChkTargetInner(SpecialCodeKind kind, bool delay); #if REARRANGE_ADDS void fgMoveOpsLeft(GenTree* tree); #endif bool fgIsCommaThrow(GenTree* tree, bool forFolding = false); bool fgIsThrow(GenTree* tree); bool fgInDifferentRegions(BasicBlock* blk1, BasicBlock* blk2); bool fgIsBlockCold(BasicBlock* block); GenTree* fgMorphCastIntoHelper(GenTree* tree, int helper, GenTree* oper); GenTree* fgMorphIntoHelperCall(GenTree* tree, int helper, GenTreeCall::Use* args, bool morphArgs = true); GenTree* fgMorphStackArgForVarArgs(unsigned lclNum, var_types varType, unsigned lclOffs); // A "MorphAddrContext" carries information from the surrounding context. If we are evaluating a byref address, // it is useful to know whether the address will be immediately dereferenced, or whether the address value will // be used, perhaps by passing it as an argument to a called method. This affects how null checking is done: // for sufficiently small offsets, we can rely on OS page protection to implicitly null-check addresses that we // know will be dereferenced. To know that reliance on implicit null checking is sound, we must further know that // all offsets between the top-level indirection and the bottom are constant, and that their sum is sufficiently // small; hence the other fields of MorphAddrContext. enum MorphAddrContextKind { MACK_Ind, MACK_Addr, }; struct MorphAddrContext { MorphAddrContextKind m_kind; bool m_allConstantOffsets; // Valid only for "m_kind == MACK_Ind". True iff all offsets between // top-level indirection and here have been constants. size_t m_totalOffset; // Valid only for "m_kind == MACK_Ind", and if "m_allConstantOffsets" is true. // In that case, is the sum of those constant offsets. MorphAddrContext(MorphAddrContextKind kind) : m_kind(kind), m_allConstantOffsets(true), m_totalOffset(0) { } }; // A MACK_CopyBlock context is immutable, so we can just make one of these and share it. static MorphAddrContext s_CopyBlockMAC; #ifdef FEATURE_SIMD GenTree* getSIMDStructFromField(GenTree* tree, CorInfoType* simdBaseJitTypeOut, unsigned* indexOut, unsigned* simdSizeOut, bool ignoreUsedInSIMDIntrinsic = false); GenTree* fgMorphFieldAssignToSimdSetElement(GenTree* tree); GenTree* fgMorphFieldToSimdGetElement(GenTree* tree); bool fgMorphCombineSIMDFieldAssignments(BasicBlock* block, Statement* stmt); void impMarkContiguousSIMDFieldAssignments(Statement* stmt); // fgPreviousCandidateSIMDFieldAsgStmt is only used for tracking previous simd field assignment // in function: Complier::impMarkContiguousSIMDFieldAssignments. Statement* fgPreviousCandidateSIMDFieldAsgStmt; #endif // FEATURE_SIMD GenTree* fgMorphArrayIndex(GenTree* tree); GenTree* fgMorphExpandCast(GenTreeCast* tree); GenTreeFieldList* fgMorphLclArgToFieldlist(GenTreeLclVarCommon* lcl); void fgInitArgInfo(GenTreeCall* call); GenTreeCall* fgMorphArgs(GenTreeCall* call); void fgMakeOutgoingStructArgCopy(GenTreeCall* call, GenTreeCall::Use* args, CORINFO_CLASS_HANDLE copyBlkClass); GenTree* fgMorphLocalVar(GenTree* tree, bool forceRemorph); public: bool fgAddrCouldBeNull(GenTree* addr); private: GenTree* fgMorphField(GenTree* tree, MorphAddrContext* mac); bool fgCanFastTailCall(GenTreeCall* call, const char** failReason); #if FEATURE_FASTTAILCALL bool fgCallHasMustCopyByrefParameter(GenTreeCall* callee); #endif bool fgCheckStmtAfterTailCall(); GenTree* fgMorphTailCallViaHelpers(GenTreeCall* call, CORINFO_TAILCALL_HELPERS& help); bool fgCanTailCallViaJitHelper(); void fgMorphTailCallViaJitHelper(GenTreeCall* call); GenTree* fgCreateCallDispatcherAndGetResult(GenTreeCall* origCall, CORINFO_METHOD_HANDLE callTargetStubHnd, CORINFO_METHOD_HANDLE dispatcherHnd); GenTree* getLookupTree(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_LOOKUP* pLookup, GenTreeFlags handleFlags, void* compileTimeHandle); GenTree* getRuntimeLookupTree(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_LOOKUP* pLookup, void* compileTimeHandle); GenTree* getVirtMethodPointerTree(GenTree* thisPtr, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_CALL_INFO* pCallInfo); GenTree* getTokenHandleTree(CORINFO_RESOLVED_TOKEN* pResolvedToken, bool parent); GenTree* fgMorphPotentialTailCall(GenTreeCall* call); GenTree* fgGetStubAddrArg(GenTreeCall* call); unsigned fgGetArgTabEntryParameterLclNum(GenTreeCall* call, fgArgTabEntry* argTabEntry); void fgMorphRecursiveFastTailCallIntoLoop(BasicBlock* block, GenTreeCall* recursiveTailCall); Statement* fgAssignRecursiveCallArgToCallerParam(GenTree* arg, fgArgTabEntry* argTabEntry, unsigned lclParamNum, BasicBlock* block, const DebugInfo& callDI, Statement* tmpAssignmentInsertionPoint, Statement* paramAssignmentInsertionPoint); GenTree* fgMorphCall(GenTreeCall* call); GenTree* fgExpandVirtualVtableCallTarget(GenTreeCall* call); void fgMorphCallInline(GenTreeCall* call, InlineResult* result); void fgMorphCallInlineHelper(GenTreeCall* call, InlineResult* result, InlineContext** createdContext); #if DEBUG void fgNoteNonInlineCandidate(Statement* stmt, GenTreeCall* call); static fgWalkPreFn fgFindNonInlineCandidate; #endif GenTree* fgOptimizeDelegateConstructor(GenTreeCall* call, CORINFO_CONTEXT_HANDLE* ExactContextHnd, CORINFO_RESOLVED_TOKEN* ldftnToken); GenTree* fgMorphLeaf(GenTree* tree); void fgAssignSetVarDef(GenTree* tree); GenTree* fgMorphOneAsgBlockOp(GenTree* tree); GenTree* fgMorphInitBlock(GenTree* tree); GenTree* fgMorphPromoteLocalInitBlock(GenTreeLclVar* destLclNode, GenTree* initVal, unsigned blockSize); GenTree* fgMorphGetStructAddr(GenTree** pTree, CORINFO_CLASS_HANDLE clsHnd, bool isRValue = false); GenTree* fgMorphBlockOperand(GenTree* tree, var_types asgType, unsigned blockWidth, bool isBlkReqd); GenTree* fgMorphCopyBlock(GenTree* tree); GenTree* fgMorphStoreDynBlock(GenTreeStoreDynBlk* tree); GenTree* fgMorphForRegisterFP(GenTree* tree); GenTree* fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac = nullptr); GenTree* fgOptimizeCast(GenTreeCast* cast); GenTree* fgOptimizeEqualityComparisonWithConst(GenTreeOp* cmp); GenTree* fgOptimizeRelationalComparisonWithConst(GenTreeOp* cmp); #ifdef FEATURE_HW_INTRINSICS GenTree* fgOptimizeHWIntrinsic(GenTreeHWIntrinsic* node); #endif GenTree* fgOptimizeCommutativeArithmetic(GenTreeOp* tree); GenTree* fgOptimizeRelationalComparisonWithCasts(GenTreeOp* cmp); GenTree* fgOptimizeAddition(GenTreeOp* add); GenTree* fgOptimizeMultiply(GenTreeOp* mul); GenTree* fgOptimizeBitwiseAnd(GenTreeOp* andOp); GenTree* fgPropagateCommaThrow(GenTree* parent, GenTreeOp* commaThrow, GenTreeFlags precedingSideEffects); GenTree* fgMorphRetInd(GenTreeUnOp* tree); GenTree* fgMorphModToSubMulDiv(GenTreeOp* tree); GenTree* fgMorphSmpOpOptional(GenTreeOp* tree); GenTree* fgMorphMultiOp(GenTreeMultiOp* multiOp); GenTree* fgMorphConst(GenTree* tree); bool fgMorphCanUseLclFldForCopy(unsigned lclNum1, unsigned lclNum2); GenTreeLclVar* fgMorphTryFoldObjAsLclVar(GenTreeObj* obj, bool destroyNodes = true); GenTreeOp* fgMorphCommutative(GenTreeOp* tree); GenTree* fgMorphCastedBitwiseOp(GenTreeOp* tree); GenTree* fgMorphReduceAddOps(GenTree* tree); public: GenTree* fgMorphTree(GenTree* tree, MorphAddrContext* mac = nullptr); private: void fgKillDependentAssertionsSingle(unsigned lclNum DEBUGARG(GenTree* tree)); void fgKillDependentAssertions(unsigned lclNum DEBUGARG(GenTree* tree)); void fgMorphTreeDone(GenTree* tree, GenTree* oldTree = nullptr DEBUGARG(int morphNum = 0)); Statement* fgMorphStmt; unsigned fgGetBigOffsetMorphingTemp(var_types type); // We cache one temp per type to be // used when morphing big offset. //----------------------- Liveness analysis ------------------------------- VARSET_TP fgCurUseSet; // vars used by block (before an assignment) VARSET_TP fgCurDefSet; // vars assigned by block (before a use) MemoryKindSet fgCurMemoryUse; // True iff the current basic block uses memory. MemoryKindSet fgCurMemoryDef; // True iff the current basic block modifies memory. MemoryKindSet fgCurMemoryHavoc; // True if the current basic block is known to set memory to a "havoc" value. bool byrefStatesMatchGcHeapStates; // True iff GcHeap and ByrefExposed memory have all the same def points. void fgMarkUseDef(GenTreeLclVarCommon* tree); void fgBeginScopeLife(VARSET_TP* inScope, VarScopeDsc* var); void fgEndScopeLife(VARSET_TP* inScope, VarScopeDsc* var); void fgMarkInScope(BasicBlock* block, VARSET_VALARG_TP inScope); void fgUnmarkInScope(BasicBlock* block, VARSET_VALARG_TP unmarkScope); void fgExtendDbgScopes(); void fgExtendDbgLifetimes(); #ifdef DEBUG void fgDispDebugScopes(); #endif // DEBUG //------------------------------------------------------------------------- // // The following keeps track of any code we've added for things like array // range checking or explicit calls to enable GC, and so on. // public: struct AddCodeDsc { AddCodeDsc* acdNext; BasicBlock* acdDstBlk; // block to which we jump unsigned acdData; SpecialCodeKind acdKind; // what kind of a special block is this? #if !FEATURE_FIXED_OUT_ARGS bool acdStkLvlInit; // has acdStkLvl value been already set? unsigned acdStkLvl; // stack level in stack slots. #endif // !FEATURE_FIXED_OUT_ARGS }; private: static unsigned acdHelper(SpecialCodeKind codeKind); AddCodeDsc* fgAddCodeList; bool fgAddCodeModf; bool fgRngChkThrowAdded; AddCodeDsc* fgExcptnTargetCache[SCK_COUNT]; BasicBlock* fgRngChkTarget(BasicBlock* block, SpecialCodeKind kind); BasicBlock* fgAddCodeRef(BasicBlock* srcBlk, unsigned refData, SpecialCodeKind kind); public: AddCodeDsc* fgFindExcptnTarget(SpecialCodeKind kind, unsigned refData); bool fgUseThrowHelperBlocks(); AddCodeDsc* fgGetAdditionalCodeDescriptors() { return fgAddCodeList; } private: bool fgIsCodeAdded(); bool fgIsThrowHlpBlk(BasicBlock* block); #if !FEATURE_FIXED_OUT_ARGS unsigned fgThrowHlpBlkStkLevel(BasicBlock* block); #endif // !FEATURE_FIXED_OUT_ARGS unsigned fgBigOffsetMorphingTemps[TYP_COUNT]; unsigned fgCheckInlineDepthAndRecursion(InlineInfo* inlineInfo); void fgInvokeInlineeCompiler(GenTreeCall* call, InlineResult* result, InlineContext** createdContext); void fgInsertInlineeBlocks(InlineInfo* pInlineInfo); Statement* fgInlinePrependStatements(InlineInfo* inlineInfo); void fgInlineAppendStatements(InlineInfo* inlineInfo, BasicBlock* block, Statement* stmt); #if FEATURE_MULTIREG_RET GenTree* fgGetStructAsStructPtr(GenTree* tree); GenTree* fgAssignStructInlineeToVar(GenTree* child, CORINFO_CLASS_HANDLE retClsHnd); void fgAttachStructInlineeToAsg(GenTree* tree, GenTree* child, CORINFO_CLASS_HANDLE retClsHnd); #endif // FEATURE_MULTIREG_RET static fgWalkPreFn fgUpdateInlineReturnExpressionPlaceHolder; static fgWalkPostFn fgLateDevirtualization; #ifdef DEBUG static fgWalkPreFn fgDebugCheckInlineCandidates; void CheckNoTransformableIndirectCallsRemain(); static fgWalkPreFn fgDebugCheckForTransformableIndirectCalls; #endif void fgPromoteStructs(); void fgMorphStructField(GenTree* tree, GenTree* parent); void fgMorphLocalField(GenTree* tree, GenTree* parent); // Reset the refCount for implicit byrefs. void fgResetImplicitByRefRefCount(); // Change implicit byrefs' types from struct to pointer, and for any that were // promoted, create new promoted struct temps. void fgRetypeImplicitByRefArgs(); // Rewrite appearances of implicit byrefs (manifest the implied additional level of indirection). bool fgMorphImplicitByRefArgs(GenTree* tree); GenTree* fgMorphImplicitByRefArgs(GenTree* tree, bool isAddr); // Clear up annotations for any struct promotion temps created for implicit byrefs. void fgMarkDemotedImplicitByRefArgs(); void fgMarkAddressExposedLocals(); void fgMarkAddressExposedLocals(Statement* stmt); PhaseStatus fgForwardSub(); bool fgForwardSubBlock(BasicBlock* block); bool fgForwardSubStatement(Statement* statement); static fgWalkPreFn fgUpdateSideEffectsPre; static fgWalkPostFn fgUpdateSideEffectsPost; // The given local variable, required to be a struct variable, is being assigned via // a "lclField", to make it masquerade as an integral type in the ABI. Make sure that // the variable is not enregistered, and is therefore not promoted independently. void fgLclFldAssign(unsigned lclNum); static fgWalkPreFn gtHasLocalsWithAddrOpCB; enum TypeProducerKind { TPK_Unknown = 0, // May not be a RuntimeType TPK_Handle = 1, // RuntimeType via handle TPK_GetType = 2, // RuntimeType via Object.get_Type() TPK_Null = 3, // Tree value is null TPK_Other = 4 // RuntimeType via other means }; TypeProducerKind gtGetTypeProducerKind(GenTree* tree); bool gtIsTypeHandleToRuntimeTypeHelper(GenTreeCall* call); bool gtIsTypeHandleToRuntimeTypeHandleHelper(GenTreeCall* call, CorInfoHelpFunc* pHelper = nullptr); bool gtIsActiveCSE_Candidate(GenTree* tree); bool fgIsBigOffset(size_t offset); bool fgNeedReturnSpillTemp(); /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX Optimizer XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ public: void optInit(); GenTree* optRemoveRangeCheck(GenTreeBoundsChk* check, GenTree* comma, Statement* stmt); GenTree* optRemoveStandaloneRangeCheck(GenTreeBoundsChk* check, Statement* stmt); void optRemoveCommaBasedRangeCheck(GenTree* comma, Statement* stmt); protected: // Do hoisting for all loops. void optHoistLoopCode(); // To represent sets of VN's that have already been hoisted in outer loops. typedef JitHashTable<ValueNum, JitSmallPrimitiveKeyFuncs<ValueNum>, bool> VNSet; struct LoopHoistContext { private: // The set of variables hoisted in the current loop (or nullptr if there are none). VNSet* m_pHoistedInCurLoop; public: // Value numbers of expressions that have been hoisted in parent loops in the loop nest. VNSet m_hoistedInParentLoops; // Value numbers of expressions that have been hoisted in the current (or most recent) loop in the nest. // Previous decisions on loop-invariance of value numbers in the current loop. VNSet m_curLoopVnInvariantCache; VNSet* GetHoistedInCurLoop(Compiler* comp) { if (m_pHoistedInCurLoop == nullptr) { m_pHoistedInCurLoop = new (comp->getAllocatorLoopHoist()) VNSet(comp->getAllocatorLoopHoist()); } return m_pHoistedInCurLoop; } VNSet* ExtractHoistedInCurLoop() { VNSet* res = m_pHoistedInCurLoop; m_pHoistedInCurLoop = nullptr; return res; } LoopHoistContext(Compiler* comp) : m_pHoistedInCurLoop(nullptr) , m_hoistedInParentLoops(comp->getAllocatorLoopHoist()) , m_curLoopVnInvariantCache(comp->getAllocatorLoopHoist()) { } }; // Do hoisting for loop "lnum" (an index into the optLoopTable), and all loops nested within it. // Tracks the expressions that have been hoisted by containing loops by temporarily recording their // value numbers in "m_hoistedInParentLoops". This set is not modified by the call. void optHoistLoopNest(unsigned lnum, LoopHoistContext* hoistCtxt); // Do hoisting for a particular loop ("lnum" is an index into the optLoopTable.) // Assumes that expressions have been hoisted in containing loops if their value numbers are in // "m_hoistedInParentLoops". // void optHoistThisLoop(unsigned lnum, LoopHoistContext* hoistCtxt); // Hoist all expressions in "blocks" that are invariant in loop "loopNum" (an index into the optLoopTable) // outside of that loop. Exempt expressions whose value number is in "m_hoistedInParentLoops"; add VN's of hoisted // expressions to "hoistInLoop". void optHoistLoopBlocks(unsigned loopNum, ArrayStack<BasicBlock*>* blocks, LoopHoistContext* hoistContext); // Return true if the tree looks profitable to hoist out of loop 'lnum'. bool optIsProfitableToHoistTree(GenTree* tree, unsigned lnum); // Performs the hoisting 'tree' into the PreHeader for loop 'lnum' void optHoistCandidate(GenTree* tree, BasicBlock* treeBb, unsigned lnum, LoopHoistContext* hoistCtxt); // Returns true iff the ValueNum "vn" represents a value that is loop-invariant in "lnum". // Constants and init values are always loop invariant. // VNPhi's connect VN's to the SSA definition, so we can know if the SSA def occurs in the loop. bool optVNIsLoopInvariant(ValueNum vn, unsigned lnum, VNSet* recordedVNs); // If "blk" is the entry block of a natural loop, returns true and sets "*pLnum" to the index of the loop // in the loop table. bool optBlockIsLoopEntry(BasicBlock* blk, unsigned* pLnum); // Records the set of "side effects" of all loops: fields (object instance and static) // written to, and SZ-array element type equivalence classes updated. void optComputeLoopSideEffects(); #ifdef DEBUG bool optAnyChildNotRemoved(unsigned loopNum); #endif // DEBUG // Mark a loop as removed. void optMarkLoopRemoved(unsigned loopNum); private: // Requires "lnum" to be the index of an outermost loop in the loop table. Traverses the body of that loop, // including all nested loops, and records the set of "side effects" of the loop: fields (object instance and // static) written to, and SZ-array element type equivalence classes updated. void optComputeLoopNestSideEffects(unsigned lnum); // Given a loop number 'lnum' mark it and any nested loops as having 'memoryHavoc' void optRecordLoopNestsMemoryHavoc(unsigned lnum, MemoryKindSet memoryHavoc); // Add the side effects of "blk" (which is required to be within a loop) to all loops of which it is a part. // Returns false if we encounter a block that is not marked as being inside a loop. // bool optComputeLoopSideEffectsOfBlock(BasicBlock* blk); // Hoist the expression "expr" out of loop "lnum". void optPerformHoistExpr(GenTree* expr, BasicBlock* exprBb, unsigned lnum); public: void optOptimizeBools(); public: PhaseStatus optInvertLoops(); // Invert loops so they're entered at top and tested at bottom. PhaseStatus optOptimizeLayout(); // Optimize the BasicBlock layout of the method PhaseStatus optSetBlockWeights(); PhaseStatus optFindLoopsPhase(); // Finds loops and records them in the loop table void optFindLoops(); PhaseStatus optCloneLoops(); void optCloneLoop(unsigned loopInd, LoopCloneContext* context); void optEnsureUniqueHead(unsigned loopInd, weight_t ambientWeight); PhaseStatus optUnrollLoops(); // Unrolls loops (needs to have cost info) void optRemoveRedundantZeroInits(); protected: // This enumeration describes what is killed by a call. enum callInterf { CALLINT_NONE, // no interference (most helpers) CALLINT_REF_INDIRS, // kills GC ref indirections (SETFIELD OBJ) CALLINT_SCL_INDIRS, // kills non GC ref indirections (SETFIELD non-OBJ) CALLINT_ALL_INDIRS, // kills both GC ref and non GC ref indirections (SETFIELD STRUCT) CALLINT_ALL, // kills everything (normal method call) }; enum class FieldKindForVN { SimpleStatic, WithBaseAddr }; public: // A "LoopDsc" describes a ("natural") loop. We (currently) require the body of a loop to be a contiguous (in // bbNext order) sequence of basic blocks. (At times, we may require the blocks in a loop to be "properly numbered" // in bbNext order; we use comparisons on the bbNum to decide order.) // The blocks that define the body are // top <= entry <= bottom // The "head" of the loop is a block outside the loop that has "entry" as a successor. We only support loops with a // single 'head' block. The meanings of these blocks are given in the definitions below. Also see the picture at // Compiler::optFindNaturalLoops(). struct LoopDsc { BasicBlock* lpHead; // HEAD of the loop (not part of the looping of the loop) -- has ENTRY as a successor. BasicBlock* lpTop; // loop TOP (the back edge from lpBottom reaches here). Lexically first block (in bbNext // order) reachable in this loop. BasicBlock* lpEntry; // the ENTRY in the loop (in most cases TOP or BOTTOM) BasicBlock* lpBottom; // loop BOTTOM (from here we have a back edge to the TOP) BasicBlock* lpExit; // if a single exit loop this is the EXIT (in most cases BOTTOM) callInterf lpAsgCall; // "callInterf" for calls in the loop ALLVARSET_TP lpAsgVars; // set of vars assigned within the loop (all vars, not just tracked) varRefKinds lpAsgInds : 8; // set of inds modified within the loop LoopFlags lpFlags; unsigned char lpExitCnt; // number of exits from the loop unsigned char lpParent; // The index of the most-nested loop that completely contains this one, // or else BasicBlock::NOT_IN_LOOP if no such loop exists. unsigned char lpChild; // The index of a nested loop, or else BasicBlock::NOT_IN_LOOP if no child exists. // (Actually, an "immediately" nested loop -- // no other child of this loop is a parent of lpChild.) unsigned char lpSibling; // The index of another loop that is an immediate child of lpParent, // or else BasicBlock::NOT_IN_LOOP. One can enumerate all the children of a loop // by following "lpChild" then "lpSibling" links. bool lpLoopHasMemoryHavoc[MemoryKindCount]; // The loop contains an operation that we assume has arbitrary // memory side effects. If this is set, the fields below // may not be accurate (since they become irrelevant.) VARSET_TP lpVarInOut; // The set of variables that are IN or OUT during the execution of this loop VARSET_TP lpVarUseDef; // The set of variables that are USE or DEF during the execution of this loop // The following counts are used for hoisting profitability checks. int lpHoistedExprCount; // The register count for the non-FP expressions from inside this loop that have been // hoisted int lpLoopVarCount; // The register count for the non-FP LclVars that are read/written inside this loop int lpVarInOutCount; // The register count for the non-FP LclVars that are alive inside or across this loop int lpHoistedFPExprCount; // The register count for the FP expressions from inside this loop that have been // hoisted int lpLoopVarFPCount; // The register count for the FP LclVars that are read/written inside this loop int lpVarInOutFPCount; // The register count for the FP LclVars that are alive inside or across this loop typedef JitHashTable<CORINFO_FIELD_HANDLE, JitPtrKeyFuncs<struct CORINFO_FIELD_STRUCT_>, FieldKindForVN> FieldHandleSet; FieldHandleSet* lpFieldsModified; // This has entries for all static field and object instance fields modified // in the loop. typedef JitHashTable<CORINFO_CLASS_HANDLE, JitPtrKeyFuncs<struct CORINFO_CLASS_STRUCT_>, bool> ClassHandleSet; ClassHandleSet* lpArrayElemTypesModified; // Bits set indicate the set of sz array element types such that // arrays of that type are modified // in the loop. // Adds the variable liveness information for 'blk' to 'this' LoopDsc void AddVariableLiveness(Compiler* comp, BasicBlock* blk); inline void AddModifiedField(Compiler* comp, CORINFO_FIELD_HANDLE fldHnd, FieldKindForVN fieldKind); // This doesn't *always* take a class handle -- it can also take primitive types, encoded as class handles // (shifted left, with a low-order bit set to distinguish.) // Use the {Encode/Decode}ElemType methods to construct/destruct these. inline void AddModifiedElemType(Compiler* comp, CORINFO_CLASS_HANDLE structHnd); /* The following values are set only for iterator loops, i.e. has the flag LPFLG_ITER set */ GenTree* lpIterTree; // The "i = i <op> const" tree unsigned lpIterVar() const; // iterator variable # int lpIterConst() const; // the constant with which the iterator is incremented genTreeOps lpIterOper() const; // the type of the operation on the iterator (ASG_ADD, ASG_SUB, etc.) void VERIFY_lpIterTree() const; var_types lpIterOperType() const; // For overflow instructions // Set to the block where we found the initialization for LPFLG_CONST_INIT or LPFLG_VAR_INIT loops. // Initially, this will be 'head', but 'head' might change if we insert a loop pre-header block. BasicBlock* lpInitBlock; union { int lpConstInit; // initial constant value of iterator // : Valid if LPFLG_CONST_INIT unsigned lpVarInit; // initial local var number to which we initialize the iterator // : Valid if LPFLG_VAR_INIT }; // The following is for LPFLG_ITER loops only (i.e. the loop condition is "i RELOP const or var") GenTree* lpTestTree; // pointer to the node containing the loop test genTreeOps lpTestOper() const; // the type of the comparison between the iterator and the limit (GT_LE, GT_GE, // etc.) void VERIFY_lpTestTree() const; bool lpIsReversed() const; // true if the iterator node is the second operand in the loop condition GenTree* lpIterator() const; // the iterator node in the loop test GenTree* lpLimit() const; // the limit node in the loop test // Limit constant value of iterator - loop condition is "i RELOP const" // : Valid if LPFLG_CONST_LIMIT int lpConstLimit() const; // The lclVar # in the loop condition ( "i RELOP lclVar" ) // : Valid if LPFLG_VAR_LIMIT unsigned lpVarLimit() const; // The array length in the loop condition ( "i RELOP arr.len" or "i RELOP arr[i][j].len" ) // : Valid if LPFLG_ARRLEN_LIMIT bool lpArrLenLimit(Compiler* comp, ArrIndex* index) const; // Returns "true" iff this is a "top entry" loop. bool lpIsTopEntry() const { if (lpHead->bbNext == lpEntry) { assert(lpHead->bbFallsThrough()); assert(lpTop == lpEntry); return true; } else { return false; } } // Returns "true" iff "*this" contains the blk. bool lpContains(BasicBlock* blk) const { return lpTop->bbNum <= blk->bbNum && blk->bbNum <= lpBottom->bbNum; } // Returns "true" iff "*this" (properly) contains the range [top, bottom] (allowing tops // to be equal, but requiring bottoms to be different.) bool lpContains(BasicBlock* top, BasicBlock* bottom) const { return lpTop->bbNum <= top->bbNum && bottom->bbNum < lpBottom->bbNum; } // Returns "true" iff "*this" (properly) contains "lp2" (allowing tops to be equal, but requiring // bottoms to be different.) bool lpContains(const LoopDsc& lp2) const { return lpContains(lp2.lpTop, lp2.lpBottom); } // Returns "true" iff "*this" is (properly) contained by the range [top, bottom] // (allowing tops to be equal, but requiring bottoms to be different.) bool lpContainedBy(BasicBlock* top, BasicBlock* bottom) const { return top->bbNum <= lpTop->bbNum && lpBottom->bbNum < bottom->bbNum; } // Returns "true" iff "*this" is (properly) contained by "lp2" // (allowing tops to be equal, but requiring bottoms to be different.) bool lpContainedBy(const LoopDsc& lp2) const { return lpContainedBy(lp2.lpTop, lp2.lpBottom); } // Returns "true" iff "*this" is disjoint from the range [top, bottom]. bool lpDisjoint(BasicBlock* top, BasicBlock* bottom) const { return bottom->bbNum < lpTop->bbNum || lpBottom->bbNum < top->bbNum; } // Returns "true" iff "*this" is disjoint from "lp2". bool lpDisjoint(const LoopDsc& lp2) const { return lpDisjoint(lp2.lpTop, lp2.lpBottom); } // Returns "true" iff the loop is well-formed (see code for defn). bool lpWellFormed() const { return lpTop->bbNum <= lpEntry->bbNum && lpEntry->bbNum <= lpBottom->bbNum && (lpHead->bbNum < lpTop->bbNum || lpHead->bbNum > lpBottom->bbNum); } #ifdef DEBUG void lpValidatePreHeader() const { // If this is called, we expect there to be a pre-header. assert(lpFlags & LPFLG_HAS_PREHEAD); // The pre-header must unconditionally enter the loop. assert(lpHead->GetUniqueSucc() == lpEntry); // The loop block must be marked as a pre-header. assert(lpHead->bbFlags & BBF_LOOP_PREHEADER); // The loop entry must have a single non-loop predecessor, which is the pre-header. // We can't assume here that the bbNum are properly ordered, so we can't do a simple lpContained() // check. So, we defer this check, which will be done by `fgDebugCheckLoopTable()`. } #endif // DEBUG // LoopBlocks: convenience method for enabling range-based `for` iteration over all the // blocks in a loop, e.g.: // for (BasicBlock* const block : loop->LoopBlocks()) ... // Currently, the loop blocks are expected to be in linear, lexical, `bbNext` order // from `lpTop` through `lpBottom`, inclusive. All blocks in this range are considered // to be part of the loop. // BasicBlockRangeList LoopBlocks() const { return BasicBlockRangeList(lpTop, lpBottom); } }; protected: bool fgMightHaveLoop(); // returns true if there are any back edges bool fgHasLoops; // True if this method has any loops, set in fgComputeReachability public: LoopDsc* optLoopTable; // loop descriptor table unsigned char optLoopCount; // number of tracked loops unsigned char loopAlignCandidates; // number of loops identified for alignment // Every time we rebuild the loop table, we increase the global "loop epoch". Any loop indices or // loop table pointers from the previous epoch are invalid. // TODO: validate this in some way? unsigned optCurLoopEpoch; void NewLoopEpoch() { ++optCurLoopEpoch; JITDUMP("New loop epoch %d\n", optCurLoopEpoch); } #ifdef DEBUG unsigned char loopsAligned; // number of loops actually aligned #endif // DEBUG bool optRecordLoop(BasicBlock* head, BasicBlock* top, BasicBlock* entry, BasicBlock* bottom, BasicBlock* exit, unsigned char exitCnt); void optClearLoopIterInfo(); #ifdef DEBUG void optPrintLoopInfo(unsigned lnum, bool printVerbose = false); void optPrintLoopInfo(const LoopDsc* loop, bool printVerbose = false); void optPrintLoopTable(); #endif protected: unsigned optCallCount; // number of calls made in the method unsigned optIndirectCallCount; // number of virtual, interface and indirect calls made in the method unsigned optNativeCallCount; // number of Pinvoke/Native calls made in the method unsigned optLoopsCloned; // number of loops cloned in the current method. #ifdef DEBUG void optCheckPreds(); #endif void optResetLoopInfo(); void optFindAndScaleGeneralLoopBlocks(); // Determine if there are any potential loops, and set BBF_LOOP_HEAD on potential loop heads. void optMarkLoopHeads(); void optScaleLoopBlocks(BasicBlock* begBlk, BasicBlock* endBlk); void optUnmarkLoopBlocks(BasicBlock* begBlk, BasicBlock* endBlk); void optUpdateLoopsBeforeRemoveBlock(BasicBlock* block, bool skipUnmarkLoop = false); bool optIsLoopTestEvalIntoTemp(Statement* testStmt, Statement** newTestStmt); unsigned optIsLoopIncrTree(GenTree* incr); bool optCheckIterInLoopTest(unsigned loopInd, GenTree* test, BasicBlock* from, BasicBlock* to, unsigned iterVar); bool optComputeIterInfo(GenTree* incr, BasicBlock* from, BasicBlock* to, unsigned* pIterVar); bool optPopulateInitInfo(unsigned loopInd, BasicBlock* initBlock, GenTree* init, unsigned iterVar); bool optExtractInitTestIncr( BasicBlock* head, BasicBlock* bottom, BasicBlock* exit, GenTree** ppInit, GenTree** ppTest, GenTree** ppIncr); void optFindNaturalLoops(); void optIdentifyLoopsForAlignment(); // Ensures that all the loops in the loop nest rooted at "loopInd" (an index into the loop table) are 'canonical' -- // each loop has a unique "top." Returns "true" iff the flowgraph has been modified. bool optCanonicalizeLoopNest(unsigned char loopInd); // Ensures that the loop "loopInd" (an index into the loop table) is 'canonical' -- it has a unique "top," // unshared with any other loop. Returns "true" iff the flowgraph has been modified bool optCanonicalizeLoop(unsigned char loopInd); // Requires "l1" to be a valid loop table index, and not "BasicBlock::NOT_IN_LOOP". // Requires "l2" to be a valid loop table index, or else "BasicBlock::NOT_IN_LOOP". // Returns true iff "l2" is not NOT_IN_LOOP, and "l1" contains "l2". // A loop contains itself. bool optLoopContains(unsigned l1, unsigned l2) const; // Updates the loop table by changing loop "loopInd", whose head is required // to be "from", to be "to". Also performs this transformation for any // loop nested in "loopInd" that shares the same head as "loopInd". void optUpdateLoopHead(unsigned loopInd, BasicBlock* from, BasicBlock* to); void optRedirectBlock(BasicBlock* blk, BlockToBlockMap* redirectMap, const bool updatePreds = false); // Marks the containsCall information to "lnum" and any parent loops. void AddContainsCallAllContainingLoops(unsigned lnum); // Adds the variable liveness information from 'blk' to "lnum" and any parent loops. void AddVariableLivenessAllContainingLoops(unsigned lnum, BasicBlock* blk); // Adds "fldHnd" to the set of modified fields of "lnum" and any parent loops. void AddModifiedFieldAllContainingLoops(unsigned lnum, CORINFO_FIELD_HANDLE fldHnd, FieldKindForVN fieldKind); // Adds "elemType" to the set of modified array element types of "lnum" and any parent loops. void AddModifiedElemTypeAllContainingLoops(unsigned lnum, CORINFO_CLASS_HANDLE elemType); // Requires that "from" and "to" have the same "bbJumpKind" (perhaps because "to" is a clone // of "from".) Copies the jump destination from "from" to "to". void optCopyBlkDest(BasicBlock* from, BasicBlock* to); // Returns true if 'block' is an entry block for any loop in 'optLoopTable' bool optIsLoopEntry(BasicBlock* block) const; // The depth of the loop described by "lnum" (an index into the loop table.) (0 == top level) unsigned optLoopDepth(unsigned lnum) { assert(lnum < optLoopCount); unsigned depth = 0; while ((lnum = optLoopTable[lnum].lpParent) != BasicBlock::NOT_IN_LOOP) { ++depth; } return depth; } // Struct used in optInvertWhileLoop to count interesting constructs to boost the profitability score. struct OptInvertCountTreeInfoType { int sharedStaticHelperCount; int arrayLengthCount; }; static fgWalkResult optInvertCountTreeInfo(GenTree** pTree, fgWalkData* data); bool optInvertWhileLoop(BasicBlock* block); private: static bool optIterSmallOverflow(int iterAtExit, var_types incrType); static bool optIterSmallUnderflow(int iterAtExit, var_types decrType); bool optComputeLoopRep(int constInit, int constLimit, int iterInc, genTreeOps iterOper, var_types iterType, genTreeOps testOper, bool unsignedTest, bool dupCond, unsigned* iterCount); static fgWalkPreFn optIsVarAssgCB; protected: bool optIsVarAssigned(BasicBlock* beg, BasicBlock* end, GenTree* skip, unsigned var); bool optIsVarAssgLoop(unsigned lnum, unsigned var); int optIsSetAssgLoop(unsigned lnum, ALLVARSET_VALARG_TP vars, varRefKinds inds = VR_NONE); bool optNarrowTree(GenTree* tree, var_types srct, var_types dstt, ValueNumPair vnpNarrow, bool doit); protected: // The following is the upper limit on how many expressions we'll keep track // of for the CSE analysis. // static const unsigned MAX_CSE_CNT = EXPSET_SZ; static const int MIN_CSE_COST = 2; // BitVec trait information only used by the optCSE_canSwap() method, for the CSE_defMask and CSE_useMask. // This BitVec uses one bit per CSE candidate BitVecTraits* cseMaskTraits; // one bit per CSE candidate // BitVec trait information for computing CSE availability using the CSE_DataFlow algorithm. // Two bits are allocated per CSE candidate to compute CSE availability // plus an extra bit to handle the initial unvisited case. // (See CSE_DataFlow::EndMerge for an explanation of why this is necessary.) // // The two bits per CSE candidate have the following meanings: // 11 - The CSE is available, and is also available when considering calls as killing availability. // 10 - The CSE is available, but is not available when considering calls as killing availability. // 00 - The CSE is not available // 01 - An illegal combination // BitVecTraits* cseLivenessTraits; //----------------------------------------------------------------------------------------------------------------- // getCSEnum2bit: Return the normalized index to use in the EXPSET_TP for the CSE with the given CSE index. // Each GenTree has a `gtCSEnum` field. Zero is reserved to mean this node is not a CSE, positive values indicate // CSE uses, and negative values indicate CSE defs. The caller must pass a non-zero positive value, as from // GET_CSE_INDEX(). // static unsigned genCSEnum2bit(unsigned CSEnum) { assert((CSEnum > 0) && (CSEnum <= MAX_CSE_CNT)); return CSEnum - 1; } //----------------------------------------------------------------------------------------------------------------- // getCSEAvailBit: Return the bit used by CSE dataflow sets (bbCseGen, etc.) for the availability bit for a CSE. // static unsigned getCSEAvailBit(unsigned CSEnum) { return genCSEnum2bit(CSEnum) * 2; } //----------------------------------------------------------------------------------------------------------------- // getCSEAvailCrossCallBit: Return the bit used by CSE dataflow sets (bbCseGen, etc.) for the availability bit // for a CSE considering calls as killing availability bit (see description above). // static unsigned getCSEAvailCrossCallBit(unsigned CSEnum) { return getCSEAvailBit(CSEnum) + 1; } void optPrintCSEDataFlowSet(EXPSET_VALARG_TP cseDataFlowSet, bool includeBits = true); EXPSET_TP cseCallKillsMask; // Computed once - A mask that is used to kill available CSEs at callsites /* Generic list of nodes - used by the CSE logic */ struct treeLst { treeLst* tlNext; GenTree* tlTree; }; struct treeStmtLst { treeStmtLst* tslNext; GenTree* tslTree; // tree node Statement* tslStmt; // statement containing the tree BasicBlock* tslBlock; // block containing the statement }; // The following logic keeps track of expressions via a simple hash table. struct CSEdsc { CSEdsc* csdNextInBucket; // used by the hash table size_t csdHashKey; // the orginal hashkey ssize_t csdConstDefValue; // When we CSE similar constants, this is the value that we use as the def ValueNum csdConstDefVN; // When we CSE similar constants, this is the ValueNumber that we use for the LclVar // assignment unsigned csdIndex; // 1..optCSECandidateCount bool csdIsSharedConst; // true if this CSE is a shared const bool csdLiveAcrossCall; unsigned short csdDefCount; // definition count unsigned short csdUseCount; // use count (excluding the implicit uses at defs) weight_t csdDefWtCnt; // weighted def count weight_t csdUseWtCnt; // weighted use count (excluding the implicit uses at defs) GenTree* csdTree; // treenode containing the 1st occurrence Statement* csdStmt; // stmt containing the 1st occurrence BasicBlock* csdBlock; // block containing the 1st occurrence treeStmtLst* csdTreeList; // list of matching tree nodes: head treeStmtLst* csdTreeLast; // list of matching tree nodes: tail // ToDo: This can be removed when gtGetStructHandleIfPresent stops guessing // and GT_IND nodes always have valid struct handle. // CORINFO_CLASS_HANDLE csdStructHnd; // The class handle, currently needed to create a SIMD LclVar in PerformCSE bool csdStructHndMismatch; ValueNum defExcSetPromise; // The exception set that is now required for all defs of this CSE. // This will be set to NoVN if we decide to abandon this CSE ValueNum defExcSetCurrent; // The set of exceptions we currently can use for CSE uses. ValueNum defConservNormVN; // if all def occurrences share the same conservative normal value // number, this will reflect it; otherwise, NoVN. // not used for shared const CSE's }; static const size_t s_optCSEhashSizeInitial; static const size_t s_optCSEhashGrowthFactor; static const size_t s_optCSEhashBucketSize; size_t optCSEhashSize; // The current size of hashtable size_t optCSEhashCount; // Number of entries in hashtable size_t optCSEhashMaxCountBeforeResize; // Number of entries before resize CSEdsc** optCSEhash; CSEdsc** optCSEtab; typedef JitHashTable<GenTree*, JitPtrKeyFuncs<GenTree>, GenTree*> NodeToNodeMap; NodeToNodeMap* optCseCheckedBoundMap; // Maps bound nodes to ancestor compares that should be // re-numbered with the bound to improve range check elimination // Given a compare, look for a cse candidate checked bound feeding it and add a map entry if found. void optCseUpdateCheckedBoundMap(GenTree* compare); void optCSEstop(); CSEdsc* optCSEfindDsc(unsigned index); bool optUnmarkCSE(GenTree* tree); // user defined callback data for the tree walk function optCSE_MaskHelper() struct optCSE_MaskData { EXPSET_TP CSE_defMask; EXPSET_TP CSE_useMask; }; // Treewalk helper for optCSE_DefMask and optCSE_UseMask static fgWalkPreFn optCSE_MaskHelper; // This function walks all the node for an given tree // and return the mask of CSE definitions and uses for the tree // void optCSE_GetMaskData(GenTree* tree, optCSE_MaskData* pMaskData); // Given a binary tree node return true if it is safe to swap the order of evaluation for op1 and op2. bool optCSE_canSwap(GenTree* firstNode, GenTree* secondNode); struct optCSEcostCmpEx { bool operator()(const CSEdsc* op1, const CSEdsc* op2); }; struct optCSEcostCmpSz { bool operator()(const CSEdsc* op1, const CSEdsc* op2); }; void optCleanupCSEs(); #ifdef DEBUG void optEnsureClearCSEInfo(); #endif // DEBUG static bool Is_Shared_Const_CSE(size_t key) { return ((key & TARGET_SIGN_BIT) != 0); } // returns the encoded key static size_t Encode_Shared_Const_CSE_Value(size_t key) { return TARGET_SIGN_BIT | (key >> CSE_CONST_SHARED_LOW_BITS); } // returns the orginal key static size_t Decode_Shared_Const_CSE_Value(size_t enckey) { assert(Is_Shared_Const_CSE(enckey)); return (enckey & ~TARGET_SIGN_BIT) << CSE_CONST_SHARED_LOW_BITS; } /************************************************************************** * Value Number based CSEs *************************************************************************/ // String to use for formatting CSE numbers. Note that this is the positive number, e.g., from GET_CSE_INDEX(). #define FMT_CSE "CSE #%02u" public: void optOptimizeValnumCSEs(); protected: void optValnumCSE_Init(); unsigned optValnumCSE_Index(GenTree* tree, Statement* stmt); bool optValnumCSE_Locate(); void optValnumCSE_InitDataFlow(); void optValnumCSE_DataFlow(); void optValnumCSE_Availablity(); void optValnumCSE_Heuristic(); bool optDoCSE; // True when we have found a duplicate CSE tree bool optValnumCSE_phase; // True when we are executing the optOptimizeValnumCSEs() phase unsigned optCSECandidateCount; // Count of CSE's candidates unsigned optCSEstart; // The first local variable number that is a CSE unsigned optCSEcount; // The total count of CSE's introduced. weight_t optCSEweight; // The weight of the current block when we are doing PerformCSE bool optIsCSEcandidate(GenTree* tree); // lclNumIsTrueCSE returns true if the LclVar was introduced by the CSE phase of the compiler // bool lclNumIsTrueCSE(unsigned lclNum) const { return ((optCSEcount > 0) && (lclNum >= optCSEstart) && (lclNum < optCSEstart + optCSEcount)); } // lclNumIsCSE returns true if the LclVar should be treated like a CSE with regards to constant prop. // bool lclNumIsCSE(unsigned lclNum) const { return lvaGetDesc(lclNum)->lvIsCSE; } #ifdef DEBUG bool optConfigDisableCSE(); bool optConfigDisableCSE2(); #endif void optOptimizeCSEs(); struct isVarAssgDsc { GenTree* ivaSkip; ALLVARSET_TP ivaMaskVal; // Set of variables assigned to. This is a set of all vars, not tracked vars. #ifdef DEBUG void* ivaSelf; #endif unsigned ivaVar; // Variable we are interested in, or -1 varRefKinds ivaMaskInd; // What kind of indirect assignments are there? callInterf ivaMaskCall; // What kind of calls are there? bool ivaMaskIncomplete; // Variables not representable in ivaMaskVal were assigned to. }; static callInterf optCallInterf(GenTreeCall* call); public: // VN based copy propagation. // In DEBUG builds, we'd like to know the tree that the SSA definition was pushed for. // While for ordinary SSA defs it will be available (as an ASG) in the SSA descriptor, // for locals which will use "definitions from uses", it will not be, so we store it // in this class instead. class CopyPropSsaDef { LclSsaVarDsc* m_ssaDef; #ifdef DEBUG GenTree* m_defNode; #endif public: CopyPropSsaDef(LclSsaVarDsc* ssaDef, GenTree* defNode) : m_ssaDef(ssaDef) #ifdef DEBUG , m_defNode(defNode) #endif { } LclSsaVarDsc* GetSsaDef() const { return m_ssaDef; } #ifdef DEBUG GenTree* GetDefNode() const { return m_defNode; } #endif }; typedef ArrayStack<CopyPropSsaDef> CopyPropSsaDefStack; typedef JitHashTable<unsigned, JitSmallPrimitiveKeyFuncs<unsigned>, CopyPropSsaDefStack*> LclNumToLiveDefsMap; // Copy propagation functions. void optCopyProp(Statement* stmt, GenTreeLclVarCommon* tree, unsigned lclNum, LclNumToLiveDefsMap* curSsaName); void optBlockCopyPropPopStacks(BasicBlock* block, LclNumToLiveDefsMap* curSsaName); void optBlockCopyProp(BasicBlock* block, LclNumToLiveDefsMap* curSsaName); void optCopyPropPushDef(GenTreeOp* asg, GenTreeLclVarCommon* lclNode, unsigned lclNum, LclNumToLiveDefsMap* curSsaName); unsigned optIsSsaLocal(GenTreeLclVarCommon* lclNode); int optCopyProp_LclVarScore(const LclVarDsc* lclVarDsc, const LclVarDsc* copyVarDsc, bool preferOp2); void optVnCopyProp(); INDEBUG(void optDumpCopyPropStack(LclNumToLiveDefsMap* curSsaName)); /************************************************************************** * Early value propagation *************************************************************************/ struct SSAName { unsigned m_lvNum; unsigned m_ssaNum; SSAName(unsigned lvNum, unsigned ssaNum) : m_lvNum(lvNum), m_ssaNum(ssaNum) { } static unsigned GetHashCode(SSAName ssaNm) { return (ssaNm.m_lvNum << 16) | (ssaNm.m_ssaNum); } static bool Equals(SSAName ssaNm1, SSAName ssaNm2) { return (ssaNm1.m_lvNum == ssaNm2.m_lvNum) && (ssaNm1.m_ssaNum == ssaNm2.m_ssaNum); } }; #define OMF_HAS_NEWARRAY 0x00000001 // Method contains 'new' of an array #define OMF_HAS_NEWOBJ 0x00000002 // Method contains 'new' of an object type. #define OMF_HAS_ARRAYREF 0x00000004 // Method contains array element loads or stores. #define OMF_HAS_NULLCHECK 0x00000008 // Method contains null check. #define OMF_HAS_FATPOINTER 0x00000010 // Method contains call, that needs fat pointer transformation. #define OMF_HAS_OBJSTACKALLOC 0x00000020 // Method contains an object allocated on the stack. #define OMF_HAS_GUARDEDDEVIRT 0x00000040 // Method contains guarded devirtualization candidate #define OMF_HAS_EXPRUNTIMELOOKUP 0x00000080 // Method contains a runtime lookup to an expandable dictionary. #define OMF_HAS_PATCHPOINT 0x00000100 // Method contains patchpoints #define OMF_NEEDS_GCPOLLS 0x00000200 // Method needs GC polls #define OMF_HAS_FROZEN_STRING 0x00000400 // Method has a frozen string (REF constant int), currently only on CoreRT. #define OMF_HAS_PARTIAL_COMPILATION_PATCHPOINT 0x00000800 // Method contains partial compilation patchpoints #define OMF_HAS_TAILCALL_SUCCESSOR 0x00001000 // Method has potential tail call in a non BBJ_RETURN block bool doesMethodHaveFatPointer() { return (optMethodFlags & OMF_HAS_FATPOINTER) != 0; } void setMethodHasFatPointer() { optMethodFlags |= OMF_HAS_FATPOINTER; } void clearMethodHasFatPointer() { optMethodFlags &= ~OMF_HAS_FATPOINTER; } void addFatPointerCandidate(GenTreeCall* call); bool doesMethodHaveFrozenString() const { return (optMethodFlags & OMF_HAS_FROZEN_STRING) != 0; } void setMethodHasFrozenString() { optMethodFlags |= OMF_HAS_FROZEN_STRING; } bool doesMethodHaveGuardedDevirtualization() const { return (optMethodFlags & OMF_HAS_GUARDEDDEVIRT) != 0; } void setMethodHasGuardedDevirtualization() { optMethodFlags |= OMF_HAS_GUARDEDDEVIRT; } void clearMethodHasGuardedDevirtualization() { optMethodFlags &= ~OMF_HAS_GUARDEDDEVIRT; } void considerGuardedDevirtualization(GenTreeCall* call, IL_OFFSET ilOffset, bool isInterface, CORINFO_METHOD_HANDLE baseMethod, CORINFO_CLASS_HANDLE baseClass, CORINFO_CONTEXT_HANDLE* pContextHandle DEBUGARG(CORINFO_CLASS_HANDLE objClass) DEBUGARG(const char* objClassName)); void addGuardedDevirtualizationCandidate(GenTreeCall* call, CORINFO_METHOD_HANDLE methodHandle, CORINFO_CLASS_HANDLE classHandle, unsigned methodAttr, unsigned classAttr, unsigned likelihood); bool doesMethodHaveExpRuntimeLookup() { return (optMethodFlags & OMF_HAS_EXPRUNTIMELOOKUP) != 0; } void setMethodHasExpRuntimeLookup() { optMethodFlags |= OMF_HAS_EXPRUNTIMELOOKUP; } void clearMethodHasExpRuntimeLookup() { optMethodFlags &= ~OMF_HAS_EXPRUNTIMELOOKUP; } void addExpRuntimeLookupCandidate(GenTreeCall* call); bool doesMethodHavePatchpoints() { return (optMethodFlags & OMF_HAS_PATCHPOINT) != 0; } void setMethodHasPatchpoint() { optMethodFlags |= OMF_HAS_PATCHPOINT; } bool doesMethodHavePartialCompilationPatchpoints() { return (optMethodFlags & OMF_HAS_PARTIAL_COMPILATION_PATCHPOINT) != 0; } void setMethodHasPartialCompilationPatchpoint() { optMethodFlags |= OMF_HAS_PARTIAL_COMPILATION_PATCHPOINT; } unsigned optMethodFlags; bool doesMethodHaveNoReturnCalls() { return optNoReturnCallCount > 0; } void setMethodHasNoReturnCalls() { optNoReturnCallCount++; } unsigned optNoReturnCallCount; // Recursion bound controls how far we can go backwards tracking for a SSA value. // No throughput diff was found with backward walk bound between 3-8. static const int optEarlyPropRecurBound = 5; enum class optPropKind { OPK_INVALID, OPK_ARRAYLEN, OPK_NULLCHECK }; typedef JitHashTable<unsigned, JitSmallPrimitiveKeyFuncs<unsigned>, GenTree*> LocalNumberToNullCheckTreeMap; GenTree* getArrayLengthFromAllocation(GenTree* tree DEBUGARG(BasicBlock* block)); GenTree* optPropGetValueRec(unsigned lclNum, unsigned ssaNum, optPropKind valueKind, int walkDepth); GenTree* optPropGetValue(unsigned lclNum, unsigned ssaNum, optPropKind valueKind); GenTree* optEarlyPropRewriteTree(GenTree* tree, LocalNumberToNullCheckTreeMap* nullCheckMap); bool optDoEarlyPropForBlock(BasicBlock* block); bool optDoEarlyPropForFunc(); void optEarlyProp(); void optFoldNullCheck(GenTree* tree, LocalNumberToNullCheckTreeMap* nullCheckMap); GenTree* optFindNullCheckToFold(GenTree* tree, LocalNumberToNullCheckTreeMap* nullCheckMap); bool optIsNullCheckFoldingLegal(GenTree* tree, GenTree* nullCheckTree, GenTree** nullCheckParent, Statement** nullCheckStmt); bool optCanMoveNullCheckPastTree(GenTree* tree, unsigned nullCheckLclNum, bool isInsideTry, bool checkSideEffectSummary); #if DEBUG void optCheckFlagsAreSet(unsigned methodFlag, const char* methodFlagStr, unsigned bbFlag, const char* bbFlagStr, GenTree* tree, BasicBlock* basicBlock); #endif // Redundant branch opts // PhaseStatus optRedundantBranches(); bool optRedundantRelop(BasicBlock* const block); bool optRedundantBranch(BasicBlock* const block); bool optJumpThread(BasicBlock* const block, BasicBlock* const domBlock, bool domIsSameRelop); bool optReachable(BasicBlock* const fromBlock, BasicBlock* const toBlock, BasicBlock* const excludedBlock); /************************************************************************** * Value/Assertion propagation *************************************************************************/ public: // Data structures for assertion prop BitVecTraits* apTraits; ASSERT_TP apFull; enum optAssertionKind { OAK_INVALID, OAK_EQUAL, OAK_NOT_EQUAL, OAK_SUBRANGE, OAK_NO_THROW, OAK_COUNT }; enum optOp1Kind { O1K_INVALID, O1K_LCLVAR, O1K_ARR_BND, O1K_BOUND_OPER_BND, O1K_BOUND_LOOP_BND, O1K_CONSTANT_LOOP_BND, O1K_CONSTANT_LOOP_BND_UN, O1K_EXACT_TYPE, O1K_SUBTYPE, O1K_VALUE_NUMBER, O1K_COUNT }; enum optOp2Kind { O2K_INVALID, O2K_LCLVAR_COPY, O2K_IND_CNS_INT, O2K_CONST_INT, O2K_CONST_LONG, O2K_CONST_DOUBLE, O2K_ZEROOBJ, O2K_SUBRANGE, O2K_COUNT }; struct AssertionDsc { optAssertionKind assertionKind; struct SsaVar { unsigned lclNum; // assigned to or property of this local var number unsigned ssaNum; }; struct ArrBnd { ValueNum vnIdx; ValueNum vnLen; }; struct AssertionDscOp1 { optOp1Kind kind; // a normal LclVar, or Exact-type or Subtype ValueNum vn; union { SsaVar lcl; ArrBnd bnd; }; } op1; struct AssertionDscOp2 { optOp2Kind kind; // a const or copy assignment ValueNum vn; struct IntVal { ssize_t iconVal; // integer #if !defined(HOST_64BIT) unsigned padding; // unused; ensures iconFlags does not overlap lconVal #endif GenTreeFlags iconFlags; // gtFlags }; union { struct { SsaVar lcl; FieldSeqNode* zeroOffsetFieldSeq; }; IntVal u1; __int64 lconVal; double dconVal; IntegralRange u2; }; } op2; bool IsCheckedBoundArithBound() { return ((assertionKind == OAK_EQUAL || assertionKind == OAK_NOT_EQUAL) && op1.kind == O1K_BOUND_OPER_BND); } bool IsCheckedBoundBound() { return ((assertionKind == OAK_EQUAL || assertionKind == OAK_NOT_EQUAL) && op1.kind == O1K_BOUND_LOOP_BND); } bool IsConstantBound() { return ((assertionKind == OAK_EQUAL || assertionKind == OAK_NOT_EQUAL) && (op1.kind == O1K_CONSTANT_LOOP_BND)); } bool IsConstantBoundUnsigned() { return ((assertionKind == OAK_EQUAL || assertionKind == OAK_NOT_EQUAL) && (op1.kind == O1K_CONSTANT_LOOP_BND_UN)); } bool IsBoundsCheckNoThrow() { return ((assertionKind == OAK_NO_THROW) && (op1.kind == O1K_ARR_BND)); } bool IsCopyAssertion() { return ((assertionKind == OAK_EQUAL) && (op1.kind == O1K_LCLVAR) && (op2.kind == O2K_LCLVAR_COPY)); } bool IsConstantInt32Assertion() { return ((assertionKind == OAK_EQUAL) || (assertionKind == OAK_NOT_EQUAL)) && (op2.kind == O2K_CONST_INT); } static bool SameKind(AssertionDsc* a1, AssertionDsc* a2) { return a1->assertionKind == a2->assertionKind && a1->op1.kind == a2->op1.kind && a1->op2.kind == a2->op2.kind; } static bool ComplementaryKind(optAssertionKind kind, optAssertionKind kind2) { if (kind == OAK_EQUAL) { return kind2 == OAK_NOT_EQUAL; } else if (kind == OAK_NOT_EQUAL) { return kind2 == OAK_EQUAL; } return false; } bool HasSameOp1(AssertionDsc* that, bool vnBased) { if (op1.kind != that->op1.kind) { return false; } else if (op1.kind == O1K_ARR_BND) { assert(vnBased); return (op1.bnd.vnIdx == that->op1.bnd.vnIdx) && (op1.bnd.vnLen == that->op1.bnd.vnLen); } else { return ((vnBased && (op1.vn == that->op1.vn)) || (!vnBased && (op1.lcl.lclNum == that->op1.lcl.lclNum))); } } bool HasSameOp2(AssertionDsc* that, bool vnBased) { if (op2.kind != that->op2.kind) { return false; } switch (op2.kind) { case O2K_IND_CNS_INT: case O2K_CONST_INT: return ((op2.u1.iconVal == that->op2.u1.iconVal) && (op2.u1.iconFlags == that->op2.u1.iconFlags)); case O2K_CONST_LONG: return (op2.lconVal == that->op2.lconVal); case O2K_CONST_DOUBLE: // exact match because of positive and negative zero. return (memcmp(&op2.dconVal, &that->op2.dconVal, sizeof(double)) == 0); case O2K_ZEROOBJ: return true; case O2K_LCLVAR_COPY: return (op2.lcl.lclNum == that->op2.lcl.lclNum) && (!vnBased || op2.lcl.ssaNum == that->op2.lcl.ssaNum) && (op2.zeroOffsetFieldSeq == that->op2.zeroOffsetFieldSeq); case O2K_SUBRANGE: return op2.u2.Equals(that->op2.u2); case O2K_INVALID: // we will return false break; default: assert(!"Unexpected value for op2.kind in AssertionDsc."); break; } return false; } bool Complementary(AssertionDsc* that, bool vnBased) { return ComplementaryKind(assertionKind, that->assertionKind) && HasSameOp1(that, vnBased) && HasSameOp2(that, vnBased); } bool Equals(AssertionDsc* that, bool vnBased) { if (assertionKind != that->assertionKind) { return false; } else if (assertionKind == OAK_NO_THROW) { assert(op2.kind == O2K_INVALID); return HasSameOp1(that, vnBased); } else { return HasSameOp1(that, vnBased) && HasSameOp2(that, vnBased); } } }; protected: static fgWalkPreFn optAddCopiesCallback; static fgWalkPreFn optVNAssertionPropCurStmtVisitor; unsigned optAddCopyLclNum; GenTree* optAddCopyAsgnNode; bool optLocalAssertionProp; // indicates that we are performing local assertion prop bool optAssertionPropagated; // set to true if we modified the trees bool optAssertionPropagatedCurrentStmt; #ifdef DEBUG GenTree* optAssertionPropCurrentTree; #endif AssertionIndex* optComplementaryAssertionMap; JitExpandArray<ASSERT_TP>* optAssertionDep; // table that holds dependent assertions (assertions // using the value of a local var) for each local var AssertionDsc* optAssertionTabPrivate; // table that holds info about value assignments AssertionIndex optAssertionCount; // total number of assertions in the assertion table AssertionIndex optMaxAssertionCount; public: void optVnNonNullPropCurStmt(BasicBlock* block, Statement* stmt, GenTree* tree); fgWalkResult optVNConstantPropCurStmt(BasicBlock* block, Statement* stmt, GenTree* tree); GenTree* optVNConstantPropOnJTrue(BasicBlock* block, GenTree* test); GenTree* optVNConstantPropOnTree(BasicBlock* block, GenTree* tree); GenTree* optExtractSideEffListFromConst(GenTree* tree); AssertionIndex GetAssertionCount() { return optAssertionCount; } ASSERT_TP* bbJtrueAssertionOut; typedef JitHashTable<ValueNum, JitSmallPrimitiveKeyFuncs<ValueNum>, ASSERT_TP> ValueNumToAssertsMap; ValueNumToAssertsMap* optValueNumToAsserts; // Assertion prop helpers. ASSERT_TP& GetAssertionDep(unsigned lclNum); AssertionDsc* optGetAssertion(AssertionIndex assertIndex); void optAssertionInit(bool isLocalProp); void optAssertionTraitsInit(AssertionIndex assertionCount); void optAssertionReset(AssertionIndex limit); void optAssertionRemove(AssertionIndex index); // Assertion prop data flow functions. void optAssertionPropMain(); Statement* optVNAssertionPropCurStmt(BasicBlock* block, Statement* stmt); bool optIsTreeKnownIntValue(bool vnBased, GenTree* tree, ssize_t* pConstant, GenTreeFlags* pIconFlags); ASSERT_TP* optInitAssertionDataflowFlags(); ASSERT_TP* optComputeAssertionGen(); // Assertion Gen functions. void optAssertionGen(GenTree* tree); AssertionIndex optAssertionGenCast(GenTreeCast* cast); AssertionIndex optAssertionGenPhiDefn(GenTree* tree); AssertionInfo optCreateJTrueBoundsAssertion(GenTree* tree); AssertionInfo optAssertionGenJtrue(GenTree* tree); AssertionIndex optCreateJtrueAssertions(GenTree* op1, GenTree* op2, Compiler::optAssertionKind assertionKind, bool helperCallArgs = false); AssertionIndex optFindComplementary(AssertionIndex assertionIndex); void optMapComplementary(AssertionIndex assertionIndex, AssertionIndex index); // Assertion creation functions. AssertionIndex optCreateAssertion(GenTree* op1, GenTree* op2, optAssertionKind assertionKind, bool helperCallArgs = false); AssertionIndex optFinalizeCreatingAssertion(AssertionDsc* assertion); bool optTryExtractSubrangeAssertion(GenTree* source, IntegralRange* pRange); void optCreateComplementaryAssertion(AssertionIndex assertionIndex, GenTree* op1, GenTree* op2, bool helperCallArgs = false); bool optAssertionVnInvolvesNan(AssertionDsc* assertion); AssertionIndex optAddAssertion(AssertionDsc* assertion); void optAddVnAssertionMapping(ValueNum vn, AssertionIndex index); #ifdef DEBUG void optPrintVnAssertionMapping(); #endif ASSERT_TP optGetVnMappedAssertions(ValueNum vn); // Used for respective assertion propagations. AssertionIndex optAssertionIsSubrange(GenTree* tree, IntegralRange range, ASSERT_VALARG_TP assertions); AssertionIndex optAssertionIsSubtype(GenTree* tree, GenTree* methodTableArg, ASSERT_VALARG_TP assertions); AssertionIndex optAssertionIsNonNullInternal(GenTree* op, ASSERT_VALARG_TP assertions DEBUGARG(bool* pVnBased)); bool optAssertionIsNonNull(GenTree* op, ASSERT_VALARG_TP assertions DEBUGARG(bool* pVnBased) DEBUGARG(AssertionIndex* pIndex)); AssertionIndex optGlobalAssertionIsEqualOrNotEqual(ASSERT_VALARG_TP assertions, GenTree* op1, GenTree* op2); AssertionIndex optGlobalAssertionIsEqualOrNotEqualZero(ASSERT_VALARG_TP assertions, GenTree* op1); AssertionIndex optLocalAssertionIsEqualOrNotEqual( optOp1Kind op1Kind, unsigned lclNum, optOp2Kind op2Kind, ssize_t cnsVal, ASSERT_VALARG_TP assertions); // Assertion prop for lcl var functions. bool optAssertionProp_LclVarTypeCheck(GenTree* tree, LclVarDsc* lclVarDsc, LclVarDsc* copyVarDsc); GenTree* optCopyAssertionProp(AssertionDsc* curAssertion, GenTreeLclVarCommon* tree, Statement* stmt DEBUGARG(AssertionIndex index)); GenTree* optConstantAssertionProp(AssertionDsc* curAssertion, GenTreeLclVarCommon* tree, Statement* stmt DEBUGARG(AssertionIndex index)); bool optZeroObjAssertionProp(GenTree* tree, ASSERT_VALARG_TP assertions); // Assertion propagation functions. GenTree* optAssertionProp(ASSERT_VALARG_TP assertions, GenTree* tree, Statement* stmt, BasicBlock* block); GenTree* optAssertionProp_LclVar(ASSERT_VALARG_TP assertions, GenTreeLclVarCommon* tree, Statement* stmt); GenTree* optAssertionProp_Asg(ASSERT_VALARG_TP assertions, GenTreeOp* asg, Statement* stmt); GenTree* optAssertionProp_Return(ASSERT_VALARG_TP assertions, GenTreeUnOp* ret, Statement* stmt); GenTree* optAssertionProp_Ind(ASSERT_VALARG_TP assertions, GenTree* tree, Statement* stmt); GenTree* optAssertionProp_Cast(ASSERT_VALARG_TP assertions, GenTreeCast* cast, Statement* stmt); GenTree* optAssertionProp_Call(ASSERT_VALARG_TP assertions, GenTreeCall* call, Statement* stmt); GenTree* optAssertionProp_RelOp(ASSERT_VALARG_TP assertions, GenTree* tree, Statement* stmt); GenTree* optAssertionProp_Comma(ASSERT_VALARG_TP assertions, GenTree* tree, Statement* stmt); GenTree* optAssertionProp_BndsChk(ASSERT_VALARG_TP assertions, GenTree* tree, Statement* stmt); GenTree* optAssertionPropGlobal_RelOp(ASSERT_VALARG_TP assertions, GenTree* tree, Statement* stmt); GenTree* optAssertionPropLocal_RelOp(ASSERT_VALARG_TP assertions, GenTree* tree, Statement* stmt); GenTree* optAssertionProp_Update(GenTree* newTree, GenTree* tree, Statement* stmt); GenTree* optNonNullAssertionProp_Call(ASSERT_VALARG_TP assertions, GenTreeCall* call); // Implied assertion functions. void optImpliedAssertions(AssertionIndex assertionIndex, ASSERT_TP& activeAssertions); void optImpliedByTypeOfAssertions(ASSERT_TP& activeAssertions); void optImpliedByCopyAssertion(AssertionDsc* copyAssertion, AssertionDsc* depAssertion, ASSERT_TP& result); void optImpliedByConstAssertion(AssertionDsc* curAssertion, ASSERT_TP& result); #ifdef DEBUG void optPrintAssertion(AssertionDsc* newAssertion, AssertionIndex assertionIndex = 0); void optPrintAssertionIndex(AssertionIndex index); void optPrintAssertionIndices(ASSERT_TP assertions); void optDebugCheckAssertion(AssertionDsc* assertion); void optDebugCheckAssertions(AssertionIndex AssertionIndex); #endif static void optDumpAssertionIndices(const char* header, ASSERT_TP assertions, const char* footer = nullptr); static void optDumpAssertionIndices(ASSERT_TP assertions, const char* footer = nullptr); void optAddCopies(); /************************************************************************** * Range checks *************************************************************************/ public: struct LoopCloneVisitorInfo { LoopCloneContext* context; unsigned loopNum; Statement* stmt; LoopCloneVisitorInfo(LoopCloneContext* context, unsigned loopNum, Statement* stmt) : context(context), loopNum(loopNum), stmt(nullptr) { } }; bool optIsStackLocalInvariant(unsigned loopNum, unsigned lclNum); bool optExtractArrIndex(GenTree* tree, ArrIndex* result, unsigned lhsNum); bool optReconstructArrIndex(GenTree* tree, ArrIndex* result, unsigned lhsNum); bool optIdentifyLoopOptInfo(unsigned loopNum, LoopCloneContext* context); static fgWalkPreFn optCanOptimizeByLoopCloningVisitor; fgWalkResult optCanOptimizeByLoopCloning(GenTree* tree, LoopCloneVisitorInfo* info); bool optObtainLoopCloningOpts(LoopCloneContext* context); bool optIsLoopClonable(unsigned loopInd); bool optLoopCloningEnabled(); #ifdef DEBUG void optDebugLogLoopCloning(BasicBlock* block, Statement* insertBefore); #endif void optPerformStaticOptimizations(unsigned loopNum, LoopCloneContext* context DEBUGARG(bool fastPath)); bool optComputeDerefConditions(unsigned loopNum, LoopCloneContext* context); bool optDeriveLoopCloningConditions(unsigned loopNum, LoopCloneContext* context); BasicBlock* optInsertLoopChoiceConditions(LoopCloneContext* context, unsigned loopNum, BasicBlock* slowHead, BasicBlock* insertAfter); protected: ssize_t optGetArrayRefScaleAndIndex(GenTree* mul, GenTree** pIndex DEBUGARG(bool bRngChk)); bool optReachWithoutCall(BasicBlock* srcBB, BasicBlock* dstBB); protected: bool optLoopsMarked; /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX RegAlloc XX XX XX XX Does the register allocation and puts the remaining lclVars on the stack XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ public: regNumber raUpdateRegStateForArg(RegState* regState, LclVarDsc* argDsc); void raMarkStkVars(); #if FEATURE_PARTIAL_SIMD_CALLEE_SAVE #if defined(TARGET_AMD64) static bool varTypeNeedsPartialCalleeSave(var_types type) { assert(type != TYP_STRUCT); return (type == TYP_SIMD32); } #elif defined(TARGET_ARM64) static bool varTypeNeedsPartialCalleeSave(var_types type) { assert(type != TYP_STRUCT); // ARM64 ABI FP Callee save registers only require Callee to save lower 8 Bytes // For SIMD types longer than 8 bytes Caller is responsible for saving and restoring Upper bytes. return ((type == TYP_SIMD16) || (type == TYP_SIMD12)); } #else // !defined(TARGET_AMD64) && !defined(TARGET_ARM64) #error("Unknown target architecture for FEATURE_SIMD") #endif // !defined(TARGET_AMD64) && !defined(TARGET_ARM64) #endif // FEATURE_PARTIAL_SIMD_CALLEE_SAVE protected: // Some things are used by both LSRA and regpredict allocators. FrameType rpFrameType; bool rpMustCreateEBPCalled; // Set to true after we have called rpMustCreateEBPFrame once bool rpMustCreateEBPFrame(INDEBUG(const char** wbReason)); private: Lowering* m_pLowering; // Lowering; needed to Lower IR that's added or modified after Lowering. LinearScanInterface* m_pLinearScan; // Linear Scan allocator /* raIsVarargsStackArg is called by raMaskStkVars and by lvaComputeRefCounts. It identifies the special case where a varargs function has a parameter passed on the stack, other than the special varargs handle. Such parameters require special treatment, because they cannot be tracked by the GC (their offsets in the stack are not known at compile time). */ bool raIsVarargsStackArg(unsigned lclNum) { #ifdef TARGET_X86 LclVarDsc* varDsc = lvaGetDesc(lclNum); assert(varDsc->lvIsParam); return (info.compIsVarArgs && !varDsc->lvIsRegArg && (lclNum != lvaVarargsHandleArg)); #else // TARGET_X86 return false; #endif // TARGET_X86 } /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX EEInterface XX XX XX XX Get to the class and method info from the Execution Engine given XX XX tokens for the class and method XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ public: // Get handles void eeGetCallInfo(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_RESOLVED_TOKEN* pConstrainedToken, CORINFO_CALLINFO_FLAGS flags, CORINFO_CALL_INFO* pResult); void eeGetFieldInfo(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_ACCESS_FLAGS flags, CORINFO_FIELD_INFO* pResult); // Get the flags bool eeIsValueClass(CORINFO_CLASS_HANDLE clsHnd); bool eeIsIntrinsic(CORINFO_METHOD_HANDLE ftn); bool eeIsFieldStatic(CORINFO_FIELD_HANDLE fldHnd); var_types eeGetFieldType(CORINFO_FIELD_HANDLE fldHnd, CORINFO_CLASS_HANDLE* pStructHnd = nullptr); #if defined(DEBUG) || defined(FEATURE_JIT_METHOD_PERF) || defined(FEATURE_SIMD) || defined(TRACK_LSRA_STATS) const char* eeGetMethodName(CORINFO_METHOD_HANDLE hnd, const char** className); const char* eeGetMethodFullName(CORINFO_METHOD_HANDLE hnd); unsigned compMethodHash(CORINFO_METHOD_HANDLE methodHandle); bool eeIsNativeMethod(CORINFO_METHOD_HANDLE method); CORINFO_METHOD_HANDLE eeGetMethodHandleForNative(CORINFO_METHOD_HANDLE method); #endif var_types eeGetArgType(CORINFO_ARG_LIST_HANDLE list, CORINFO_SIG_INFO* sig); var_types eeGetArgType(CORINFO_ARG_LIST_HANDLE list, CORINFO_SIG_INFO* sig, bool* isPinned); CORINFO_CLASS_HANDLE eeGetArgClass(CORINFO_SIG_INFO* sig, CORINFO_ARG_LIST_HANDLE list); CORINFO_CLASS_HANDLE eeGetClassFromContext(CORINFO_CONTEXT_HANDLE context); unsigned eeGetArgSize(CORINFO_ARG_LIST_HANDLE list, CORINFO_SIG_INFO* sig); static unsigned eeGetArgAlignment(var_types type, bool isFloatHfa); // VOM info, method sigs void eeGetSig(unsigned sigTok, CORINFO_MODULE_HANDLE scope, CORINFO_CONTEXT_HANDLE context, CORINFO_SIG_INFO* retSig); void eeGetCallSiteSig(unsigned sigTok, CORINFO_MODULE_HANDLE scope, CORINFO_CONTEXT_HANDLE context, CORINFO_SIG_INFO* retSig); void eeGetMethodSig(CORINFO_METHOD_HANDLE methHnd, CORINFO_SIG_INFO* retSig, CORINFO_CLASS_HANDLE owner = nullptr); // Method entry-points, instrs CORINFO_METHOD_HANDLE eeMarkNativeTarget(CORINFO_METHOD_HANDLE method); CORINFO_EE_INFO eeInfo; bool eeInfoInitialized; CORINFO_EE_INFO* eeGetEEInfo(); // Gets the offset of a SDArray's first element static unsigned eeGetArrayDataOffset(); // Get the offset of a MDArray's first element static unsigned eeGetMDArrayDataOffset(unsigned rank); // Get the offset of a MDArray's dimension length for a given dimension. static unsigned eeGetMDArrayLengthOffset(unsigned rank, unsigned dimension); // Get the offset of a MDArray's lower bound for a given dimension. static unsigned eeGetMDArrayLowerBoundOffset(unsigned rank, unsigned dimension); GenTree* eeGetPInvokeCookie(CORINFO_SIG_INFO* szMetaSig); // Returns the page size for the target machine as reported by the EE. target_size_t eeGetPageSize() { return (target_size_t)eeGetEEInfo()->osPageSize; } //------------------------------------------------------------------------ // VirtualStubParam: virtual stub dispatch extra parameter (slot address). // // It represents Abi and target specific registers for the parameter. // class VirtualStubParamInfo { public: VirtualStubParamInfo(bool isCoreRTABI) { #if defined(TARGET_X86) reg = REG_EAX; regMask = RBM_EAX; #elif defined(TARGET_AMD64) if (isCoreRTABI) { reg = REG_R10; regMask = RBM_R10; } else { reg = REG_R11; regMask = RBM_R11; } #elif defined(TARGET_ARM) if (isCoreRTABI) { reg = REG_R12; regMask = RBM_R12; } else { reg = REG_R4; regMask = RBM_R4; } #elif defined(TARGET_ARM64) reg = REG_R11; regMask = RBM_R11; #else #error Unsupported or unset target architecture #endif } regNumber GetReg() const { return reg; } _regMask_enum GetRegMask() const { return regMask; } private: regNumber reg; _regMask_enum regMask; }; VirtualStubParamInfo* virtualStubParamInfo; bool IsTargetAbi(CORINFO_RUNTIME_ABI abi) { return eeGetEEInfo()->targetAbi == abi; } bool generateCFIUnwindCodes() { #if defined(FEATURE_CFI_SUPPORT) return TargetOS::IsUnix && IsTargetAbi(CORINFO_CORERT_ABI); #else return false; #endif } // Debugging support - Line number info void eeGetStmtOffsets(); unsigned eeBoundariesCount; ICorDebugInfo::OffsetMapping* eeBoundaries; // Boundaries to report to the EE void eeSetLIcount(unsigned count); void eeSetLIinfo(unsigned which, UNATIVE_OFFSET offs, IPmappingDscKind kind, const ILLocation& loc); void eeSetLIdone(); #ifdef DEBUG static void eeDispILOffs(IL_OFFSET offs); static void eeDispSourceMappingOffs(uint32_t offs); static void eeDispLineInfo(const ICorDebugInfo::OffsetMapping* line); void eeDispLineInfos(); #endif // DEBUG // Debugging support - Local var info void eeGetVars(); unsigned eeVarsCount; struct VarResultInfo { UNATIVE_OFFSET startOffset; UNATIVE_OFFSET endOffset; DWORD varNumber; CodeGenInterface::siVarLoc loc; } * eeVars; void eeSetLVcount(unsigned count); void eeSetLVinfo(unsigned which, UNATIVE_OFFSET startOffs, UNATIVE_OFFSET length, unsigned varNum, const CodeGenInterface::siVarLoc& loc); void eeSetLVdone(); #ifdef DEBUG void eeDispVar(ICorDebugInfo::NativeVarInfo* var); void eeDispVars(CORINFO_METHOD_HANDLE ftn, ULONG32 cVars, ICorDebugInfo::NativeVarInfo* vars); #endif // DEBUG // ICorJitInfo wrappers void eeReserveUnwindInfo(bool isFunclet, bool isColdCode, ULONG unwindSize); void eeAllocUnwindInfo(BYTE* pHotCode, BYTE* pColdCode, ULONG startOffset, ULONG endOffset, ULONG unwindSize, BYTE* pUnwindBlock, CorJitFuncKind funcKind); void eeSetEHcount(unsigned cEH); void eeSetEHinfo(unsigned EHnumber, const CORINFO_EH_CLAUSE* clause); WORD eeGetRelocTypeHint(void* target); // ICorStaticInfo wrapper functions bool eeTryResolveToken(CORINFO_RESOLVED_TOKEN* resolvedToken); #if defined(UNIX_AMD64_ABI) #ifdef DEBUG static void dumpSystemVClassificationType(SystemVClassificationType ct); #endif // DEBUG void eeGetSystemVAmd64PassStructInRegisterDescriptor( /*IN*/ CORINFO_CLASS_HANDLE structHnd, /*OUT*/ SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR* structPassInRegDescPtr); #endif // UNIX_AMD64_ABI template <typename ParamType> bool eeRunWithErrorTrap(void (*function)(ParamType*), ParamType* param) { return eeRunWithErrorTrapImp(reinterpret_cast<void (*)(void*)>(function), reinterpret_cast<void*>(param)); } bool eeRunWithErrorTrapImp(void (*function)(void*), void* param); template <typename ParamType> bool eeRunWithSPMIErrorTrap(void (*function)(ParamType*), ParamType* param) { return eeRunWithSPMIErrorTrapImp(reinterpret_cast<void (*)(void*)>(function), reinterpret_cast<void*>(param)); } bool eeRunWithSPMIErrorTrapImp(void (*function)(void*), void* param); // Utility functions const char* eeGetFieldName(CORINFO_FIELD_HANDLE fieldHnd, const char** classNamePtr = nullptr); #if defined(DEBUG) const WCHAR* eeGetCPString(size_t stringHandle); #endif const char* eeGetClassName(CORINFO_CLASS_HANDLE clsHnd); static CORINFO_METHOD_HANDLE eeFindHelper(unsigned helper); static CorInfoHelpFunc eeGetHelperNum(CORINFO_METHOD_HANDLE method); static bool IsSharedStaticHelper(GenTree* tree); static bool IsGcSafePoint(GenTreeCall* call); static CORINFO_FIELD_HANDLE eeFindJitDataOffs(unsigned jitDataOffs); // returns true/false if 'field' is a Jit Data offset static bool eeIsJitDataOffs(CORINFO_FIELD_HANDLE field); // returns a number < 0 if 'field' is not a Jit Data offset, otherwise the data offset (limited to 2GB) static int eeGetJitDataOffs(CORINFO_FIELD_HANDLE field); /*****************************************************************************/ /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX CodeGenerator XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ public: CodeGenInterface* codeGen; // Record the instr offset mapping to the generated code jitstd::list<IPmappingDsc> genIPmappings; #ifdef DEBUG jitstd::list<PreciseIPMapping> genPreciseIPmappings; #endif // Managed RetVal - A side hash table meant to record the mapping from a // GT_CALL node to its debug info. This info is used to emit sequence points // that can be used by debugger to determine the native offset at which the // managed RetVal will be available. // // In fact we can store debug info in a GT_CALL node. This was ruled out in // favor of a side table for two reasons: 1) We need debug info for only those // GT_CALL nodes (created during importation) that correspond to an IL call and // whose return type is other than TYP_VOID. 2) GT_CALL node is a frequently used // structure and IL offset is needed only when generating debuggable code. Therefore // it is desirable to avoid memory size penalty in retail scenarios. typedef JitHashTable<GenTree*, JitPtrKeyFuncs<GenTree>, DebugInfo> CallSiteDebugInfoTable; CallSiteDebugInfoTable* genCallSite2DebugInfoMap; unsigned genReturnLocal; // Local number for the return value when applicable. BasicBlock* genReturnBB; // jumped to when not optimizing for speed. // The following properties are part of CodeGenContext. Getters are provided here for // convenience and backward compatibility, but the properties can only be set by invoking // the setter on CodeGenContext directly. emitter* GetEmitter() const { return codeGen->GetEmitter(); } bool isFramePointerUsed() const { return codeGen->isFramePointerUsed(); } bool GetInterruptible() { return codeGen->GetInterruptible(); } void SetInterruptible(bool value) { codeGen->SetInterruptible(value); } #if DOUBLE_ALIGN const bool genDoubleAlign() { return codeGen->doDoubleAlign(); } DWORD getCanDoubleAlign(); bool shouldDoubleAlign(unsigned refCntStk, unsigned refCntReg, weight_t refCntWtdReg, unsigned refCntStkParam, weight_t refCntWtdStkDbl); #endif // DOUBLE_ALIGN bool IsFullPtrRegMapRequired() { return codeGen->IsFullPtrRegMapRequired(); } void SetFullPtrRegMapRequired(bool value) { codeGen->SetFullPtrRegMapRequired(value); } // Things that MAY belong either in CodeGen or CodeGenContext #if defined(FEATURE_EH_FUNCLETS) FuncInfoDsc* compFuncInfos; unsigned short compCurrFuncIdx; unsigned short compFuncInfoCount; unsigned short compFuncCount() { assert(fgFuncletsCreated); return compFuncInfoCount; } #else // !FEATURE_EH_FUNCLETS // This is a no-op when there are no funclets! void genUpdateCurrentFunclet(BasicBlock* block) { return; } FuncInfoDsc compFuncInfoRoot; static const unsigned compCurrFuncIdx = 0; unsigned short compFuncCount() { return 1; } #endif // !FEATURE_EH_FUNCLETS FuncInfoDsc* funCurrentFunc(); void funSetCurrentFunc(unsigned funcIdx); FuncInfoDsc* funGetFunc(unsigned funcIdx); unsigned int funGetFuncIdx(BasicBlock* block); // LIVENESS VARSET_TP compCurLife; // current live variables GenTree* compCurLifeTree; // node after which compCurLife has been computed // Compare the given "newLife" with last set of live variables and update // codeGen "gcInfo", siScopes, "regSet" with the new variable's homes/liveness. template <bool ForCodeGen> void compChangeLife(VARSET_VALARG_TP newLife); // Update the GC's masks, register's masks and reports change on variable's homes given a set of // current live variables if changes have happened since "compCurLife". template <bool ForCodeGen> inline void compUpdateLife(VARSET_VALARG_TP newLife); // Gets a register mask that represent the kill set for a helper call since // not all JIT Helper calls follow the standard ABI on the target architecture. regMaskTP compHelperCallKillSet(CorInfoHelpFunc helper); #ifdef TARGET_ARM // Requires that "varDsc" be a promoted struct local variable being passed as an argument, beginning at // "firstArgRegNum", which is assumed to have already been aligned to the register alignment restriction of the // struct type. Adds bits to "*pArgSkippedRegMask" for any argument registers *not* used in passing "varDsc" -- // i.e., internal "holes" caused by internal alignment constraints. For example, if the struct contained an int and // a double, and we at R0 (on ARM), then R1 would be skipped, and the bit for R1 would be added to the mask. void fgAddSkippedRegsInPromotedStructArg(LclVarDsc* varDsc, unsigned firstArgRegNum, regMaskTP* pArgSkippedRegMask); #endif // TARGET_ARM // If "tree" is a indirection (GT_IND, or GT_OBJ) whose arg is an ADDR, whose arg is a LCL_VAR, return that LCL_VAR // node, else NULL. static GenTreeLclVar* fgIsIndirOfAddrOfLocal(GenTree* tree); // This map is indexed by GT_OBJ nodes that are address of promoted struct variables, which // have been annotated with the GTF_VAR_DEATH flag. If such a node is *not* mapped in this // table, one may assume that all the (tracked) field vars die at this GT_OBJ. Otherwise, // the node maps to a pointer to a VARSET_TP, containing set bits for each of the tracked field // vars of the promoted struct local that go dead at the given node (the set bits are the bits // for the tracked var indices of the field vars, as in a live var set). // // The map is allocated on demand so all map operations should use one of the following three // wrapper methods. NodeToVarsetPtrMap* m_promotedStructDeathVars; NodeToVarsetPtrMap* GetPromotedStructDeathVars() { if (m_promotedStructDeathVars == nullptr) { m_promotedStructDeathVars = new (getAllocator()) NodeToVarsetPtrMap(getAllocator()); } return m_promotedStructDeathVars; } void ClearPromotedStructDeathVars() { if (m_promotedStructDeathVars != nullptr) { m_promotedStructDeathVars->RemoveAll(); } } bool LookupPromotedStructDeathVars(GenTree* tree, VARSET_TP** bits) { *bits = nullptr; bool result = false; if (m_promotedStructDeathVars != nullptr) { result = m_promotedStructDeathVars->Lookup(tree, bits); } return result; } /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX UnwindInfo XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ #if !defined(__GNUC__) #pragma region Unwind information #endif public: // // Infrastructure functions: start/stop/reserve/emit. // void unwindBegProlog(); void unwindEndProlog(); void unwindBegEpilog(); void unwindEndEpilog(); void unwindReserve(); void unwindEmit(void* pHotCode, void* pColdCode); // // Specific unwind information functions: called by code generation to indicate a particular // prolog or epilog unwindable instruction has been generated. // void unwindPush(regNumber reg); void unwindAllocStack(unsigned size); void unwindSetFrameReg(regNumber reg, unsigned offset); void unwindSaveReg(regNumber reg, unsigned offset); #if defined(TARGET_ARM) void unwindPushMaskInt(regMaskTP mask); void unwindPushMaskFloat(regMaskTP mask); void unwindPopMaskInt(regMaskTP mask); void unwindPopMaskFloat(regMaskTP mask); void unwindBranch16(); // The epilog terminates with a 16-bit branch (e.g., "bx lr") void unwindNop(unsigned codeSizeInBytes); // Generate unwind NOP code. 'codeSizeInBytes' is 2 or 4 bytes. Only // called via unwindPadding(). void unwindPadding(); // Generate a sequence of unwind NOP codes representing instructions between the last // instruction and the current location. #endif // TARGET_ARM #if defined(TARGET_ARM64) void unwindNop(); void unwindPadding(); // Generate a sequence of unwind NOP codes representing instructions between the last // instruction and the current location. void unwindSaveReg(regNumber reg, int offset); // str reg, [sp, #offset] void unwindSaveRegPreindexed(regNumber reg, int offset); // str reg, [sp, #offset]! void unwindSaveRegPair(regNumber reg1, regNumber reg2, int offset); // stp reg1, reg2, [sp, #offset] void unwindSaveRegPairPreindexed(regNumber reg1, regNumber reg2, int offset); // stp reg1, reg2, [sp, #offset]! void unwindSaveNext(); // unwind code: save_next void unwindReturn(regNumber reg); // ret lr #endif // defined(TARGET_ARM64) // // Private "helper" functions for the unwind implementation. // private: #if defined(FEATURE_EH_FUNCLETS) void unwindGetFuncLocations(FuncInfoDsc* func, bool getHotSectionData, /* OUT */ emitLocation** ppStartLoc, /* OUT */ emitLocation** ppEndLoc); #endif // FEATURE_EH_FUNCLETS void unwindReserveFunc(FuncInfoDsc* func); void unwindEmitFunc(FuncInfoDsc* func, void* pHotCode, void* pColdCode); #if defined(TARGET_AMD64) || (defined(TARGET_X86) && defined(FEATURE_EH_FUNCLETS)) void unwindReserveFuncHelper(FuncInfoDsc* func, bool isHotCode); void unwindEmitFuncHelper(FuncInfoDsc* func, void* pHotCode, void* pColdCode, bool isHotCode); #endif // TARGET_AMD64 || (TARGET_X86 && FEATURE_EH_FUNCLETS) UNATIVE_OFFSET unwindGetCurrentOffset(FuncInfoDsc* func); #if defined(TARGET_AMD64) void unwindBegPrologWindows(); void unwindPushWindows(regNumber reg); void unwindAllocStackWindows(unsigned size); void unwindSetFrameRegWindows(regNumber reg, unsigned offset); void unwindSaveRegWindows(regNumber reg, unsigned offset); #ifdef UNIX_AMD64_ABI void unwindSaveRegCFI(regNumber reg, unsigned offset); #endif // UNIX_AMD64_ABI #elif defined(TARGET_ARM) void unwindPushPopMaskInt(regMaskTP mask, bool useOpsize16); void unwindPushPopMaskFloat(regMaskTP mask); #endif // TARGET_ARM #if defined(FEATURE_CFI_SUPPORT) short mapRegNumToDwarfReg(regNumber reg); void createCfiCode(FuncInfoDsc* func, UNATIVE_OFFSET codeOffset, UCHAR opcode, short dwarfReg, INT offset = 0); void unwindPushPopCFI(regNumber reg); void unwindBegPrologCFI(); void unwindPushPopMaskCFI(regMaskTP regMask, bool isFloat); void unwindAllocStackCFI(unsigned size); void unwindSetFrameRegCFI(regNumber reg, unsigned offset); void unwindEmitFuncCFI(FuncInfoDsc* func, void* pHotCode, void* pColdCode); #ifdef DEBUG void DumpCfiInfo(bool isHotCode, UNATIVE_OFFSET startOffset, UNATIVE_OFFSET endOffset, DWORD cfiCodeBytes, const CFI_CODE* const pCfiCode); #endif #endif // FEATURE_CFI_SUPPORT #if !defined(__GNUC__) #pragma endregion // Note: region is NOT under !defined(__GNUC__) #endif /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX SIMD XX XX XX XX Info about SIMD types, methods and the SIMD assembly (i.e. the assembly XX XX that contains the distinguished, well-known SIMD type definitions). XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ bool IsBaselineSimdIsaSupported() { #ifdef FEATURE_SIMD #if defined(TARGET_XARCH) CORINFO_InstructionSet minimumIsa = InstructionSet_SSE2; #elif defined(TARGET_ARM64) CORINFO_InstructionSet minimumIsa = InstructionSet_AdvSimd; #else #error Unsupported platform #endif // !TARGET_XARCH && !TARGET_ARM64 return compOpportunisticallyDependsOn(minimumIsa); #else return false; #endif } #if defined(DEBUG) bool IsBaselineSimdIsaSupportedDebugOnly() { #ifdef FEATURE_SIMD #if defined(TARGET_XARCH) CORINFO_InstructionSet minimumIsa = InstructionSet_SSE2; #elif defined(TARGET_ARM64) CORINFO_InstructionSet minimumIsa = InstructionSet_AdvSimd; #else #error Unsupported platform #endif // !TARGET_XARCH && !TARGET_ARM64 return compIsaSupportedDebugOnly(minimumIsa); #else return false; #endif // FEATURE_SIMD } #endif // DEBUG // Get highest available level for SIMD codegen SIMDLevel getSIMDSupportLevel() { #if defined(TARGET_XARCH) if (compOpportunisticallyDependsOn(InstructionSet_AVX2)) { return SIMD_AVX2_Supported; } if (compOpportunisticallyDependsOn(InstructionSet_SSE42)) { return SIMD_SSE4_Supported; } // min bar is SSE2 return SIMD_SSE2_Supported; #else assert(!"Available instruction set(s) for SIMD codegen is not defined for target arch"); unreached(); return SIMD_Not_Supported; #endif } bool isIntrinsicType(CORINFO_CLASS_HANDLE clsHnd) { return info.compCompHnd->isIntrinsicType(clsHnd); } const char* getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName) { return info.compCompHnd->getClassNameFromMetadata(cls, namespaceName); } CORINFO_CLASS_HANDLE getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index) { return info.compCompHnd->getTypeInstantiationArgument(cls, index); } #ifdef FEATURE_SIMD // Should we support SIMD intrinsics? bool featureSIMD; // Should we recognize SIMD types? // We always do this on ARM64 to support HVA types. bool supportSIMDTypes() { #ifdef TARGET_ARM64 return true; #else return featureSIMD; #endif } // Have we identified any SIMD types? // This is currently used by struct promotion to avoid getting type information for a struct // field to see if it is a SIMD type, if we haven't seen any SIMD types or operations in // the method. bool _usesSIMDTypes; bool usesSIMDTypes() { return _usesSIMDTypes; } void setUsesSIMDTypes(bool value) { _usesSIMDTypes = value; } // This is a temp lclVar allocated on the stack as TYP_SIMD. It is used to implement intrinsics // that require indexed access to the individual fields of the vector, which is not well supported // by the hardware. It is allocated when/if such situations are encountered during Lowering. unsigned lvaSIMDInitTempVarNum; struct SIMDHandlesCache { // SIMD Types CORINFO_CLASS_HANDLE SIMDFloatHandle; CORINFO_CLASS_HANDLE SIMDDoubleHandle; CORINFO_CLASS_HANDLE SIMDIntHandle; CORINFO_CLASS_HANDLE SIMDUShortHandle; CORINFO_CLASS_HANDLE SIMDUByteHandle; CORINFO_CLASS_HANDLE SIMDShortHandle; CORINFO_CLASS_HANDLE SIMDByteHandle; CORINFO_CLASS_HANDLE SIMDLongHandle; CORINFO_CLASS_HANDLE SIMDUIntHandle; CORINFO_CLASS_HANDLE SIMDULongHandle; CORINFO_CLASS_HANDLE SIMDNIntHandle; CORINFO_CLASS_HANDLE SIMDNUIntHandle; CORINFO_CLASS_HANDLE SIMDVector2Handle; CORINFO_CLASS_HANDLE SIMDVector3Handle; CORINFO_CLASS_HANDLE SIMDVector4Handle; CORINFO_CLASS_HANDLE SIMDVectorHandle; #ifdef FEATURE_HW_INTRINSICS #if defined(TARGET_ARM64) CORINFO_CLASS_HANDLE Vector64FloatHandle; CORINFO_CLASS_HANDLE Vector64DoubleHandle; CORINFO_CLASS_HANDLE Vector64IntHandle; CORINFO_CLASS_HANDLE Vector64UShortHandle; CORINFO_CLASS_HANDLE Vector64UByteHandle; CORINFO_CLASS_HANDLE Vector64ShortHandle; CORINFO_CLASS_HANDLE Vector64ByteHandle; CORINFO_CLASS_HANDLE Vector64LongHandle; CORINFO_CLASS_HANDLE Vector64UIntHandle; CORINFO_CLASS_HANDLE Vector64ULongHandle; CORINFO_CLASS_HANDLE Vector64NIntHandle; CORINFO_CLASS_HANDLE Vector64NUIntHandle; #endif // defined(TARGET_ARM64) CORINFO_CLASS_HANDLE Vector128FloatHandle; CORINFO_CLASS_HANDLE Vector128DoubleHandle; CORINFO_CLASS_HANDLE Vector128IntHandle; CORINFO_CLASS_HANDLE Vector128UShortHandle; CORINFO_CLASS_HANDLE Vector128UByteHandle; CORINFO_CLASS_HANDLE Vector128ShortHandle; CORINFO_CLASS_HANDLE Vector128ByteHandle; CORINFO_CLASS_HANDLE Vector128LongHandle; CORINFO_CLASS_HANDLE Vector128UIntHandle; CORINFO_CLASS_HANDLE Vector128ULongHandle; CORINFO_CLASS_HANDLE Vector128NIntHandle; CORINFO_CLASS_HANDLE Vector128NUIntHandle; #if defined(TARGET_XARCH) CORINFO_CLASS_HANDLE Vector256FloatHandle; CORINFO_CLASS_HANDLE Vector256DoubleHandle; CORINFO_CLASS_HANDLE Vector256IntHandle; CORINFO_CLASS_HANDLE Vector256UShortHandle; CORINFO_CLASS_HANDLE Vector256UByteHandle; CORINFO_CLASS_HANDLE Vector256ShortHandle; CORINFO_CLASS_HANDLE Vector256ByteHandle; CORINFO_CLASS_HANDLE Vector256LongHandle; CORINFO_CLASS_HANDLE Vector256UIntHandle; CORINFO_CLASS_HANDLE Vector256ULongHandle; CORINFO_CLASS_HANDLE Vector256NIntHandle; CORINFO_CLASS_HANDLE Vector256NUIntHandle; #endif // defined(TARGET_XARCH) #endif // FEATURE_HW_INTRINSICS SIMDHandlesCache() { memset(this, 0, sizeof(*this)); } }; SIMDHandlesCache* m_simdHandleCache; // Get an appropriate "zero" for the given type and class handle. GenTree* gtGetSIMDZero(var_types simdType, CorInfoType simdBaseJitType, CORINFO_CLASS_HANDLE simdHandle); // Get the handle for a SIMD type. CORINFO_CLASS_HANDLE gtGetStructHandleForSIMD(var_types simdType, CorInfoType simdBaseJitType) { if (m_simdHandleCache == nullptr) { // This may happen if the JIT generates SIMD node on its own, without importing them. // Otherwise getBaseJitTypeAndSizeOfSIMDType should have created the cache. return NO_CLASS_HANDLE; } if (simdBaseJitType == CORINFO_TYPE_FLOAT) { switch (simdType) { case TYP_SIMD8: return m_simdHandleCache->SIMDVector2Handle; case TYP_SIMD12: return m_simdHandleCache->SIMDVector3Handle; case TYP_SIMD16: if ((getSIMDVectorType() == TYP_SIMD32) || (m_simdHandleCache->SIMDVector4Handle != NO_CLASS_HANDLE)) { return m_simdHandleCache->SIMDVector4Handle; } break; case TYP_SIMD32: break; default: unreached(); } } assert(emitTypeSize(simdType) <= largestEnregisterableStructSize()); switch (simdBaseJitType) { case CORINFO_TYPE_FLOAT: return m_simdHandleCache->SIMDFloatHandle; case CORINFO_TYPE_DOUBLE: return m_simdHandleCache->SIMDDoubleHandle; case CORINFO_TYPE_INT: return m_simdHandleCache->SIMDIntHandle; case CORINFO_TYPE_USHORT: return m_simdHandleCache->SIMDUShortHandle; case CORINFO_TYPE_UBYTE: return m_simdHandleCache->SIMDUByteHandle; case CORINFO_TYPE_SHORT: return m_simdHandleCache->SIMDShortHandle; case CORINFO_TYPE_BYTE: return m_simdHandleCache->SIMDByteHandle; case CORINFO_TYPE_LONG: return m_simdHandleCache->SIMDLongHandle; case CORINFO_TYPE_UINT: return m_simdHandleCache->SIMDUIntHandle; case CORINFO_TYPE_ULONG: return m_simdHandleCache->SIMDULongHandle; case CORINFO_TYPE_NATIVEINT: return m_simdHandleCache->SIMDNIntHandle; case CORINFO_TYPE_NATIVEUINT: return m_simdHandleCache->SIMDNUIntHandle; default: assert(!"Didn't find a class handle for simdType"); } return NO_CLASS_HANDLE; } // Returns true if this is a SIMD type that should be considered an opaque // vector type (i.e. do not analyze or promote its fields). // Note that all but the fixed vector types are opaque, even though they may // actually be declared as having fields. bool isOpaqueSIMDType(CORINFO_CLASS_HANDLE structHandle) const { return ((m_simdHandleCache != nullptr) && (structHandle != m_simdHandleCache->SIMDVector2Handle) && (structHandle != m_simdHandleCache->SIMDVector3Handle) && (structHandle != m_simdHandleCache->SIMDVector4Handle)); } // Returns true if the tree corresponds to a TYP_SIMD lcl var. // Note that both SIMD vector args and locals are mared as lvSIMDType = true, but // type of an arg node is TYP_BYREF and a local node is TYP_SIMD or TYP_STRUCT. bool isSIMDTypeLocal(GenTree* tree) { return tree->OperIsLocal() && lvaGetDesc(tree->AsLclVarCommon())->lvSIMDType; } // Returns true if the lclVar is an opaque SIMD type. bool isOpaqueSIMDLclVar(const LclVarDsc* varDsc) const { if (!varDsc->lvSIMDType) { return false; } return isOpaqueSIMDType(varDsc->GetStructHnd()); } static bool isRelOpSIMDIntrinsic(SIMDIntrinsicID intrinsicId) { return (intrinsicId == SIMDIntrinsicEqual); } // Returns base JIT type of a TYP_SIMD local. // Returns CORINFO_TYPE_UNDEF if the local is not TYP_SIMD. CorInfoType getBaseJitTypeOfSIMDLocal(GenTree* tree) { if (isSIMDTypeLocal(tree)) { return lvaGetDesc(tree->AsLclVarCommon())->GetSimdBaseJitType(); } return CORINFO_TYPE_UNDEF; } bool isSIMDClass(CORINFO_CLASS_HANDLE clsHnd) { if (isIntrinsicType(clsHnd)) { const char* namespaceName = nullptr; (void)getClassNameFromMetadata(clsHnd, &namespaceName); return strcmp(namespaceName, "System.Numerics") == 0; } return false; } bool isSIMDClass(typeInfo* pTypeInfo) { return pTypeInfo->IsStruct() && isSIMDClass(pTypeInfo->GetClassHandleForValueClass()); } bool isHWSIMDClass(CORINFO_CLASS_HANDLE clsHnd) { #ifdef FEATURE_HW_INTRINSICS if (isIntrinsicType(clsHnd)) { const char* namespaceName = nullptr; (void)getClassNameFromMetadata(clsHnd, &namespaceName); return strcmp(namespaceName, "System.Runtime.Intrinsics") == 0; } #endif // FEATURE_HW_INTRINSICS return false; } bool isHWSIMDClass(typeInfo* pTypeInfo) { #ifdef FEATURE_HW_INTRINSICS return pTypeInfo->IsStruct() && isHWSIMDClass(pTypeInfo->GetClassHandleForValueClass()); #else return false; #endif } bool isSIMDorHWSIMDClass(CORINFO_CLASS_HANDLE clsHnd) { return isSIMDClass(clsHnd) || isHWSIMDClass(clsHnd); } bool isSIMDorHWSIMDClass(typeInfo* pTypeInfo) { return isSIMDClass(pTypeInfo) || isHWSIMDClass(pTypeInfo); } // Get the base (element) type and size in bytes for a SIMD type. Returns CORINFO_TYPE_UNDEF // if it is not a SIMD type or is an unsupported base JIT type. CorInfoType getBaseJitTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeHnd, unsigned* sizeBytes = nullptr); CorInfoType getBaseJitTypeOfSIMDType(CORINFO_CLASS_HANDLE typeHnd) { return getBaseJitTypeAndSizeOfSIMDType(typeHnd, nullptr); } // Get SIMD Intrinsic info given the method handle. // Also sets typeHnd, argCount, baseType and sizeBytes out params. const SIMDIntrinsicInfo* getSIMDIntrinsicInfo(CORINFO_CLASS_HANDLE* typeHnd, CORINFO_METHOD_HANDLE methodHnd, CORINFO_SIG_INFO* sig, bool isNewObj, unsigned* argCount, CorInfoType* simdBaseJitType, unsigned* sizeBytes); // Pops and returns GenTree node from importers type stack. // Normalizes TYP_STRUCT value in case of GT_CALL, GT_RET_EXPR and arg nodes. GenTree* impSIMDPopStack(var_types type, bool expectAddr = false, CORINFO_CLASS_HANDLE structType = nullptr); // Transforms operands and returns the SIMD intrinsic to be applied on // transformed operands to obtain given relop result. SIMDIntrinsicID impSIMDRelOp(SIMDIntrinsicID relOpIntrinsicId, CORINFO_CLASS_HANDLE typeHnd, unsigned simdVectorSize, CorInfoType* inOutBaseJitType, GenTree** op1, GenTree** op2); #if defined(TARGET_XARCH) // Transforms operands and returns the SIMD intrinsic to be applied on // transformed operands to obtain == comparison result. SIMDIntrinsicID impSIMDLongRelOpEqual(CORINFO_CLASS_HANDLE typeHnd, unsigned simdVectorSize, GenTree** op1, GenTree** op2); #endif // defined(TARGET_XARCH) void setLclRelatedToSIMDIntrinsic(GenTree* tree); bool areFieldsContiguous(GenTree* op1, GenTree* op2); bool areLocalFieldsContiguous(GenTreeLclFld* first, GenTreeLclFld* second); bool areArrayElementsContiguous(GenTree* op1, GenTree* op2); bool areArgumentsContiguous(GenTree* op1, GenTree* op2); GenTree* createAddressNodeForSIMDInit(GenTree* tree, unsigned simdSize); // check methodHnd to see if it is a SIMD method that is expanded as an intrinsic in the JIT. GenTree* impSIMDIntrinsic(OPCODE opcode, GenTree* newobjThis, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig, unsigned methodFlags, int memberRef); GenTree* getOp1ForConstructor(OPCODE opcode, GenTree* newobjThis, CORINFO_CLASS_HANDLE clsHnd); // Whether SIMD vector occupies part of SIMD register. // SSE2: vector2f/3f are considered sub register SIMD types. // AVX: vector2f, 3f and 4f are all considered sub register SIMD types. bool isSubRegisterSIMDType(GenTreeSIMD* simdNode) { unsigned vectorRegisterByteLength; #if defined(TARGET_XARCH) // Calling the getSIMDVectorRegisterByteLength api causes the size of Vector<T> to be recorded // with the AOT compiler, so that it cannot change from aot compilation time to runtime // This api does not require such fixing as it merely pertains to the size of the simd type // relative to the Vector<T> size as used at compile time. (So detecting a vector length of 16 here // does not preclude the code from being used on a machine with a larger vector length.) if (getSIMDSupportLevel() < SIMD_AVX2_Supported) { vectorRegisterByteLength = 16; } else { vectorRegisterByteLength = 32; } #else vectorRegisterByteLength = getSIMDVectorRegisterByteLength(); #endif return (simdNode->GetSimdSize() < vectorRegisterByteLength); } // Get the type for the hardware SIMD vector. // This is the maximum SIMD type supported for this target. var_types getSIMDVectorType() { #if defined(TARGET_XARCH) if (getSIMDSupportLevel() == SIMD_AVX2_Supported) { return TYP_SIMD32; } else { // Verify and record that AVX2 isn't supported compVerifyInstructionSetUnusable(InstructionSet_AVX2); assert(getSIMDSupportLevel() >= SIMD_SSE2_Supported); return TYP_SIMD16; } #elif defined(TARGET_ARM64) return TYP_SIMD16; #else assert(!"getSIMDVectorType() unimplemented on target arch"); unreached(); #endif } // Get the size of the SIMD type in bytes int getSIMDTypeSizeInBytes(CORINFO_CLASS_HANDLE typeHnd) { unsigned sizeBytes = 0; (void)getBaseJitTypeAndSizeOfSIMDType(typeHnd, &sizeBytes); return sizeBytes; } // Get the the number of elements of baseType of SIMD vector given by its size and baseType static int getSIMDVectorLength(unsigned simdSize, var_types baseType); // Get the the number of elements of baseType of SIMD vector given by its type handle int getSIMDVectorLength(CORINFO_CLASS_HANDLE typeHnd); // Get preferred alignment of SIMD type. int getSIMDTypeAlignment(var_types simdType); // Get the number of bytes in a System.Numeric.Vector<T> for the current compilation. // Note - cannot be used for System.Runtime.Intrinsic unsigned getSIMDVectorRegisterByteLength() { #if defined(TARGET_XARCH) if (getSIMDSupportLevel() == SIMD_AVX2_Supported) { return YMM_REGSIZE_BYTES; } else { // Verify and record that AVX2 isn't supported compVerifyInstructionSetUnusable(InstructionSet_AVX2); assert(getSIMDSupportLevel() >= SIMD_SSE2_Supported); return XMM_REGSIZE_BYTES; } #elif defined(TARGET_ARM64) return FP_REGSIZE_BYTES; #else assert(!"getSIMDVectorRegisterByteLength() unimplemented on target arch"); unreached(); #endif } // The minimum and maximum possible number of bytes in a SIMD vector. // maxSIMDStructBytes // The minimum SIMD size supported by System.Numeric.Vectors or System.Runtime.Intrinsic // SSE: 16-byte Vector<T> and Vector128<T> // AVX: 32-byte Vector256<T> (Vector<T> is 16-byte) // AVX2: 32-byte Vector<T> and Vector256<T> unsigned int maxSIMDStructBytes() { #if defined(FEATURE_HW_INTRINSICS) && defined(TARGET_XARCH) if (compOpportunisticallyDependsOn(InstructionSet_AVX)) { return YMM_REGSIZE_BYTES; } else { // Verify and record that AVX2 isn't supported compVerifyInstructionSetUnusable(InstructionSet_AVX2); assert(getSIMDSupportLevel() >= SIMD_SSE2_Supported); return XMM_REGSIZE_BYTES; } #else return getSIMDVectorRegisterByteLength(); #endif } unsigned int minSIMDStructBytes() { return emitTypeSize(TYP_SIMD8); } public: // Returns the codegen type for a given SIMD size. static var_types getSIMDTypeForSize(unsigned size) { var_types simdType = TYP_UNDEF; if (size == 8) { simdType = TYP_SIMD8; } else if (size == 12) { simdType = TYP_SIMD12; } else if (size == 16) { simdType = TYP_SIMD16; } else if (size == 32) { simdType = TYP_SIMD32; } else { noway_assert(!"Unexpected size for SIMD type"); } return simdType; } private: unsigned getSIMDInitTempVarNum(var_types simdType); #else // !FEATURE_SIMD bool isOpaqueSIMDLclVar(LclVarDsc* varDsc) { return false; } #endif // FEATURE_SIMD public: //------------------------------------------------------------------------ // largestEnregisterableStruct: The size in bytes of the largest struct that can be enregistered. // // Notes: It is not guaranteed that the struct of this size or smaller WILL be a // candidate for enregistration. unsigned largestEnregisterableStructSize() { #ifdef FEATURE_SIMD #if defined(FEATURE_HW_INTRINSICS) && defined(TARGET_XARCH) if (opts.IsReadyToRun()) { // Return constant instead of maxSIMDStructBytes, as maxSIMDStructBytes performs // checks that are effected by the current level of instruction set support would // otherwise cause the highest level of instruction set support to be reported to crossgen2. // and this api is only ever used as an optimization or assert, so no reporting should // ever happen. return YMM_REGSIZE_BYTES; } #endif // defined(FEATURE_HW_INTRINSICS) && defined(TARGET_XARCH) unsigned vectorRegSize = maxSIMDStructBytes(); assert(vectorRegSize >= TARGET_POINTER_SIZE); return vectorRegSize; #else // !FEATURE_SIMD return TARGET_POINTER_SIZE; #endif // !FEATURE_SIMD } // Use to determine if a struct *might* be a SIMD type. As this function only takes a size, many // structs will fit the criteria. bool structSizeMightRepresentSIMDType(size_t structSize) { #ifdef FEATURE_SIMD // Do not use maxSIMDStructBytes as that api in R2R on X86 and X64 may notify the JIT // about the size of a struct under the assumption that the struct size needs to be recorded. // By using largestEnregisterableStructSize here, the detail of whether or not Vector256<T> is // enregistered or not will not be messaged to the R2R compiler. return (structSize >= minSIMDStructBytes()) && (structSize <= largestEnregisterableStructSize()); #else return false; #endif // FEATURE_SIMD } #ifdef FEATURE_SIMD static bool vnEncodesResultTypeForSIMDIntrinsic(SIMDIntrinsicID intrinsicId); #endif // !FEATURE_SIMD #ifdef FEATURE_HW_INTRINSICS static bool vnEncodesResultTypeForHWIntrinsic(NamedIntrinsic hwIntrinsicID); #endif // FEATURE_HW_INTRINSICS private: // These routines need not be enclosed under FEATURE_SIMD since lvIsSIMDType() // is defined for both FEATURE_SIMD and !FEATURE_SIMD apropriately. The use // of this routines also avoids the need of #ifdef FEATURE_SIMD specific code. // Is this var is of type simd struct? bool lclVarIsSIMDType(unsigned varNum) { return lvaGetDesc(varNum)->lvIsSIMDType(); } // Is this Local node a SIMD local? bool lclVarIsSIMDType(GenTreeLclVarCommon* lclVarTree) { return lclVarIsSIMDType(lclVarTree->GetLclNum()); } // Returns true if the TYP_SIMD locals on stack are aligned at their // preferred byte boundary specified by getSIMDTypeAlignment(). // // As per the Intel manual, the preferred alignment for AVX vectors is // 32-bytes. It is not clear whether additional stack space used in // aligning stack is worth the benefit and for now will use 16-byte // alignment for AVX 256-bit vectors with unaligned load/stores to/from // memory. On x86, the stack frame is aligned to 4 bytes. We need to extend // existing support for double (8-byte) alignment to 16 or 32 byte // alignment for frames with local SIMD vars, if that is determined to be // profitable. // // On Amd64 and SysV, RSP+8 is aligned on entry to the function (before // prolog has run). This means that in RBP-based frames RBP will be 16-byte // aligned. For RSP-based frames these are only sometimes aligned, depending // on the frame size. // bool isSIMDTypeLocalAligned(unsigned varNum) { #if defined(FEATURE_SIMD) && ALIGN_SIMD_TYPES if (lclVarIsSIMDType(varNum) && lvaTable[varNum].lvType != TYP_BYREF) { // TODO-Cleanup: Can't this use the lvExactSize on the varDsc? int alignment = getSIMDTypeAlignment(lvaTable[varNum].lvType); if (alignment <= STACK_ALIGN) { bool rbpBased; int off = lvaFrameAddress(varNum, &rbpBased); // On SysV and Winx64 ABIs RSP+8 will be 16-byte aligned at the // first instruction of a function. If our frame is RBP based // then RBP will always be 16 bytes aligned, so we can simply // check the offset. if (rbpBased) { return (off % alignment) == 0; } // For RSP-based frame the alignment of RSP depends on our // locals. rsp+8 is aligned on entry and we just subtract frame // size so it is not hard to compute. Note that the compiler // tries hard to make sure the frame size means RSP will be // 16-byte aligned, but for leaf functions without locals (i.e. // frameSize = 0) it will not be. int frameSize = codeGen->genTotalFrameSize(); return ((8 - frameSize + off) % alignment) == 0; } } #endif // FEATURE_SIMD return false; } #ifdef DEBUG // Answer the question: Is a particular ISA supported? // Use this api when asking the question so that future // ISA questions can be asked correctly or when asserting // support/nonsupport for an instruction set bool compIsaSupportedDebugOnly(CORINFO_InstructionSet isa) const { #if defined(TARGET_XARCH) || defined(TARGET_ARM64) return (opts.compSupportsISA & (1ULL << isa)) != 0; #else return false; #endif } #endif // DEBUG bool notifyInstructionSetUsage(CORINFO_InstructionSet isa, bool supported) const; // Answer the question: Is a particular ISA allowed to be used implicitly by optimizations? // The result of this api call will exactly match the target machine // on which the function is executed (except for CoreLib, where there are special rules) bool compExactlyDependsOn(CORINFO_InstructionSet isa) const { #if defined(TARGET_XARCH) || defined(TARGET_ARM64) uint64_t isaBit = (1ULL << isa); if ((opts.compSupportsISAReported & isaBit) == 0) { if (notifyInstructionSetUsage(isa, (opts.compSupportsISA & isaBit) != 0)) ((Compiler*)this)->opts.compSupportsISAExactly |= isaBit; ((Compiler*)this)->opts.compSupportsISAReported |= isaBit; } return (opts.compSupportsISAExactly & isaBit) != 0; #else return false; #endif } // Ensure that code will not execute if an instruction set is usable. Call only // if the instruction set has previously reported as unusable, but when // that that status has not yet been recorded to the AOT compiler void compVerifyInstructionSetUnusable(CORINFO_InstructionSet isa) { // use compExactlyDependsOn to capture are record the use of the isa bool isaUsable = compExactlyDependsOn(isa); // Assert that the is unusable. If true, this function should never be called. assert(!isaUsable); } // Answer the question: Is a particular ISA allowed to be used implicitly by optimizations? // The result of this api call will match the target machine if the result is true // If the result is false, then the target machine may have support for the instruction bool compOpportunisticallyDependsOn(CORINFO_InstructionSet isa) const { if ((opts.compSupportsISA & (1ULL << isa)) != 0) { return compExactlyDependsOn(isa); } else { return false; } } // Answer the question: Is a particular ISA supported for explicit hardware intrinsics? bool compHWIntrinsicDependsOn(CORINFO_InstructionSet isa) const { // Report intent to use the ISA to the EE compExactlyDependsOn(isa); return ((opts.compSupportsISA & (1ULL << isa)) != 0); } bool canUseVexEncoding() const { #ifdef TARGET_XARCH return compOpportunisticallyDependsOn(InstructionSet_AVX); #else return false; #endif } /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX Compiler XX XX XX XX Generic info about the compilation and the method being compiled. XX XX It is responsible for driving the other phases. XX XX It is also responsible for all the memory management. XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ public: Compiler* InlineeCompiler; // The Compiler instance for the inlinee InlineResult* compInlineResult; // The result of importing the inlinee method. bool compDoAggressiveInlining; // If true, mark every method as CORINFO_FLG_FORCEINLINE bool compJmpOpUsed; // Does the method do a JMP bool compLongUsed; // Does the method use TYP_LONG bool compFloatingPointUsed; // Does the method use TYP_FLOAT or TYP_DOUBLE bool compTailCallUsed; // Does the method do a tailcall bool compTailPrefixSeen; // Does the method IL have tail. prefix bool compLocallocSeen; // Does the method IL have localloc opcode bool compLocallocUsed; // Does the method use localloc. bool compLocallocOptimized; // Does the method have an optimized localloc bool compQmarkUsed; // Does the method use GT_QMARK/GT_COLON bool compQmarkRationalized; // Is it allowed to use a GT_QMARK/GT_COLON node. bool compUnsafeCastUsed; // Does the method use LDIND/STIND to cast between scalar/refernce types bool compHasBackwardJump; // Does the method (or some inlinee) have a lexically backwards jump? bool compHasBackwardJumpInHandler; // Does the method have a lexically backwards jump in a handler? bool compSwitchedToOptimized; // Codegen initially was Tier0 but jit switched to FullOpts bool compSwitchedToMinOpts; // Codegen initially was Tier1/FullOpts but jit switched to MinOpts bool compSuppressedZeroInit; // There are vars with lvSuppressedZeroInit set // NOTE: These values are only reliable after // the importing is completely finished. #ifdef DEBUG // State information - which phases have completed? // These are kept together for easy discoverability bool bRangeAllowStress; bool compCodeGenDone; int64_t compNumStatementLinksTraversed; // # of links traversed while doing debug checks bool fgNormalizeEHDone; // Has the flowgraph EH normalization phase been done? size_t compSizeEstimate; // The estimated size of the method as per `gtSetEvalOrder`. size_t compCycleEstimate; // The estimated cycle count of the method as per `gtSetEvalOrder` #endif // DEBUG bool fgLocalVarLivenessDone; // Note that this one is used outside of debug. bool fgLocalVarLivenessChanged; bool compLSRADone; bool compRationalIRForm; bool compUsesThrowHelper; // There is a call to a THROW_HELPER for the compiled method. bool compGeneratingProlog; bool compGeneratingEpilog; bool compNeedsGSSecurityCookie; // There is an unsafe buffer (or localloc) on the stack. // Insert cookie on frame and code to check the cookie, like VC++ -GS. bool compGSReorderStackLayout; // There is an unsafe buffer on the stack, reorder locals and make local // copies of susceptible parameters to avoid buffer overrun attacks through locals/params bool getNeedsGSSecurityCookie() const { return compNeedsGSSecurityCookie; } void setNeedsGSSecurityCookie() { compNeedsGSSecurityCookie = true; } FrameLayoutState lvaDoneFrameLayout; // The highest frame layout state that we've completed. During // frame layout calculations, this is the level we are currently // computing. //---------------------------- JITing options ----------------------------- enum codeOptimize { BLENDED_CODE, SMALL_CODE, FAST_CODE, COUNT_OPT_CODE }; struct Options { JitFlags* jitFlags; // all flags passed from the EE // The instruction sets that the compiler is allowed to emit. uint64_t compSupportsISA; // The instruction sets that were reported to the VM as being used by the current method. Subset of // compSupportsISA. uint64_t compSupportsISAReported; // The instruction sets that the compiler is allowed to take advantage of implicitly during optimizations. // Subset of compSupportsISA. // The instruction sets available in compSupportsISA and not available in compSupportsISAExactly can be only // used via explicit hardware intrinsics. uint64_t compSupportsISAExactly; void setSupportedISAs(CORINFO_InstructionSetFlags isas) { compSupportsISA = isas.GetFlagsRaw(); } unsigned compFlags; // method attributes unsigned instrCount; unsigned lvRefCount; codeOptimize compCodeOpt; // what type of code optimizations bool compUseCMOV; // optimize maximally and/or favor speed over size? #define DEFAULT_MIN_OPTS_CODE_SIZE 60000 #define DEFAULT_MIN_OPTS_INSTR_COUNT 20000 #define DEFAULT_MIN_OPTS_BB_COUNT 2000 #define DEFAULT_MIN_OPTS_LV_NUM_COUNT 2000 #define DEFAULT_MIN_OPTS_LV_REF_COUNT 8000 // Maximun number of locals before turning off the inlining #define MAX_LV_NUM_COUNT_FOR_INLINING 512 bool compMinOpts; bool compMinOptsIsSet; #ifdef DEBUG mutable bool compMinOptsIsUsed; bool MinOpts() const { assert(compMinOptsIsSet); compMinOptsIsUsed = true; return compMinOpts; } bool IsMinOptsSet() const { return compMinOptsIsSet; } #else // !DEBUG bool MinOpts() const { return compMinOpts; } bool IsMinOptsSet() const { return compMinOptsIsSet; } #endif // !DEBUG bool OptimizationDisabled() const { return MinOpts() || compDbgCode; } bool OptimizationEnabled() const { return !OptimizationDisabled(); } void SetMinOpts(bool val) { assert(!compMinOptsIsUsed); assert(!compMinOptsIsSet || (compMinOpts == val)); compMinOpts = val; compMinOptsIsSet = true; } // true if the CLFLG_* for an optimization is set. bool OptEnabled(unsigned optFlag) const { return !!(compFlags & optFlag); } #ifdef FEATURE_READYTORUN bool IsReadyToRun() const { return jitFlags->IsSet(JitFlags::JIT_FLAG_READYTORUN); } #else bool IsReadyToRun() const { return false; } #endif // Check if the compilation is control-flow guard enabled. bool IsCFGEnabled() const { #if defined(TARGET_ARM64) || defined(TARGET_AMD64) // On these platforms we assume the register that the target is // passed in is preserved by the validator and take care to get the // target from the register for the call (even in debug mode). static_assert_no_msg((RBM_VALIDATE_INDIRECT_CALL_TRASH & (1 << REG_VALIDATE_INDIRECT_CALL_ADDR)) == 0); if (JitConfig.JitForceControlFlowGuard()) return true; return jitFlags->IsSet(JitFlags::JIT_FLAG_ENABLE_CFG); #else // The remaining platforms are not supported and would require some // work to support. // // ARM32: // The ARM32 validator does not preserve any volatile registers // which means we have to take special care to allocate and use a // callee-saved register (reloading the target from memory is a // security issue). // // x86: // On x86 some VSD calls disassemble the call site and expect an // indirect call which is fundamentally incompatible with CFG. // This would require a different way to pass this information // through. // return false; #endif } #ifdef FEATURE_ON_STACK_REPLACEMENT bool IsOSR() const { return jitFlags->IsSet(JitFlags::JIT_FLAG_OSR); } #else bool IsOSR() const { return false; } #endif // true if we should use the PINVOKE_{BEGIN,END} helpers instead of generating // PInvoke transitions inline. Normally used by R2R, but also used when generating a reverse pinvoke frame, as // the current logic for frame setup initializes and pushes // the InlinedCallFrame before performing the Reverse PInvoke transition, which is invalid (as frames cannot // safely be pushed/popped while the thread is in a preemptive state.). bool ShouldUsePInvokeHelpers() { return jitFlags->IsSet(JitFlags::JIT_FLAG_USE_PINVOKE_HELPERS) || jitFlags->IsSet(JitFlags::JIT_FLAG_REVERSE_PINVOKE); } // true if we should use insert the REVERSE_PINVOKE_{ENTER,EXIT} helpers in the method // prolog/epilog bool IsReversePInvoke() { return jitFlags->IsSet(JitFlags::JIT_FLAG_REVERSE_PINVOKE); } bool compScopeInfo; // Generate the LocalVar info ? bool compDbgCode; // Generate debugger-friendly code? bool compDbgInfo; // Gather debugging info? bool compDbgEnC; #ifdef PROFILING_SUPPORTED bool compNoPInvokeInlineCB; #else static const bool compNoPInvokeInlineCB; #endif #ifdef DEBUG bool compGcChecks; // Check arguments and return values to ensure they are sane #endif #if defined(DEBUG) && defined(TARGET_XARCH) bool compStackCheckOnRet; // Check stack pointer on return to ensure it is correct. #endif // defined(DEBUG) && defined(TARGET_XARCH) #if defined(DEBUG) && defined(TARGET_X86) bool compStackCheckOnCall; // Check stack pointer after call to ensure it is correct. Only for x86. #endif // defined(DEBUG) && defined(TARGET_X86) bool compReloc; // Generate relocs for pointers in code, true for all ngen/prejit codegen #ifdef DEBUG #if defined(TARGET_XARCH) bool compEnablePCRelAddr; // Whether absolute addr be encoded as PC-rel offset by RyuJIT where possible #endif #endif // DEBUG #ifdef UNIX_AMD64_ABI // This flag is indicating if there is a need to align the frame. // On AMD64-Windows, if there are calls, 4 slots for the outgoing ars are allocated, except for // FastTailCall. This slots makes the frame size non-zero, so alignment logic will be called. // On AMD64-Unix, there are no such slots. There is a possibility to have calls in the method with frame size of // 0. The frame alignment logic won't kick in. This flags takes care of the AMD64-Unix case by remembering that // there are calls and making sure the frame alignment logic is executed. bool compNeedToAlignFrame; #endif // UNIX_AMD64_ABI bool compProcedureSplitting; // Separate cold code from hot code bool genFPorder; // Preserve FP order (operations are non-commutative) bool genFPopt; // Can we do frame-pointer-omission optimization? bool altJit; // True if we are an altjit and are compiling this method #ifdef OPT_CONFIG bool optRepeat; // Repeat optimizer phases k times #endif #ifdef DEBUG bool compProcedureSplittingEH; // Separate cold code from hot code for functions with EH bool dspCode; // Display native code generated bool dspEHTable; // Display the EH table reported to the VM bool dspDebugInfo; // Display the Debug info reported to the VM bool dspInstrs; // Display the IL instructions intermixed with the native code output bool dspLines; // Display source-code lines intermixed with native code output bool dmpHex; // Display raw bytes in hex of native code output bool varNames; // Display variables names in native code output bool disAsm; // Display native code as it is generated bool disAsmSpilled; // Display native code when any register spilling occurs bool disasmWithGC; // Display GC info interleaved with disassembly. bool disDiffable; // Makes the Disassembly code 'diff-able' bool disAddr; // Display process address next to each instruction in disassembly code bool disAlignment; // Display alignment boundaries in disassembly code bool disAsm2; // Display native code after it is generated using external disassembler bool dspOrder; // Display names of each of the methods that we ngen/jit bool dspUnwind; // Display the unwind info output bool dspDiffable; // Makes the Jit Dump 'diff-able' (currently uses same COMPlus_* flag as disDiffable) bool compLongAddress; // Force using large pseudo instructions for long address // (IF_LARGEJMP/IF_LARGEADR/IF_LARGLDC) bool dspGCtbls; // Display the GC tables #endif bool compExpandCallsEarly; // True if we should expand virtual call targets early for this method // Default numbers used to perform loop alignment. All the numbers are choosen // based on experimenting with various benchmarks. // Default minimum loop block weight required to enable loop alignment. #define DEFAULT_ALIGN_LOOP_MIN_BLOCK_WEIGHT 4 // By default a loop will be aligned at 32B address boundary to get better // performance as per architecture manuals. #define DEFAULT_ALIGN_LOOP_BOUNDARY 0x20 // For non-adaptive loop alignment, by default, only align a loop whose size is // at most 3 times the alignment block size. If the loop is bigger than that, it is most // likely complicated enough that loop alignment will not impact performance. #define DEFAULT_MAX_LOOPSIZE_FOR_ALIGN DEFAULT_ALIGN_LOOP_BOUNDARY * 3 #ifdef DEBUG // Loop alignment variables // If set, for non-adaptive alignment, ensure loop jmps are not on or cross alignment boundary. bool compJitAlignLoopForJcc; #endif // For non-adaptive alignment, minimum loop size (in bytes) for which alignment will be done. unsigned short compJitAlignLoopMaxCodeSize; // Minimum weight needed for the first block of a loop to make it a candidate for alignment. unsigned short compJitAlignLoopMinBlockWeight; // For non-adaptive alignment, address boundary (power of 2) at which loop alignment should // be done. By default, 32B. unsigned short compJitAlignLoopBoundary; // Padding limit to align a loop. unsigned short compJitAlignPaddingLimit; // If set, perform adaptive loop alignment that limits number of padding based on loop size. bool compJitAlignLoopAdaptive; // If set, tries to hide alignment instructions behind unconditional jumps. bool compJitHideAlignBehindJmp; #ifdef LATE_DISASM bool doLateDisasm; // Run the late disassembler #endif // LATE_DISASM #if DUMP_GC_TABLES && !defined(DEBUG) #pragma message("NOTE: this non-debug build has GC ptr table dumping always enabled!") static const bool dspGCtbls = true; #endif #ifdef PROFILING_SUPPORTED // Whether to emit Enter/Leave/TailCall hooks using a dummy stub (DummyProfilerELTStub()). // This option helps make the JIT behave as if it is running under a profiler. bool compJitELTHookEnabled; #endif // PROFILING_SUPPORTED #if FEATURE_TAILCALL_OPT // Whether opportunistic or implicit tail call optimization is enabled. bool compTailCallOpt; // Whether optimization of transforming a recursive tail call into a loop is enabled. bool compTailCallLoopOpt; #endif #if FEATURE_FASTTAILCALL // Whether fast tail calls are allowed. bool compFastTailCalls; #endif // FEATURE_FASTTAILCALL #if defined(TARGET_ARM64) // Decision about whether to save FP/LR registers with callee-saved registers (see // COMPlus_JitSaveFpLrWithCalleSavedRegisters). int compJitSaveFpLrWithCalleeSavedRegisters; #endif // defined(TARGET_ARM64) #ifdef CONFIGURABLE_ARM_ABI bool compUseSoftFP = false; #else #ifdef ARM_SOFTFP static const bool compUseSoftFP = true; #else // !ARM_SOFTFP static const bool compUseSoftFP = false; #endif // ARM_SOFTFP #endif // CONFIGURABLE_ARM_ABI } opts; static bool s_pAltJitExcludeAssembliesListInitialized; static AssemblyNamesList2* s_pAltJitExcludeAssembliesList; #ifdef DEBUG static bool s_pJitDisasmIncludeAssembliesListInitialized; static AssemblyNamesList2* s_pJitDisasmIncludeAssembliesList; static bool s_pJitFunctionFileInitialized; static MethodSet* s_pJitMethodSet; #endif // DEBUG #ifdef DEBUG // silence warning of cast to greater size. It is easier to silence than construct code the compiler is happy with, and // it is safe in this case #pragma warning(push) #pragma warning(disable : 4312) template <typename T> T dspPtr(T p) { return (p == ZERO) ? ZERO : (opts.dspDiffable ? T(0xD1FFAB1E) : p); } template <typename T> T dspOffset(T o) { return (o == ZERO) ? ZERO : (opts.dspDiffable ? T(0xD1FFAB1E) : o); } #pragma warning(pop) static int dspTreeID(GenTree* tree) { return tree->gtTreeID; } static void printStmtID(Statement* stmt) { assert(stmt != nullptr); printf(FMT_STMT, stmt->GetID()); } static void printTreeID(GenTree* tree) { if (tree == nullptr) { printf("[------]"); } else { printf("[%06d]", dspTreeID(tree)); } } const char* pgoSourceToString(ICorJitInfo::PgoSource p); const char* devirtualizationDetailToString(CORINFO_DEVIRTUALIZATION_DETAIL detail); #endif // DEBUG // clang-format off #define STRESS_MODES \ \ STRESS_MODE(NONE) \ \ /* "Variations" stress areas which we try to mix up with each other. */ \ /* These should not be exhaustively used as they might */ \ /* hide/trivialize other areas */ \ \ STRESS_MODE(REGS) \ STRESS_MODE(DBL_ALN) \ STRESS_MODE(LCL_FLDS) \ STRESS_MODE(UNROLL_LOOPS) \ STRESS_MODE(MAKE_CSE) \ STRESS_MODE(LEGACY_INLINE) \ STRESS_MODE(CLONE_EXPR) \ STRESS_MODE(USE_CMOV) \ STRESS_MODE(FOLD) \ STRESS_MODE(MERGED_RETURNS) \ STRESS_MODE(BB_PROFILE) \ STRESS_MODE(OPT_BOOLS_GC) \ STRESS_MODE(REMORPH_TREES) \ STRESS_MODE(64RSLT_MUL) \ STRESS_MODE(DO_WHILE_LOOPS) \ STRESS_MODE(MIN_OPTS) \ STRESS_MODE(REVERSE_FLAG) /* Will set GTF_REVERSE_OPS whenever we can */ \ STRESS_MODE(REVERSE_COMMA) /* Will reverse commas created with gtNewCommaNode */ \ STRESS_MODE(TAILCALL) /* Will make the call as a tailcall whenever legal */ \ STRESS_MODE(CATCH_ARG) /* Will spill catch arg */ \ STRESS_MODE(UNSAFE_BUFFER_CHECKS) \ STRESS_MODE(NULL_OBJECT_CHECK) \ STRESS_MODE(PINVOKE_RESTORE_ESP) \ STRESS_MODE(RANDOM_INLINE) \ STRESS_MODE(SWITCH_CMP_BR_EXPANSION) \ STRESS_MODE(GENERIC_VARN) \ STRESS_MODE(PROFILER_CALLBACKS) /* Will generate profiler hooks for ELT callbacks */ \ STRESS_MODE(BYREF_PROMOTION) /* Change undoPromotion decisions for byrefs */ \ STRESS_MODE(PROMOTE_FEWER_STRUCTS)/* Don't promote some structs that can be promoted */ \ STRESS_MODE(VN_BUDGET)/* Randomize the VN budget */ \ \ /* After COUNT_VARN, stress level 2 does all of these all the time */ \ \ STRESS_MODE(COUNT_VARN) \ \ /* "Check" stress areas that can be exhaustively used if we */ \ /* dont care about performance at all */ \ \ STRESS_MODE(FORCE_INLINE) /* Treat every method as AggressiveInlining */ \ STRESS_MODE(CHK_FLOW_UPDATE) \ STRESS_MODE(EMITTER) \ STRESS_MODE(CHK_REIMPORT) \ STRESS_MODE(FLATFP) \ STRESS_MODE(GENERIC_CHECK) \ STRESS_MODE(COUNT) enum compStressArea { #define STRESS_MODE(mode) STRESS_##mode, STRESS_MODES #undef STRESS_MODE }; // clang-format on #ifdef DEBUG static const LPCWSTR s_compStressModeNames[STRESS_COUNT + 1]; BYTE compActiveStressModes[STRESS_COUNT]; #endif // DEBUG #define MAX_STRESS_WEIGHT 100 bool compStressCompile(compStressArea stressArea, unsigned weightPercentage); bool compStressCompileHelper(compStressArea stressArea, unsigned weightPercentage); #ifdef DEBUG bool compInlineStress() { return compStressCompile(STRESS_LEGACY_INLINE, 50); } bool compRandomInlineStress() { return compStressCompile(STRESS_RANDOM_INLINE, 50); } bool compPromoteFewerStructs(unsigned lclNum); #endif // DEBUG bool compTailCallStress() { #ifdef DEBUG // Do not stress tailcalls in IL stubs as the runtime creates several IL // stubs to implement the tailcall mechanism, which would then // recursively create more IL stubs. return !opts.jitFlags->IsSet(JitFlags::JIT_FLAG_IL_STUB) && (JitConfig.TailcallStress() != 0 || compStressCompile(STRESS_TAILCALL, 5)); #else return false; #endif } const char* compGetTieringName(bool wantShortName = false) const; const char* compGetStressMessage() const; codeOptimize compCodeOpt() const { #if 0 // Switching between size & speed has measurable throughput impact // (3.5% on NGen CoreLib when measured). It used to be enabled for // DEBUG, but should generate identical code between CHK & RET builds, // so that's not acceptable. // TODO-Throughput: Figure out what to do about size vs. speed & throughput. // Investigate the cause of the throughput regression. return opts.compCodeOpt; #else return BLENDED_CODE; #endif } //--------------------- Info about the procedure -------------------------- struct Info { COMP_HANDLE compCompHnd; CORINFO_MODULE_HANDLE compScopeHnd; CORINFO_CLASS_HANDLE compClassHnd; CORINFO_METHOD_HANDLE compMethodHnd; CORINFO_METHOD_INFO* compMethodInfo; bool hasCircularClassConstraints; bool hasCircularMethodConstraints; #if defined(DEBUG) || defined(LATE_DISASM) || DUMP_FLOWGRAPHS const char* compMethodName; const char* compClassName; const char* compFullName; double compPerfScore; int compMethodSuperPMIIndex; // useful when debugging under SuperPMI #endif // defined(DEBUG) || defined(LATE_DISASM) || DUMP_FLOWGRAPHS #if defined(DEBUG) || defined(INLINE_DATA) // Method hash is logically const, but computed // on first demand. mutable unsigned compMethodHashPrivate; unsigned compMethodHash() const; #endif // defined(DEBUG) || defined(INLINE_DATA) #ifdef PSEUDORANDOM_NOP_INSERTION // things for pseudorandom nop insertion unsigned compChecksum; CLRRandom compRNG; #endif // The following holds the FLG_xxxx flags for the method we're compiling. unsigned compFlags; // The following holds the class attributes for the method we're compiling. unsigned compClassAttr; const BYTE* compCode; IL_OFFSET compILCodeSize; // The IL code size IL_OFFSET compILImportSize; // Estimated amount of IL actually imported IL_OFFSET compILEntry; // The IL entry point (normally 0) PatchpointInfo* compPatchpointInfo; // Patchpoint data for OSR (normally nullptr) UNATIVE_OFFSET compNativeCodeSize; // The native code size, after instructions are issued. This // is less than (compTotalHotCodeSize + compTotalColdCodeSize) only if: // (1) the code is not hot/cold split, and we issued less code than we expected, or // (2) the code is hot/cold split, and we issued less code than we expected // in the cold section (the hot section will always be padded out to compTotalHotCodeSize). bool compIsStatic : 1; // Is the method static (no 'this' pointer)? bool compIsVarArgs : 1; // Does the method have varargs parameters? bool compInitMem : 1; // Is the CORINFO_OPT_INIT_LOCALS bit set in the method info options? bool compProfilerCallback : 1; // JIT inserted a profiler Enter callback bool compPublishStubParam : 1; // EAX captured in prolog will be available through an intrinsic bool compHasNextCallRetAddr : 1; // The NextCallReturnAddress intrinsic is used. var_types compRetType; // Return type of the method as declared in IL var_types compRetNativeType; // Normalized return type as per target arch ABI unsigned compILargsCount; // Number of arguments (incl. implicit but not hidden) unsigned compArgsCount; // Number of arguments (incl. implicit and hidden) #if FEATURE_FASTTAILCALL unsigned compArgStackSize; // Incoming argument stack size in bytes #endif // FEATURE_FASTTAILCALL unsigned compRetBuffArg; // position of hidden return param var (0, 1) (BAD_VAR_NUM means not present); int compTypeCtxtArg; // position of hidden param for type context for generic code (CORINFO_CALLCONV_PARAMTYPE) unsigned compThisArg; // position of implicit this pointer param (not to be confused with lvaArg0Var) unsigned compILlocalsCount; // Number of vars : args + locals (incl. implicit but not hidden) unsigned compLocalsCount; // Number of vars : args + locals (incl. implicit and hidden) unsigned compMaxStack; UNATIVE_OFFSET compTotalHotCodeSize; // Total number of bytes of Hot Code in the method UNATIVE_OFFSET compTotalColdCodeSize; // Total number of bytes of Cold Code in the method unsigned compUnmanagedCallCountWithGCTransition; // count of unmanaged calls with GC transition. CorInfoCallConvExtension compCallConv; // The entry-point calling convention for this method. unsigned compLvFrameListRoot; // lclNum for the Frame root unsigned compXcptnsCount; // Number of exception-handling clauses read in the method's IL. // You should generally use compHndBBtabCount instead: it is the // current number of EH clauses (after additions like synchronized // methods and funclets, and removals like unreachable code deletion). Target::ArgOrder compArgOrder; bool compMatchedVM; // true if the VM is "matched": either the JIT is a cross-compiler // and the VM expects that, or the JIT is a "self-host" compiler // (e.g., x86 hosted targeting x86) and the VM expects that. /* The following holds IL scope information about local variables. */ unsigned compVarScopesCount; VarScopeDsc* compVarScopes; /* The following holds information about instr offsets for * which we need to report IP-mappings */ IL_OFFSET* compStmtOffsets; // sorted unsigned compStmtOffsetsCount; ICorDebugInfo::BoundaryTypes compStmtOffsetsImplicit; #define CPU_X86 0x0100 // The generic X86 CPU #define CPU_X86_PENTIUM_4 0x0110 #define CPU_X64 0x0200 // The generic x64 CPU #define CPU_AMD_X64 0x0210 // AMD x64 CPU #define CPU_INTEL_X64 0x0240 // Intel x64 CPU #define CPU_ARM 0x0300 // The generic ARM CPU #define CPU_ARM64 0x0400 // The generic ARM64 CPU unsigned genCPU; // What CPU are we running on // Number of class profile probes in this method unsigned compClassProbeCount; } info; // Returns true if the method being compiled returns a non-void and non-struct value. // Note that lvaInitTypeRef() normalizes compRetNativeType for struct returns in a // single register as per target arch ABI (e.g on Amd64 Windows structs of size 1, 2, // 4 or 8 gets normalized to TYP_BYTE/TYP_SHORT/TYP_INT/TYP_LONG; On Arm HFA structs). // Methods returning such structs are considered to return non-struct return value and // this method returns true in that case. bool compMethodReturnsNativeScalarType() { return (info.compRetType != TYP_VOID) && !varTypeIsStruct(info.compRetNativeType); } // Returns true if the method being compiled returns RetBuf addr as its return value bool compMethodReturnsRetBufAddr() { // There are cases where implicit RetBuf argument should be explicitly returned in a register. // In such cases the return type is changed to TYP_BYREF and appropriate IR is generated. // These cases are: CLANG_FORMAT_COMMENT_ANCHOR; #ifdef TARGET_AMD64 // 1. on x64 Windows and Unix the address of RetBuf needs to be returned by // methods with hidden RetBufArg in RAX. In such case GT_RETURN is of TYP_BYREF, // returning the address of RetBuf. return (info.compRetBuffArg != BAD_VAR_NUM); #else // TARGET_AMD64 #ifdef PROFILING_SUPPORTED // 2. Profiler Leave callback expects the address of retbuf as return value for // methods with hidden RetBuf argument. impReturnInstruction() when profiler // callbacks are needed creates GT_RETURN(TYP_BYREF, op1 = Addr of RetBuf) for // methods with hidden RetBufArg. if (compIsProfilerHookNeeded()) { return (info.compRetBuffArg != BAD_VAR_NUM); } #endif // 3. Windows ARM64 native instance calling convention requires the address of RetBuff // to be returned in x0. CLANG_FORMAT_COMMENT_ANCHOR; #if defined(TARGET_ARM64) if (TargetOS::IsWindows) { auto callConv = info.compCallConv; if (callConvIsInstanceMethodCallConv(callConv)) { return (info.compRetBuffArg != BAD_VAR_NUM); } } #endif // TARGET_ARM64 // 4. x86 unmanaged calling conventions require the address of RetBuff to be returned in eax. CLANG_FORMAT_COMMENT_ANCHOR; #if defined(TARGET_X86) if (info.compCallConv != CorInfoCallConvExtension::Managed) { return (info.compRetBuffArg != BAD_VAR_NUM); } #endif return false; #endif // TARGET_AMD64 } // Returns true if the method returns a value in more than one return register // TODO-ARM-Bug: Deal with multi-register genReturnLocaled structs? // TODO-ARM64: Does this apply for ARM64 too? bool compMethodReturnsMultiRegRetType() { #if FEATURE_MULTIREG_RET #if defined(TARGET_X86) // On x86, 64-bit longs and structs are returned in multiple registers return varTypeIsLong(info.compRetNativeType) || (varTypeIsStruct(info.compRetNativeType) && (info.compRetBuffArg == BAD_VAR_NUM)); #else // targets: X64-UNIX, ARM64 or ARM32 // On all other targets that support multireg return values: // Methods returning a struct in multiple registers have a return value of TYP_STRUCT. // Such method's compRetNativeType is TYP_STRUCT without a hidden RetBufArg return varTypeIsStruct(info.compRetNativeType) && (info.compRetBuffArg == BAD_VAR_NUM); #endif // TARGET_XXX #else // not FEATURE_MULTIREG_RET // For this architecture there are no multireg returns return false; #endif // FEATURE_MULTIREG_RET } bool compEnregLocals() { return ((opts.compFlags & CLFLG_REGVAR) != 0); } bool compEnregStructLocals() { return (JitConfig.JitEnregStructLocals() != 0); } bool compObjectStackAllocation() { return (JitConfig.JitObjectStackAllocation() != 0); } // Returns true if the method returns a value in more than one return register, // it should replace/be merged with compMethodReturnsMultiRegRetType when #36868 is fixed. // The difference from original `compMethodReturnsMultiRegRetType` is in ARM64 SIMD* handling, // this method correctly returns false for it (it is passed as HVA), when the original returns true. bool compMethodReturnsMultiRegRegTypeAlternate() { #if FEATURE_MULTIREG_RET #if defined(TARGET_X86) // On x86, 64-bit longs and structs are returned in multiple registers return varTypeIsLong(info.compRetNativeType) || (varTypeIsStruct(info.compRetNativeType) && (info.compRetBuffArg == BAD_VAR_NUM)); #else // targets: X64-UNIX, ARM64 or ARM32 #if defined(TARGET_ARM64) // TYP_SIMD* are returned in one register. if (varTypeIsSIMD(info.compRetNativeType)) { return false; } #endif // On all other targets that support multireg return values: // Methods returning a struct in multiple registers have a return value of TYP_STRUCT. // Such method's compRetNativeType is TYP_STRUCT without a hidden RetBufArg return varTypeIsStruct(info.compRetNativeType) && (info.compRetBuffArg == BAD_VAR_NUM); #endif // TARGET_XXX #else // not FEATURE_MULTIREG_RET // For this architecture there are no multireg returns return false; #endif // FEATURE_MULTIREG_RET } // Returns true if the method being compiled returns a value bool compMethodHasRetVal() { return compMethodReturnsNativeScalarType() || compMethodReturnsRetBufAddr() || compMethodReturnsMultiRegRetType(); } // Returns true if the method requires a PInvoke prolog and epilog bool compMethodRequiresPInvokeFrame() { return (info.compUnmanagedCallCountWithGCTransition > 0); } // Returns true if address-exposed user variables should be poisoned with a recognizable value bool compShouldPoisonFrame() { #ifdef FEATURE_ON_STACK_REPLACEMENT if (opts.IsOSR()) return false; #endif return !info.compInitMem && opts.compDbgCode; } // Returns true if the jit supports having patchpoints in this method. // Optionally, get the reason why not. bool compCanHavePatchpoints(const char** reason = nullptr); #if defined(DEBUG) void compDispLocalVars(); #endif // DEBUG private: class ClassLayoutTable* m_classLayoutTable; class ClassLayoutTable* typCreateClassLayoutTable(); class ClassLayoutTable* typGetClassLayoutTable(); public: // Get the layout having the specified layout number. ClassLayout* typGetLayoutByNum(unsigned layoutNum); // Get the layout number of the specified layout. unsigned typGetLayoutNum(ClassLayout* layout); // Get the layout having the specified size but no class handle. ClassLayout* typGetBlkLayout(unsigned blockSize); // Get the number of a layout having the specified size but no class handle. unsigned typGetBlkLayoutNum(unsigned blockSize); // Get the layout for the specified class handle. ClassLayout* typGetObjLayout(CORINFO_CLASS_HANDLE classHandle); // Get the number of a layout for the specified class handle. unsigned typGetObjLayoutNum(CORINFO_CLASS_HANDLE classHandle); //-------------------------- Global Compiler Data ------------------------------------ #ifdef DEBUG private: static LONG s_compMethodsCount; // to produce unique label names #endif public: #ifdef DEBUG LONG compMethodID; unsigned compGenTreeID; unsigned compStatementID; unsigned compBasicBlockID; #endif BasicBlock* compCurBB; // the current basic block in process Statement* compCurStmt; // the current statement in process GenTree* compCurTree; // the current tree in process // The following is used to create the 'method JIT info' block. size_t compInfoBlkSize; BYTE* compInfoBlkAddr; EHblkDsc* compHndBBtab; // array of EH data unsigned compHndBBtabCount; // element count of used elements in EH data array unsigned compHndBBtabAllocCount; // element count of allocated elements in EH data array #if defined(TARGET_X86) //------------------------------------------------------------------------- // Tracking of region covered by the monitor in synchronized methods void* syncStartEmitCookie; // the emitter cookie for first instruction after the call to MON_ENTER void* syncEndEmitCookie; // the emitter cookie for first instruction after the call to MON_EXIT #endif // !TARGET_X86 Phases mostRecentlyActivePhase; // the most recently active phase PhaseChecks activePhaseChecks; // the currently active phase checks //------------------------------------------------------------------------- // The following keeps track of how many bytes of local frame space we've // grabbed so far in the current function, and how many argument bytes we // need to pop when we return. // unsigned compLclFrameSize; // secObject+lclBlk+locals+temps // Count of callee-saved regs we pushed in the prolog. // Does not include EBP for isFramePointerUsed() and double-aligned frames. // In case of Amd64 this doesn't include float regs saved on stack. unsigned compCalleeRegsPushed; #if defined(TARGET_XARCH) // Mask of callee saved float regs on stack. regMaskTP compCalleeFPRegsSavedMask; #endif #ifdef TARGET_AMD64 // Quirk for VS debug-launch scenario to work: // Bytes of padding between save-reg area and locals. #define VSQUIRK_STACK_PAD (2 * REGSIZE_BYTES) unsigned compVSQuirkStackPaddingNeeded; #endif unsigned compArgSize; // total size of arguments in bytes (including register args (lvIsRegArg)) unsigned compMapILargNum(unsigned ILargNum); // map accounting for hidden args unsigned compMapILvarNum(unsigned ILvarNum); // map accounting for hidden args unsigned compMap2ILvarNum(unsigned varNum) const; // map accounting for hidden args #if defined(TARGET_ARM64) struct FrameInfo { // Frame type (1-5) int frameType; // Distance from established (method body) SP to base of callee save area int calleeSaveSpOffset; // Amount to subtract from SP before saving (prolog) OR // to add to SP after restoring (epilog) callee saves int calleeSaveSpDelta; // Distance from established SP to where caller's FP was saved int offsetSpToSavedFp; } compFrameInfo; #endif //------------------------------------------------------------------------- static void compStartup(); // One-time initialization static void compShutdown(); // One-time finalization void compInit(ArenaAllocator* pAlloc, CORINFO_METHOD_HANDLE methodHnd, COMP_HANDLE compHnd, CORINFO_METHOD_INFO* methodInfo, InlineInfo* inlineInfo); void compDone(); static void compDisplayStaticSizes(FILE* fout); //------------ Some utility functions -------------- void* compGetHelperFtn(CorInfoHelpFunc ftnNum, /* IN */ void** ppIndirection); /* OUT */ // Several JIT/EE interface functions return a CorInfoType, and also return a // class handle as an out parameter if the type is a value class. Returns the // size of the type these describe. unsigned compGetTypeSize(CorInfoType cit, CORINFO_CLASS_HANDLE clsHnd); // Returns true if the method being compiled has a return buffer. bool compHasRetBuffArg(); #ifdef DEBUG // Components used by the compiler may write unit test suites, and // have them run within this method. They will be run only once per process, and only // in debug. (Perhaps should be under the control of a COMPlus_ flag.) // These should fail by asserting. void compDoComponentUnitTestsOnce(); #endif // DEBUG int compCompile(CORINFO_MODULE_HANDLE classPtr, void** methodCodePtr, uint32_t* methodCodeSize, JitFlags* compileFlags); void compCompileFinish(); int compCompileHelper(CORINFO_MODULE_HANDLE classPtr, COMP_HANDLE compHnd, CORINFO_METHOD_INFO* methodInfo, void** methodCodePtr, uint32_t* methodCodeSize, JitFlags* compileFlag); ArenaAllocator* compGetArenaAllocator(); void generatePatchpointInfo(); #if MEASURE_MEM_ALLOC static bool s_dspMemStats; // Display per-phase memory statistics for every function #endif // MEASURE_MEM_ALLOC #if LOOP_HOIST_STATS unsigned m_loopsConsidered; bool m_curLoopHasHoistedExpression; unsigned m_loopsWithHoistedExpressions; unsigned m_totalHoistedExpressions; void AddLoopHoistStats(); void PrintPerMethodLoopHoistStats(); static CritSecObject s_loopHoistStatsLock; // This lock protects the data structures below. static unsigned s_loopsConsidered; static unsigned s_loopsWithHoistedExpressions; static unsigned s_totalHoistedExpressions; static void PrintAggregateLoopHoistStats(FILE* f); #endif // LOOP_HOIST_STATS #if TRACK_ENREG_STATS class EnregisterStats { private: unsigned m_totalNumberOfVars; unsigned m_totalNumberOfStructVars; unsigned m_totalNumberOfEnregVars; unsigned m_totalNumberOfStructEnregVars; unsigned m_addrExposed; unsigned m_VMNeedsStackAddr; unsigned m_localField; unsigned m_blockOp; unsigned m_dontEnregStructs; unsigned m_notRegSizeStruct; unsigned m_structArg; unsigned m_lclAddrNode; unsigned m_castTakesAddr; unsigned m_storeBlkSrc; unsigned m_oneAsgRetyping; unsigned m_swizzleArg; unsigned m_blockOpRet; unsigned m_returnSpCheck; unsigned m_simdUserForcesDep; unsigned m_liveInOutHndlr; unsigned m_depField; unsigned m_noRegVars; unsigned m_minOptsGC; #ifdef JIT32_GCENCODER unsigned m_PinningRef; #endif // JIT32_GCENCODER #if !defined(TARGET_64BIT) unsigned m_longParamField; #endif // !TARGET_64BIT unsigned m_parentExposed; unsigned m_tooConservative; unsigned m_escapeAddress; unsigned m_osrExposed; unsigned m_stressLclFld; unsigned m_copyFldByFld; unsigned m_dispatchRetBuf; unsigned m_wideIndir; public: void RecordLocal(const LclVarDsc* varDsc); void Dump(FILE* fout) const; }; static EnregisterStats s_enregisterStats; #endif // TRACK_ENREG_STATS bool compIsForImportOnly(); bool compIsForInlining() const; bool compDonotInline(); #ifdef DEBUG // Get the default fill char value we randomize this value when JitStress is enabled. static unsigned char compGetJitDefaultFill(Compiler* comp); const char* compLocalVarName(unsigned varNum, unsigned offs); VarName compVarName(regNumber reg, bool isFloatReg = false); const char* compRegVarName(regNumber reg, bool displayVar = false, bool isFloatReg = false); const char* compRegNameForSize(regNumber reg, size_t size); const char* compFPregVarName(unsigned fpReg, bool displayVar = false); void compDspSrcLinesByNativeIP(UNATIVE_OFFSET curIP); void compDspSrcLinesByLineNum(unsigned line, bool seek = false); #endif // DEBUG //------------------------------------------------------------------------- struct VarScopeListNode { VarScopeDsc* data; VarScopeListNode* next; static VarScopeListNode* Create(VarScopeDsc* value, CompAllocator alloc) { VarScopeListNode* node = new (alloc) VarScopeListNode; node->data = value; node->next = nullptr; return node; } }; struct VarScopeMapInfo { VarScopeListNode* head; VarScopeListNode* tail; static VarScopeMapInfo* Create(VarScopeListNode* node, CompAllocator alloc) { VarScopeMapInfo* info = new (alloc) VarScopeMapInfo; info->head = node; info->tail = node; return info; } }; // Max value of scope count for which we would use linear search; for larger values we would use hashtable lookup. static const unsigned MAX_LINEAR_FIND_LCL_SCOPELIST = 32; typedef JitHashTable<unsigned, JitSmallPrimitiveKeyFuncs<unsigned>, VarScopeMapInfo*> VarNumToScopeDscMap; // Map to keep variables' scope indexed by varNum containing it's scope dscs at the index. VarNumToScopeDscMap* compVarScopeMap; VarScopeDsc* compFindLocalVar(unsigned varNum, unsigned lifeBeg, unsigned lifeEnd); VarScopeDsc* compFindLocalVar(unsigned varNum, unsigned offs); VarScopeDsc* compFindLocalVarLinear(unsigned varNum, unsigned offs); void compInitVarScopeMap(); VarScopeDsc** compEnterScopeList; // List has the offsets where variables // enter scope, sorted by instr offset unsigned compNextEnterScope; VarScopeDsc** compExitScopeList; // List has the offsets where variables // go out of scope, sorted by instr offset unsigned compNextExitScope; void compInitScopeLists(); void compResetScopeLists(); VarScopeDsc* compGetNextEnterScope(unsigned offs, bool scan = false); VarScopeDsc* compGetNextExitScope(unsigned offs, bool scan = false); void compProcessScopesUntil(unsigned offset, VARSET_TP* inScope, void (Compiler::*enterScopeFn)(VARSET_TP* inScope, VarScopeDsc*), void (Compiler::*exitScopeFn)(VARSET_TP* inScope, VarScopeDsc*)); #ifdef DEBUG void compDispScopeLists(); #endif // DEBUG bool compIsProfilerHookNeeded(); //------------------------------------------------------------------------- /* Statistical Data Gathering */ void compJitStats(); // call this function and enable // various ifdef's below for statistical data #if CALL_ARG_STATS void compCallArgStats(); static void compDispCallArgStats(FILE* fout); #endif //------------------------------------------------------------------------- protected: #ifdef DEBUG bool skipMethod(); #endif ArenaAllocator* compArenaAllocator; public: void compFunctionTraceStart(); void compFunctionTraceEnd(void* methodCodePtr, ULONG methodCodeSize, bool isNYI); protected: size_t compMaxUncheckedOffsetForNullObject; void compInitOptions(JitFlags* compileFlags); void compSetProcessor(); void compInitDebuggingInfo(); void compSetOptimizationLevel(); #ifdef TARGET_ARMARCH bool compRsvdRegCheck(FrameLayoutState curState); #endif void compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFlags* compileFlags); // Clear annotations produced during optimizations; to be used between iterations when repeating opts. void ResetOptAnnotations(); // Regenerate loop descriptors; to be used between iterations when repeating opts. void RecomputeLoopInfo(); #ifdef PROFILING_SUPPORTED // Data required for generating profiler Enter/Leave/TailCall hooks bool compProfilerHookNeeded; // Whether profiler Enter/Leave/TailCall hook needs to be generated for the method void* compProfilerMethHnd; // Profiler handle of the method being compiled. Passed as param to ELT callbacks bool compProfilerMethHndIndirected; // Whether compProfilerHandle is pointer to the handle or is an actual handle #endif public: // Assumes called as part of process shutdown; does any compiler-specific work associated with that. static void ProcessShutdownWork(ICorStaticInfo* statInfo); CompAllocator getAllocator(CompMemKind cmk = CMK_Generic) { return CompAllocator(compArenaAllocator, cmk); } CompAllocator getAllocatorGC() { return getAllocator(CMK_GC); } CompAllocator getAllocatorLoopHoist() { return getAllocator(CMK_LoopHoist); } #ifdef DEBUG CompAllocator getAllocatorDebugOnly() { return getAllocator(CMK_DebugOnly); } #endif // DEBUG /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX typeInfo XX XX XX XX Checks for type compatibility and merges types XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ public: // Returns true if child is equal to or a subtype of parent for merge purposes // This support is necessary to suport attributes that are not described in // for example, signatures. For example, the permanent home byref (byref that // points to the gc heap), isn't a property of method signatures, therefore, // it is safe to have mismatches here (that tiCompatibleWith will not flag), // but when deciding if we need to reimport a block, we need to take these // in account bool tiMergeCompatibleWith(const typeInfo& pChild, const typeInfo& pParent, bool normalisedForStack) const; // Returns true if child is equal to or a subtype of parent. // normalisedForStack indicates that both types are normalised for the stack bool tiCompatibleWith(const typeInfo& pChild, const typeInfo& pParent, bool normalisedForStack) const; // Merges pDest and pSrc. Returns false if merge is undefined. // *pDest is modified to represent the merged type. Sets "*changed" to true // if this changes "*pDest". bool tiMergeToCommonParent(typeInfo* pDest, const typeInfo* pSrc, bool* changed) const; /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX IL verification stuff XX XX XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ public: // The following is used to track liveness of local variables, initialization // of valueclass constructors, and type safe use of IL instructions. // dynamic state info needed for verification EntryState verCurrentState; // this ptr of object type .ctors are considered intited only after // the base class ctor is called, or an alternate ctor is called. // An uninited this ptr can be used to access fields, but cannot // be used to call a member function. bool verTrackObjCtorInitState; void verInitBBEntryState(BasicBlock* block, EntryState* currentState); // Requires that "tis" is not TIS_Bottom -- it's a definite init/uninit state. void verSetThisInit(BasicBlock* block, ThisInitState tis); void verInitCurrentState(); void verResetCurrentState(BasicBlock* block, EntryState* currentState); // Merges the current verification state into the entry state of "block", return false if that merge fails, // TRUE if it succeeds. Further sets "*changed" to true if this changes the entry state of "block". bool verMergeEntryStates(BasicBlock* block, bool* changed); void verConvertBBToThrowVerificationException(BasicBlock* block DEBUGARG(bool logMsg)); void verHandleVerificationFailure(BasicBlock* block DEBUGARG(bool logMsg)); typeInfo verMakeTypeInfo(CORINFO_CLASS_HANDLE clsHnd, bool bashStructToRef = false); // converts from jit type representation to typeInfo typeInfo verMakeTypeInfo(CorInfoType ciType, CORINFO_CLASS_HANDLE clsHnd); // converts from jit type representation to typeInfo bool verIsSDArray(const typeInfo& ti); typeInfo verGetArrayElemType(const typeInfo& ti); typeInfo verParseArgSigToTypeInfo(CORINFO_SIG_INFO* sig, CORINFO_ARG_LIST_HANDLE args); bool verIsByRefLike(const typeInfo& ti); bool verIsSafeToReturnByRef(const typeInfo& ti); // generic type variables range over types that satisfy IsBoxable bool verIsBoxable(const typeInfo& ti); void DECLSPEC_NORETURN verRaiseVerifyException(INDEBUG(const char* reason) DEBUGARG(const char* file) DEBUGARG(unsigned line)); void verRaiseVerifyExceptionIfNeeded(INDEBUG(const char* reason) DEBUGARG(const char* file) DEBUGARG(unsigned line)); bool verCheckTailCallConstraint(OPCODE opcode, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken, // Is this a "constrained." call // on a type parameter? bool speculative // If true, won't throw if verificatoin fails. Instead it will // return false to the caller. // If false, it will throw. ); bool verIsBoxedValueType(const typeInfo& ti); void verVerifyCall(OPCODE opcode, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken, bool tailCall, bool readonlyCall, // is this a "readonly." call? const BYTE* delegateCreateStart, const BYTE* codeAddr, CORINFO_CALL_INFO* callInfo DEBUGARG(const char* methodName)); bool verCheckDelegateCreation(const BYTE* delegateCreateStart, const BYTE* codeAddr, mdMemberRef& targetMemberRef); typeInfo verVerifySTIND(const typeInfo& ptr, const typeInfo& value, const typeInfo& instrType); typeInfo verVerifyLDIND(const typeInfo& ptr, const typeInfo& instrType); void verVerifyField(CORINFO_RESOLVED_TOKEN* pResolvedToken, const CORINFO_FIELD_INFO& fieldInfo, const typeInfo* tiThis, bool mutator, bool allowPlainStructAsThis = false); void verVerifyCond(const typeInfo& tiOp1, const typeInfo& tiOp2, unsigned opcode); void verVerifyThisPtrInitialised(); bool verIsCallToInitThisPtr(CORINFO_CLASS_HANDLE context, CORINFO_CLASS_HANDLE target); #ifdef DEBUG // One line log function. Default level is 0. Increasing it gives you // more log information // levels are currently unused: #define JITDUMP(level,...) (); void JitLogEE(unsigned level, const char* fmt, ...); bool compDebugBreak; bool compJitHaltMethod(); #endif /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX GS Security checks for unsafe buffers XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ public: struct ShadowParamVarInfo { FixedBitVect* assignGroup; // the closure set of variables whose values depend on each other unsigned shadowCopy; // Lcl var num, if not valid set to BAD_VAR_NUM static bool mayNeedShadowCopy(LclVarDsc* varDsc) { #if defined(TARGET_AMD64) // GS cookie logic to create shadow slots, create trees to copy reg args to shadow // slots and update all trees to refer to shadow slots is done immediately after // fgMorph(). Lsra could potentially mark a param as DoNotEnregister after JIT determines // not to shadow a parameter. Also, LSRA could potentially spill a param which is passed // in register. Therefore, conservatively all params may need a shadow copy. Note that // GS cookie logic further checks whether the param is a ptr or an unsafe buffer before // creating a shadow slot even though this routine returns true. // // TODO-AMD64-CQ: Revisit this conservative approach as it could create more shadow slots than // required. There are two cases under which a reg arg could potentially be used from its // home location: // a) LSRA marks it as DoNotEnregister (see LinearScan::identifyCandidates()) // b) LSRA spills it // // Possible solution to address case (a) // - The conditions under which LSRA marks a varDsc as DoNotEnregister could be checked // in this routine. Note that live out of exception handler is something we may not be // able to do it here since GS cookie logic is invoked ahead of liveness computation. // Therefore, for methods with exception handling and need GS cookie check we might have // to take conservative approach. // // Possible solution to address case (b) // - Whenver a parameter passed in an argument register needs to be spilled by LSRA, we // create a new spill temp if the method needs GS cookie check. return varDsc->lvIsParam; #else // !defined(TARGET_AMD64) return varDsc->lvIsParam && !varDsc->lvIsRegArg; #endif } #ifdef DEBUG void Print() { printf("assignGroup [%p]; shadowCopy: [%d];\n", assignGroup, shadowCopy); } #endif }; GSCookie* gsGlobalSecurityCookieAddr; // Address of global cookie for unsafe buffer checks GSCookie gsGlobalSecurityCookieVal; // Value of global cookie if addr is NULL ShadowParamVarInfo* gsShadowVarInfo; // Table used by shadow param analysis code void gsGSChecksInitCookie(); // Grabs cookie variable void gsCopyShadowParams(); // Identify vulnerable params and create dhadow copies bool gsFindVulnerableParams(); // Shadow param analysis code void gsParamsToShadows(); // Insert copy code and replave param uses by shadow static fgWalkPreFn gsMarkPtrsAndAssignGroups; // Shadow param analysis tree-walk static fgWalkPreFn gsReplaceShadowParams; // Shadow param replacement tree-walk #define DEFAULT_MAX_INLINE_SIZE 100 // Methods with > DEFAULT_MAX_INLINE_SIZE IL bytes will never be inlined. // This can be overwritten by setting complus_JITInlineSize env variable. #define DEFAULT_MAX_INLINE_DEPTH 20 // Methods at more than this level deep will not be inlined #define DEFAULT_MAX_LOCALLOC_TO_LOCAL_SIZE 32 // fixed locallocs of this size or smaller will convert to local buffers private: #ifdef FEATURE_JIT_METHOD_PERF JitTimer* pCompJitTimer; // Timer data structure (by phases) for current compilation. static CompTimeSummaryInfo s_compJitTimerSummary; // Summary of the Timer information for the whole run. static LPCWSTR JitTimeLogCsv(); // Retrieve the file name for CSV from ConfigDWORD. static LPCWSTR compJitTimeLogFilename; // If a log file for JIT time is desired, filename to write it to. #endif void BeginPhase(Phases phase); // Indicate the start of the given phase. void EndPhase(Phases phase); // Indicate the end of the given phase. #if MEASURE_CLRAPI_CALLS // Thin wrappers that call into JitTimer (if present). inline void CLRApiCallEnter(unsigned apix); inline void CLRApiCallLeave(unsigned apix); public: inline void CLR_API_Enter(API_ICorJitInfo_Names ename); inline void CLR_API_Leave(API_ICorJitInfo_Names ename); private: #endif #if defined(DEBUG) || defined(INLINE_DATA) // These variables are associated with maintaining SQM data about compile time. unsigned __int64 m_compCyclesAtEndOfInlining; // The thread-virtualized cycle count at the end of the inlining phase // in the current compilation. unsigned __int64 m_compCycles; // Net cycle count for current compilation DWORD m_compTickCountAtEndOfInlining; // The result of GetTickCount() (# ms since some epoch marker) at the end of // the inlining phase in the current compilation. #endif // defined(DEBUG) || defined(INLINE_DATA) // Records the SQM-relevant (cycles and tick count). Should be called after inlining is complete. // (We do this after inlining because this marks the last point at which the JIT is likely to cause // type-loading and class initialization). void RecordStateAtEndOfInlining(); // Assumes being called at the end of compilation. Update the SQM state. void RecordStateAtEndOfCompilation(); public: #if FUNC_INFO_LOGGING static LPCWSTR compJitFuncInfoFilename; // If a log file for per-function information is required, this is the // filename to write it to. static FILE* compJitFuncInfoFile; // And this is the actual FILE* to write to. #endif // FUNC_INFO_LOGGING Compiler* prevCompiler; // Previous compiler on stack for TLS Compiler* linked list for reentrant compilers. #if MEASURE_NOWAY void RecordNowayAssert(const char* filename, unsigned line, const char* condStr); #endif // MEASURE_NOWAY #ifndef FEATURE_TRACELOGGING // Should we actually fire the noway assert body and the exception handler? bool compShouldThrowOnNoway(); #else // FEATURE_TRACELOGGING // Should we actually fire the noway assert body and the exception handler? bool compShouldThrowOnNoway(const char* filename, unsigned line); // Telemetry instance to use per method compilation. JitTelemetry compJitTelemetry; // Get common parameters that have to be logged with most telemetry data. void compGetTelemetryDefaults(const char** assemblyName, const char** scopeName, const char** methodName, unsigned* methodHash); #endif // !FEATURE_TRACELOGGING #ifdef DEBUG private: NodeToTestDataMap* m_nodeTestData; static const unsigned FIRST_LOOP_HOIST_CSE_CLASS = 1000; unsigned m_loopHoistCSEClass; // LoopHoist test annotations turn into CSE requirements; we // label them with CSE Class #'s starting at FIRST_LOOP_HOIST_CSE_CLASS. // Current kept in this. public: NodeToTestDataMap* GetNodeTestData() { Compiler* compRoot = impInlineRoot(); if (compRoot->m_nodeTestData == nullptr) { compRoot->m_nodeTestData = new (getAllocatorDebugOnly()) NodeToTestDataMap(getAllocatorDebugOnly()); } return compRoot->m_nodeTestData; } typedef JitHashTable<GenTree*, JitPtrKeyFuncs<GenTree>, int> NodeToIntMap; // Returns the set (i.e., the domain of the result map) of nodes that are keys in m_nodeTestData, and // currently occur in the AST graph. NodeToIntMap* FindReachableNodesInNodeTestData(); // Node "from" is being eliminated, and being replaced by node "to". If "from" had any associated // test data, associate that data with "to". void TransferTestDataToNode(GenTree* from, GenTree* to); // These are the methods that test that the various conditions implied by the // test attributes are satisfied. void JitTestCheckSSA(); // SSA builder tests. void JitTestCheckVN(); // Value numbering tests. #endif // DEBUG // The "FieldSeqStore", for canonicalizing field sequences. See the definition of FieldSeqStore for // operations. FieldSeqStore* m_fieldSeqStore; FieldSeqStore* GetFieldSeqStore() { Compiler* compRoot = impInlineRoot(); if (compRoot->m_fieldSeqStore == nullptr) { // Create a CompAllocator that labels sub-structure with CMK_FieldSeqStore, and use that for allocation. CompAllocator ialloc(getAllocator(CMK_FieldSeqStore)); compRoot->m_fieldSeqStore = new (ialloc) FieldSeqStore(ialloc); } return compRoot->m_fieldSeqStore; } typedef JitHashTable<GenTree*, JitPtrKeyFuncs<GenTree>, FieldSeqNode*> NodeToFieldSeqMap; // Some nodes of "TYP_BYREF" or "TYP_I_IMPL" actually represent the address of a field within a struct, but since // the offset of the field is zero, there's no "GT_ADD" node. We normally attach a field sequence to the constant // that is added, but what do we do when that constant is zero, and is thus not present? We use this mechanism to // attach the field sequence directly to the address node. NodeToFieldSeqMap* m_zeroOffsetFieldMap; NodeToFieldSeqMap* GetZeroOffsetFieldMap() { // Don't need to worry about inlining here if (m_zeroOffsetFieldMap == nullptr) { // Create a CompAllocator that labels sub-structure with CMK_ZeroOffsetFieldMap, and use that for // allocation. CompAllocator ialloc(getAllocator(CMK_ZeroOffsetFieldMap)); m_zeroOffsetFieldMap = new (ialloc) NodeToFieldSeqMap(ialloc); } return m_zeroOffsetFieldMap; } // Requires that "op1" is a node of type "TYP_BYREF" or "TYP_I_IMPL". We are dereferencing this with the fields in // "fieldSeq", whose offsets are required all to be zero. Ensures that any field sequence annotation currently on // "op1" or its components is augmented by appending "fieldSeq". In practice, if "op1" is a GT_LCL_FLD, it has // a field sequence as a member; otherwise, it may be the addition of an a byref and a constant, where the const // has a field sequence -- in this case "fieldSeq" is appended to that of the constant; otherwise, we // record the the field sequence using the ZeroOffsetFieldMap described above. // // One exception above is that "op1" is a node of type "TYP_REF" where "op1" is a GT_LCL_VAR. // This happens when System.Object vtable pointer is a regular field at offset 0 in System.Private.CoreLib in // CoreRT. Such case is handled same as the default case. void fgAddFieldSeqForZeroOffset(GenTree* op1, FieldSeqNode* fieldSeq); typedef JitHashTable<const GenTree*, JitPtrKeyFuncs<GenTree>, ArrayInfo> NodeToArrayInfoMap; NodeToArrayInfoMap* m_arrayInfoMap; NodeToArrayInfoMap* GetArrayInfoMap() { Compiler* compRoot = impInlineRoot(); if (compRoot->m_arrayInfoMap == nullptr) { // Create a CompAllocator that labels sub-structure with CMK_ArrayInfoMap, and use that for allocation. CompAllocator ialloc(getAllocator(CMK_ArrayInfoMap)); compRoot->m_arrayInfoMap = new (ialloc) NodeToArrayInfoMap(ialloc); } return compRoot->m_arrayInfoMap; } //----------------------------------------------------------------------------------------------------------------- // Compiler::TryGetArrayInfo: // Given an indirection node, checks to see whether or not that indirection represents an array access, and // if so returns information about the array. // // Arguments: // indir - The `GT_IND` node. // arrayInfo (out) - Information about the accessed array if this function returns true. Undefined otherwise. // // Returns: // True if the `GT_IND` node represents an array access; false otherwise. bool TryGetArrayInfo(GenTreeIndir* indir, ArrayInfo* arrayInfo) { if ((indir->gtFlags & GTF_IND_ARR_INDEX) == 0) { return false; } if (indir->gtOp1->OperIs(GT_INDEX_ADDR)) { GenTreeIndexAddr* const indexAddr = indir->gtOp1->AsIndexAddr(); *arrayInfo = ArrayInfo(indexAddr->gtElemType, indexAddr->gtElemSize, indexAddr->gtElemOffset, indexAddr->gtStructElemClass); return true; } bool found = GetArrayInfoMap()->Lookup(indir, arrayInfo); assert(found); return true; } NodeToUnsignedMap* m_memorySsaMap[MemoryKindCount]; // In some cases, we want to assign intermediate SSA #'s to memory states, and know what nodes create those memory // states. (We do this for try blocks, where, if the try block doesn't do a call that loses track of the memory // state, all the possible memory states are possible initial states of the corresponding catch block(s).) NodeToUnsignedMap* GetMemorySsaMap(MemoryKind memoryKind) { if (memoryKind == GcHeap && byrefStatesMatchGcHeapStates) { // Use the same map for GCHeap and ByrefExposed when their states match. memoryKind = ByrefExposed; } assert(memoryKind < MemoryKindCount); Compiler* compRoot = impInlineRoot(); if (compRoot->m_memorySsaMap[memoryKind] == nullptr) { // Create a CompAllocator that labels sub-structure with CMK_ArrayInfoMap, and use that for allocation. CompAllocator ialloc(getAllocator(CMK_ArrayInfoMap)); compRoot->m_memorySsaMap[memoryKind] = new (ialloc) NodeToUnsignedMap(ialloc); } return compRoot->m_memorySsaMap[memoryKind]; } // The Refany type is the only struct type whose structure is implicitly assumed by IL. We need its fields. CORINFO_CLASS_HANDLE m_refAnyClass; CORINFO_FIELD_HANDLE GetRefanyDataField() { if (m_refAnyClass == nullptr) { m_refAnyClass = info.compCompHnd->getBuiltinClass(CLASSID_TYPED_BYREF); } return info.compCompHnd->getFieldInClass(m_refAnyClass, 0); } CORINFO_FIELD_HANDLE GetRefanyTypeField() { if (m_refAnyClass == nullptr) { m_refAnyClass = info.compCompHnd->getBuiltinClass(CLASSID_TYPED_BYREF); } return info.compCompHnd->getFieldInClass(m_refAnyClass, 1); } #if VARSET_COUNTOPS static BitSetSupport::BitSetOpCounter m_varsetOpCounter; #endif #if ALLVARSET_COUNTOPS static BitSetSupport::BitSetOpCounter m_allvarsetOpCounter; #endif static HelperCallProperties s_helperCallProperties; #ifdef UNIX_AMD64_ABI static var_types GetTypeFromClassificationAndSizes(SystemVClassificationType classType, int size); static var_types GetEightByteType(const SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR& structDesc, unsigned slotNum); static void GetStructTypeOffset(const SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR& structDesc, var_types* type0, var_types* type1, unsigned __int8* offset0, unsigned __int8* offset1); void GetStructTypeOffset(CORINFO_CLASS_HANDLE typeHnd, var_types* type0, var_types* type1, unsigned __int8* offset0, unsigned __int8* offset1); #endif // defined(UNIX_AMD64_ABI) void fgMorphMultiregStructArgs(GenTreeCall* call); GenTree* fgMorphMultiregStructArg(GenTree* arg, fgArgTabEntry* fgEntryPtr); bool killGCRefs(GenTree* tree); }; // end of class Compiler //--------------------------------------------------------------------------------------------------------------------- // GenTreeVisitor: a flexible tree walker implemented using the curiously-recurring-template pattern. // // This class implements a configurable walker for IR trees. There are five configuration options (defaults values are // shown in parentheses): // // - ComputeStack (false): when true, the walker will push each node onto the `m_ancestors` stack. "Ancestors" is a bit // of a misnomer, as the first entry will always be the current node. // // - DoPreOrder (false): when true, the walker will invoke `TVisitor::PreOrderVisit` with the current node as an // argument before visiting the node's operands. // // - DoPostOrder (false): when true, the walker will invoke `TVisitor::PostOrderVisit` with the current node as an // argument after visiting the node's operands. // // - DoLclVarsOnly (false): when true, the walker will only invoke `TVisitor::PreOrderVisit` for lclVar nodes. // `DoPreOrder` must be true if this option is true. // // - UseExecutionOrder (false): when true, then walker will visit a node's operands in execution order (e.g. if a // binary operator has the `GTF_REVERSE_OPS` flag set, the second operand will be // visited before the first). // // At least one of `DoPreOrder` and `DoPostOrder` must be specified. // // A simple pre-order visitor might look something like the following: // // class CountingVisitor final : public GenTreeVisitor<CountingVisitor> // { // public: // enum // { // DoPreOrder = true // }; // // unsigned m_count; // // CountingVisitor(Compiler* compiler) // : GenTreeVisitor<CountingVisitor>(compiler), m_count(0) // { // } // // Compiler::fgWalkResult PreOrderVisit(GenTree* node) // { // m_count++; // } // }; // // This visitor would then be used like so: // // CountingVisitor countingVisitor(compiler); // countingVisitor.WalkTree(root); // template <typename TVisitor> class GenTreeVisitor { protected: typedef Compiler::fgWalkResult fgWalkResult; enum { ComputeStack = false, DoPreOrder = false, DoPostOrder = false, DoLclVarsOnly = false, UseExecutionOrder = false, }; Compiler* m_compiler; ArrayStack<GenTree*> m_ancestors; GenTreeVisitor(Compiler* compiler) : m_compiler(compiler), m_ancestors(compiler->getAllocator(CMK_ArrayStack)) { assert(compiler != nullptr); static_assert_no_msg(TVisitor::DoPreOrder || TVisitor::DoPostOrder); static_assert_no_msg(!TVisitor::DoLclVarsOnly || TVisitor::DoPreOrder); } fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { return fgWalkResult::WALK_CONTINUE; } fgWalkResult PostOrderVisit(GenTree** use, GenTree* user) { return fgWalkResult::WALK_CONTINUE; } public: fgWalkResult WalkTree(GenTree** use, GenTree* user) { assert(use != nullptr); GenTree* node = *use; if (TVisitor::ComputeStack) { m_ancestors.Push(node); } fgWalkResult result = fgWalkResult::WALK_CONTINUE; if (TVisitor::DoPreOrder && !TVisitor::DoLclVarsOnly) { result = reinterpret_cast<TVisitor*>(this)->PreOrderVisit(use, user); if (result == fgWalkResult::WALK_ABORT) { return result; } node = *use; if ((node == nullptr) || (result == fgWalkResult::WALK_SKIP_SUBTREES)) { goto DONE; } } switch (node->OperGet()) { // Leaf lclVars case GT_LCL_VAR: case GT_LCL_FLD: case GT_LCL_VAR_ADDR: case GT_LCL_FLD_ADDR: if (TVisitor::DoLclVarsOnly) { result = reinterpret_cast<TVisitor*>(this)->PreOrderVisit(use, user); if (result == fgWalkResult::WALK_ABORT) { return result; } } FALLTHROUGH; // Leaf nodes case GT_CATCH_ARG: case GT_LABEL: case GT_FTN_ADDR: case GT_RET_EXPR: case GT_CNS_INT: case GT_CNS_LNG: case GT_CNS_DBL: case GT_CNS_STR: case GT_MEMORYBARRIER: case GT_JMP: case GT_JCC: case GT_SETCC: case GT_NO_OP: case GT_START_NONGC: case GT_START_PREEMPTGC: case GT_PROF_HOOK: #if !defined(FEATURE_EH_FUNCLETS) case GT_END_LFIN: #endif // !FEATURE_EH_FUNCLETS case GT_PHI_ARG: case GT_JMPTABLE: case GT_CLS_VAR: case GT_CLS_VAR_ADDR: case GT_ARGPLACE: case GT_PHYSREG: case GT_EMITNOP: case GT_PINVOKE_PROLOG: case GT_PINVOKE_EPILOG: case GT_IL_OFFSET: break; // Lclvar unary operators case GT_STORE_LCL_VAR: case GT_STORE_LCL_FLD: if (TVisitor::DoLclVarsOnly) { result = reinterpret_cast<TVisitor*>(this)->PreOrderVisit(use, user); if (result == fgWalkResult::WALK_ABORT) { return result; } } FALLTHROUGH; // Standard unary operators case GT_NOT: case GT_NEG: case GT_BSWAP: case GT_BSWAP16: case GT_COPY: case GT_RELOAD: case GT_ARR_LENGTH: case GT_CAST: case GT_BITCAST: case GT_CKFINITE: case GT_LCLHEAP: case GT_ADDR: case GT_IND: case GT_OBJ: case GT_BLK: case GT_BOX: case GT_ALLOCOBJ: case GT_INIT_VAL: case GT_JTRUE: case GT_SWITCH: case GT_NULLCHECK: case GT_PUTARG_REG: case GT_PUTARG_STK: case GT_PUTARG_TYPE: case GT_RETURNTRAP: case GT_NOP: case GT_FIELD: case GT_RETURN: case GT_RETFILT: case GT_RUNTIMELOOKUP: case GT_KEEPALIVE: case GT_INC_SATURATE: { GenTreeUnOp* const unOp = node->AsUnOp(); if (unOp->gtOp1 != nullptr) { result = WalkTree(&unOp->gtOp1, unOp); if (result == fgWalkResult::WALK_ABORT) { return result; } } break; } // Special nodes case GT_PHI: for (GenTreePhi::Use& use : node->AsPhi()->Uses()) { result = WalkTree(&use.NodeRef(), node); if (result == fgWalkResult::WALK_ABORT) { return result; } } break; case GT_FIELD_LIST: for (GenTreeFieldList::Use& use : node->AsFieldList()->Uses()) { result = WalkTree(&use.NodeRef(), node); if (result == fgWalkResult::WALK_ABORT) { return result; } } break; case GT_CMPXCHG: { GenTreeCmpXchg* const cmpXchg = node->AsCmpXchg(); result = WalkTree(&cmpXchg->gtOpLocation, cmpXchg); if (result == fgWalkResult::WALK_ABORT) { return result; } result = WalkTree(&cmpXchg->gtOpValue, cmpXchg); if (result == fgWalkResult::WALK_ABORT) { return result; } result = WalkTree(&cmpXchg->gtOpComparand, cmpXchg); if (result == fgWalkResult::WALK_ABORT) { return result; } break; } case GT_ARR_ELEM: { GenTreeArrElem* const arrElem = node->AsArrElem(); result = WalkTree(&arrElem->gtArrObj, arrElem); if (result == fgWalkResult::WALK_ABORT) { return result; } const unsigned rank = arrElem->gtArrRank; for (unsigned dim = 0; dim < rank; dim++) { result = WalkTree(&arrElem->gtArrInds[dim], arrElem); if (result == fgWalkResult::WALK_ABORT) { return result; } } break; } case GT_ARR_OFFSET: { GenTreeArrOffs* const arrOffs = node->AsArrOffs(); result = WalkTree(&arrOffs->gtOffset, arrOffs); if (result == fgWalkResult::WALK_ABORT) { return result; } result = WalkTree(&arrOffs->gtIndex, arrOffs); if (result == fgWalkResult::WALK_ABORT) { return result; } result = WalkTree(&arrOffs->gtArrObj, arrOffs); if (result == fgWalkResult::WALK_ABORT) { return result; } break; } case GT_STORE_DYN_BLK: { GenTreeStoreDynBlk* const dynBlock = node->AsStoreDynBlk(); GenTree** op1Use = &dynBlock->gtOp1; GenTree** op2Use = &dynBlock->gtOp2; GenTree** op3Use = &dynBlock->gtDynamicSize; result = WalkTree(op1Use, dynBlock); if (result == fgWalkResult::WALK_ABORT) { return result; } result = WalkTree(op2Use, dynBlock); if (result == fgWalkResult::WALK_ABORT) { return result; } result = WalkTree(op3Use, dynBlock); if (result == fgWalkResult::WALK_ABORT) { return result; } break; } case GT_CALL: { GenTreeCall* const call = node->AsCall(); if (call->gtCallThisArg != nullptr) { result = WalkTree(&call->gtCallThisArg->NodeRef(), call); if (result == fgWalkResult::WALK_ABORT) { return result; } } for (GenTreeCall::Use& use : call->Args()) { result = WalkTree(&use.NodeRef(), call); if (result == fgWalkResult::WALK_ABORT) { return result; } } for (GenTreeCall::Use& use : call->LateArgs()) { result = WalkTree(&use.NodeRef(), call); if (result == fgWalkResult::WALK_ABORT) { return result; } } if (call->gtCallType == CT_INDIRECT) { if (call->gtCallCookie != nullptr) { result = WalkTree(&call->gtCallCookie, call); if (result == fgWalkResult::WALK_ABORT) { return result; } } result = WalkTree(&call->gtCallAddr, call); if (result == fgWalkResult::WALK_ABORT) { return result; } } if (call->gtControlExpr != nullptr) { result = WalkTree(&call->gtControlExpr, call); if (result == fgWalkResult::WALK_ABORT) { return result; } } break; } #if defined(FEATURE_SIMD) || defined(FEATURE_HW_INTRINSICS) #if defined(FEATURE_SIMD) case GT_SIMD: #endif #if defined(FEATURE_HW_INTRINSICS) case GT_HWINTRINSIC: #endif if (TVisitor::UseExecutionOrder && node->IsReverseOp()) { assert(node->AsMultiOp()->GetOperandCount() == 2); result = WalkTree(&node->AsMultiOp()->Op(2), node); if (result == fgWalkResult::WALK_ABORT) { return result; } result = WalkTree(&node->AsMultiOp()->Op(1), node); if (result == fgWalkResult::WALK_ABORT) { return result; } } else { for (GenTree** use : node->AsMultiOp()->UseEdges()) { result = WalkTree(use, node); if (result == fgWalkResult::WALK_ABORT) { return result; } } } break; #endif // defined(FEATURE_SIMD) || defined(FEATURE_HW_INTRINSICS) // Binary nodes default: { assert(node->OperIsBinary()); GenTreeOp* const op = node->AsOp(); GenTree** op1Use = &op->gtOp1; GenTree** op2Use = &op->gtOp2; if (TVisitor::UseExecutionOrder && node->IsReverseOp()) { std::swap(op1Use, op2Use); } if (*op1Use != nullptr) { result = WalkTree(op1Use, op); if (result == fgWalkResult::WALK_ABORT) { return result; } } if (*op2Use != nullptr) { result = WalkTree(op2Use, op); if (result == fgWalkResult::WALK_ABORT) { return result; } } break; } } DONE: // Finally, visit the current node if (TVisitor::DoPostOrder) { result = reinterpret_cast<TVisitor*>(this)->PostOrderVisit(use, user); } if (TVisitor::ComputeStack) { m_ancestors.Pop(); } return result; } }; template <bool computeStack, bool doPreOrder, bool doPostOrder, bool doLclVarsOnly, bool useExecutionOrder> class GenericTreeWalker final : public GenTreeVisitor<GenericTreeWalker<computeStack, doPreOrder, doPostOrder, doLclVarsOnly, useExecutionOrder>> { public: enum { ComputeStack = computeStack, DoPreOrder = doPreOrder, DoPostOrder = doPostOrder, DoLclVarsOnly = doLclVarsOnly, UseExecutionOrder = useExecutionOrder, }; private: Compiler::fgWalkData* m_walkData; public: GenericTreeWalker(Compiler::fgWalkData* walkData) : GenTreeVisitor<GenericTreeWalker<computeStack, doPreOrder, doPostOrder, doLclVarsOnly, useExecutionOrder>>( walkData->compiler) , m_walkData(walkData) { assert(walkData != nullptr); if (computeStack) { walkData->parentStack = &this->m_ancestors; } } Compiler::fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { m_walkData->parent = user; return m_walkData->wtprVisitorFn(use, m_walkData); } Compiler::fgWalkResult PostOrderVisit(GenTree** use, GenTree* user) { m_walkData->parent = user; return m_walkData->wtpoVisitorFn(use, m_walkData); } }; // A dominator tree visitor implemented using the curiously-recurring-template pattern, similar to GenTreeVisitor. template <typename TVisitor> class DomTreeVisitor { protected: Compiler* const m_compiler; DomTreeNode* const m_domTree; DomTreeVisitor(Compiler* compiler, DomTreeNode* domTree) : m_compiler(compiler), m_domTree(domTree) { } void Begin() { } void PreOrderVisit(BasicBlock* block) { } void PostOrderVisit(BasicBlock* block) { } void End() { } public: //------------------------------------------------------------------------ // WalkTree: Walk the dominator tree, starting from fgFirstBB. // // Notes: // This performs a non-recursive, non-allocating walk of the tree by using // DomTreeNode's firstChild and nextSibling links to locate the children of // a node and BasicBlock's bbIDom parent link to go back up the tree when // no more children are left. // // Forests are also supported, provided that all the roots are chained via // DomTreeNode::nextSibling to fgFirstBB. // void WalkTree() { static_cast<TVisitor*>(this)->Begin(); for (BasicBlock *next, *block = m_compiler->fgFirstBB; block != nullptr; block = next) { static_cast<TVisitor*>(this)->PreOrderVisit(block); next = m_domTree[block->bbNum].firstChild; if (next != nullptr) { assert(next->bbIDom == block); continue; } do { static_cast<TVisitor*>(this)->PostOrderVisit(block); next = m_domTree[block->bbNum].nextSibling; if (next != nullptr) { assert(next->bbIDom == block->bbIDom); break; } block = block->bbIDom; } while (block != nullptr); } static_cast<TVisitor*>(this)->End(); } }; // EHClauses: adapter class for forward iteration of the exception handling table using range-based `for`, e.g.: // for (EHblkDsc* const ehDsc : EHClauses(compiler)) // class EHClauses { EHblkDsc* m_begin; EHblkDsc* m_end; // Forward iterator for the exception handling table entries. Iteration is in table order. // class iterator { EHblkDsc* m_ehDsc; public: iterator(EHblkDsc* ehDsc) : m_ehDsc(ehDsc) { } EHblkDsc* operator*() const { return m_ehDsc; } iterator& operator++() { ++m_ehDsc; return *this; } bool operator!=(const iterator& i) const { return m_ehDsc != i.m_ehDsc; } }; public: EHClauses(Compiler* comp) : m_begin(comp->compHndBBtab), m_end(comp->compHndBBtab + comp->compHndBBtabCount) { assert((m_begin != nullptr) || (m_begin == m_end)); } iterator begin() const { return iterator(m_begin); } iterator end() const { return iterator(m_end); } }; /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX Miscellaneous Compiler stuff XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ // Values used to mark the types a stack slot is used for const unsigned TYPE_REF_INT = 0x01; // slot used as a 32-bit int const unsigned TYPE_REF_LNG = 0x02; // slot used as a 64-bit long const unsigned TYPE_REF_FLT = 0x04; // slot used as a 32-bit float const unsigned TYPE_REF_DBL = 0x08; // slot used as a 64-bit float const unsigned TYPE_REF_PTR = 0x10; // slot used as a 32-bit pointer const unsigned TYPE_REF_BYR = 0x20; // slot used as a byref pointer const unsigned TYPE_REF_STC = 0x40; // slot used as a struct const unsigned TYPE_REF_TYPEMASK = 0x7F; // bits that represent the type // const unsigned TYPE_REF_ADDR_TAKEN = 0x80; // slots address was taken /***************************************************************************** * * Variables to keep track of total code amounts. */ #if DISPLAY_SIZES extern size_t grossVMsize; extern size_t grossNCsize; extern size_t totalNCsize; extern unsigned genMethodICnt; extern unsigned genMethodNCnt; extern size_t gcHeaderISize; extern size_t gcPtrMapISize; extern size_t gcHeaderNSize; extern size_t gcPtrMapNSize; #endif // DISPLAY_SIZES /***************************************************************************** * * Variables to keep track of basic block counts (more data on 1 BB methods) */ #if COUNT_BASIC_BLOCKS extern Histogram bbCntTable; extern Histogram bbOneBBSizeTable; #endif /***************************************************************************** * * Used by optFindNaturalLoops to gather statistical information such as * - total number of natural loops * - number of loops with 1, 2, ... exit conditions * - number of loops that have an iterator (for like) * - number of loops that have a constant iterator */ #if COUNT_LOOPS extern unsigned totalLoopMethods; // counts the total number of methods that have natural loops extern unsigned maxLoopsPerMethod; // counts the maximum number of loops a method has extern unsigned totalLoopOverflows; // # of methods that identified more loops than we can represent extern unsigned totalLoopCount; // counts the total number of natural loops extern unsigned totalUnnatLoopCount; // counts the total number of (not-necessarily natural) loops extern unsigned totalUnnatLoopOverflows; // # of methods that identified more unnatural loops than we can represent extern unsigned iterLoopCount; // counts the # of loops with an iterator (for like) extern unsigned simpleTestLoopCount; // counts the # of loops with an iterator and a simple loop condition (iter < // const) extern unsigned constIterLoopCount; // counts the # of loops with a constant iterator (for like) extern bool hasMethodLoops; // flag to keep track if we already counted a method as having loops extern unsigned loopsThisMethod; // counts the number of loops in the current method extern bool loopOverflowThisMethod; // True if we exceeded the max # of loops in the method. extern Histogram loopCountTable; // Histogram of loop counts extern Histogram loopExitCountTable; // Histogram of loop exit counts #endif // COUNT_LOOPS /***************************************************************************** * variables to keep track of how many iterations we go in a dataflow pass */ #if DATAFLOW_ITER extern unsigned CSEiterCount; // counts the # of iteration for the CSE dataflow extern unsigned CFiterCount; // counts the # of iteration for the Const Folding dataflow #endif // DATAFLOW_ITER #if MEASURE_BLOCK_SIZE extern size_t genFlowNodeSize; extern size_t genFlowNodeCnt; #endif // MEASURE_BLOCK_SIZE #if MEASURE_NODE_SIZE struct NodeSizeStats { void Init() { genTreeNodeCnt = 0; genTreeNodeSize = 0; genTreeNodeActualSize = 0; } // Count of tree nodes allocated. unsigned __int64 genTreeNodeCnt; // The size we allocate. unsigned __int64 genTreeNodeSize; // The actual size of the node. Note that the actual size will likely be smaller // than the allocated size, but we sometimes use SetOper()/ChangeOper() to change // a smaller node to a larger one. TODO-Cleanup: add stats on // SetOper()/ChangeOper() usage to quantify this. unsigned __int64 genTreeNodeActualSize; }; extern NodeSizeStats genNodeSizeStats; // Total node size stats extern NodeSizeStats genNodeSizeStatsPerFunc; // Per-function node size stats extern Histogram genTreeNcntHist; extern Histogram genTreeNsizHist; #endif // MEASURE_NODE_SIZE /***************************************************************************** * Count fatal errors (including noway_asserts). */ #if MEASURE_FATAL extern unsigned fatal_badCode; extern unsigned fatal_noWay; extern unsigned fatal_implLimitation; extern unsigned fatal_NOMEM; extern unsigned fatal_noWayAssertBody; #ifdef DEBUG extern unsigned fatal_noWayAssertBodyArgs; #endif // DEBUG extern unsigned fatal_NYI; #endif // MEASURE_FATAL /***************************************************************************** * Codegen */ #ifdef TARGET_XARCH const instruction INS_SHIFT_LEFT_LOGICAL = INS_shl; const instruction INS_SHIFT_RIGHT_LOGICAL = INS_shr; const instruction INS_SHIFT_RIGHT_ARITHM = INS_sar; const instruction INS_AND = INS_and; const instruction INS_OR = INS_or; const instruction INS_XOR = INS_xor; const instruction INS_NEG = INS_neg; const instruction INS_TEST = INS_test; const instruction INS_MUL = INS_imul; const instruction INS_SIGNED_DIVIDE = INS_idiv; const instruction INS_UNSIGNED_DIVIDE = INS_div; const instruction INS_BREAKPOINT = INS_int3; const instruction INS_ADDC = INS_adc; const instruction INS_SUBC = INS_sbb; const instruction INS_NOT = INS_not; #endif // TARGET_XARCH #ifdef TARGET_ARM const instruction INS_SHIFT_LEFT_LOGICAL = INS_lsl; const instruction INS_SHIFT_RIGHT_LOGICAL = INS_lsr; const instruction INS_SHIFT_RIGHT_ARITHM = INS_asr; const instruction INS_AND = INS_and; const instruction INS_OR = INS_orr; const instruction INS_XOR = INS_eor; const instruction INS_NEG = INS_rsb; const instruction INS_TEST = INS_tst; const instruction INS_MUL = INS_mul; const instruction INS_MULADD = INS_mla; const instruction INS_SIGNED_DIVIDE = INS_sdiv; const instruction INS_UNSIGNED_DIVIDE = INS_udiv; const instruction INS_BREAKPOINT = INS_bkpt; const instruction INS_ADDC = INS_adc; const instruction INS_SUBC = INS_sbc; const instruction INS_NOT = INS_mvn; const instruction INS_ABS = INS_vabs; const instruction INS_SQRT = INS_vsqrt; #endif // TARGET_ARM #ifdef TARGET_ARM64 const instruction INS_MULADD = INS_madd; inline const instruction INS_BREAKPOINT_osHelper() { // GDB needs the encoding of brk #0 // Windbg needs the encoding of brk #F000 return TargetOS::IsUnix ? INS_brk_unix : INS_brk_windows; } #define INS_BREAKPOINT INS_BREAKPOINT_osHelper() const instruction INS_ABS = INS_fabs; const instruction INS_SQRT = INS_fsqrt; #endif // TARGET_ARM64 /*****************************************************************************/ extern const BYTE genTypeSizes[]; extern const BYTE genTypeAlignments[]; extern const BYTE genTypeStSzs[]; extern const BYTE genActualTypes[]; /*****************************************************************************/ #ifdef DEBUG void dumpConvertedVarSet(Compiler* comp, VARSET_VALARG_TP vars); #endif // DEBUG #include "compiler.hpp" // All the shared inline functions /*****************************************************************************/ #endif //_COMPILER_H_ /*****************************************************************************/
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX Compiler XX XX XX XX Represents the method data we are currently JIT-compiling. XX XX An instance of this class is created for every method we JIT. XX XX This contains all the info needed for the method. So allocating a XX XX a new instance per method makes it thread-safe. XX XX It should be used to do all the memory management for the compiler run. XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ /*****************************************************************************/ #ifndef _COMPILER_H_ #define _COMPILER_H_ /*****************************************************************************/ #include "jit.h" #include "opcode.h" #include "varset.h" #include "jitstd.h" #include "jithashtable.h" #include "gentree.h" #include "debuginfo.h" #include "lir.h" #include "block.h" #include "inline.h" #include "jiteh.h" #include "instr.h" #include "regalloc.h" #include "sm.h" #include "cycletimer.h" #include "blockset.h" #include "arraystack.h" #include "hashbv.h" #include "jitexpandarray.h" #include "tinyarray.h" #include "valuenum.h" #include "jittelemetry.h" #include "namedintrinsiclist.h" #ifdef LATE_DISASM #include "disasm.h" #endif #include "codegeninterface.h" #include "regset.h" #include "jitgcinfo.h" #if DUMP_GC_TABLES && defined(JIT32_GCENCODER) #include "gcdump.h" #endif #include "emit.h" #include "hwintrinsic.h" #include "simd.h" #include "simdashwintrinsic.h" // This is only used locally in the JIT to indicate that // a verification block should be inserted #define SEH_VERIFICATION_EXCEPTION 0xe0564552 // VER /***************************************************************************** * Forward declarations */ struct InfoHdr; // defined in GCInfo.h struct escapeMapping_t; // defined in fgdiagnostic.cpp class emitter; // defined in emit.h struct ShadowParamVarInfo; // defined in GSChecks.cpp struct InitVarDscInfo; // defined in register_arg_convention.h class FgStack; // defined in fgbasic.cpp class Instrumentor; // defined in fgprofile.cpp class SpanningTreeVisitor; // defined in fgprofile.cpp class CSE_DataFlow; // defined in OptCSE.cpp class OptBoolsDsc; // defined in optimizer.cpp #ifdef DEBUG struct IndentStack; #endif class Lowering; // defined in lower.h // The following are defined in this file, Compiler.h class Compiler; /***************************************************************************** * Unwind info */ #include "unwind.h" /*****************************************************************************/ // // Declare global operator new overloads that use the compiler's arena allocator // // I wanted to make the second argument optional, with default = CMK_Unknown, but that // caused these to be ambiguous with the global placement new operators. void* __cdecl operator new(size_t n, Compiler* context, CompMemKind cmk); void* __cdecl operator new[](size_t n, Compiler* context, CompMemKind cmk); void* __cdecl operator new(size_t n, void* p, const jitstd::placement_t& syntax_difference); // Requires the definitions of "operator new" so including "LoopCloning.h" after the definitions. #include "loopcloning.h" /*****************************************************************************/ /* This is included here and not earlier as it needs the definition of "CSE" * which is defined in the section above */ /*****************************************************************************/ unsigned genLog2(unsigned value); unsigned genLog2(unsigned __int64 value); unsigned ReinterpretHexAsDecimal(unsigned in); /*****************************************************************************/ const unsigned FLG_CCTOR = (CORINFO_FLG_CONSTRUCTOR | CORINFO_FLG_STATIC); #ifdef DEBUG const int BAD_STK_OFFS = 0xBAADF00D; // for LclVarDsc::lvStkOffs #endif //------------------------------------------------------------------------ // HFA info shared by LclVarDsc and fgArgTabEntry //------------------------------------------------------------------------ inline bool IsHfa(CorInfoHFAElemType kind) { return kind != CORINFO_HFA_ELEM_NONE; } inline var_types HfaTypeFromElemKind(CorInfoHFAElemType kind) { switch (kind) { case CORINFO_HFA_ELEM_FLOAT: return TYP_FLOAT; case CORINFO_HFA_ELEM_DOUBLE: return TYP_DOUBLE; #ifdef FEATURE_SIMD case CORINFO_HFA_ELEM_VECTOR64: return TYP_SIMD8; case CORINFO_HFA_ELEM_VECTOR128: return TYP_SIMD16; #endif case CORINFO_HFA_ELEM_NONE: return TYP_UNDEF; default: assert(!"Invalid HfaElemKind"); return TYP_UNDEF; } } inline CorInfoHFAElemType HfaElemKindFromType(var_types type) { switch (type) { case TYP_FLOAT: return CORINFO_HFA_ELEM_FLOAT; case TYP_DOUBLE: return CORINFO_HFA_ELEM_DOUBLE; #ifdef FEATURE_SIMD case TYP_SIMD8: return CORINFO_HFA_ELEM_VECTOR64; case TYP_SIMD16: return CORINFO_HFA_ELEM_VECTOR128; #endif case TYP_UNDEF: return CORINFO_HFA_ELEM_NONE; default: assert(!"Invalid HFA Type"); return CORINFO_HFA_ELEM_NONE; } } // The following holds the Local var info (scope information) typedef const char* VarName; // Actual ASCII string struct VarScopeDsc { unsigned vsdVarNum; // (remapped) LclVarDsc number unsigned vsdLVnum; // 'which' in eeGetLVinfo(). // Also, it is the index of this entry in the info.compVarScopes array, // which is useful since the array is also accessed via the // compEnterScopeList and compExitScopeList sorted arrays. IL_OFFSET vsdLifeBeg; // instr offset of beg of life IL_OFFSET vsdLifeEnd; // instr offset of end of life #ifdef DEBUG VarName vsdName; // name of the var #endif }; // This class stores information associated with a LclVar SSA definition. class LclSsaVarDsc { // The basic block where the definition occurs. Definitions of uninitialized variables // are considered to occur at the start of the first basic block (fgFirstBB). // // TODO-Cleanup: In the case of uninitialized variables the block is set to nullptr by // SsaBuilder and changed to fgFirstBB during value numbering. It would be useful to // investigate and perhaps eliminate this rather unexpected behavior. BasicBlock* m_block; // The GT_ASG node that generates the definition, or nullptr for definitions // of uninitialized variables. GenTreeOp* m_asg; public: LclSsaVarDsc() : m_block(nullptr), m_asg(nullptr) { } LclSsaVarDsc(BasicBlock* block, GenTreeOp* asg) : m_block(block), m_asg(asg) { assert((asg == nullptr) || asg->OperIs(GT_ASG)); } BasicBlock* GetBlock() const { return m_block; } void SetBlock(BasicBlock* block) { m_block = block; } GenTreeOp* GetAssignment() const { return m_asg; } void SetAssignment(GenTreeOp* asg) { assert((asg == nullptr) || asg->OperIs(GT_ASG)); m_asg = asg; } ValueNumPair m_vnPair; }; // This class stores information associated with a memory SSA definition. class SsaMemDef { public: ValueNumPair m_vnPair; }; //------------------------------------------------------------------------ // SsaDefArray: A resizable array of SSA definitions. // // Unlike an ordinary resizable array implementation, this allows only element // addition (by calling AllocSsaNum) and has special handling for RESERVED_SSA_NUM // (basically it's a 1-based array). The array doesn't impose any particular // requirements on the elements it stores and AllocSsaNum forwards its arguments // to the array element constructor, this way the array supports both LclSsaVarDsc // and SsaMemDef elements. // template <typename T> class SsaDefArray { T* m_array; unsigned m_arraySize; unsigned m_count; static_assert_no_msg(SsaConfig::RESERVED_SSA_NUM == 0); static_assert_no_msg(SsaConfig::FIRST_SSA_NUM == 1); // Get the minimum valid SSA number. unsigned GetMinSsaNum() const { return SsaConfig::FIRST_SSA_NUM; } // Increase (double) the size of the array. void GrowArray(CompAllocator alloc) { unsigned oldSize = m_arraySize; unsigned newSize = max(2, oldSize * 2); T* newArray = alloc.allocate<T>(newSize); for (unsigned i = 0; i < oldSize; i++) { newArray[i] = m_array[i]; } m_array = newArray; m_arraySize = newSize; } public: // Construct an empty SsaDefArray. SsaDefArray() : m_array(nullptr), m_arraySize(0), m_count(0) { } // Reset the array (used only if the SSA form is reconstructed). void Reset() { m_count = 0; } // Allocate a new SSA number (starting with SsaConfig::FIRST_SSA_NUM). template <class... Args> unsigned AllocSsaNum(CompAllocator alloc, Args&&... args) { if (m_count == m_arraySize) { GrowArray(alloc); } unsigned ssaNum = GetMinSsaNum() + m_count; m_array[m_count++] = T(std::forward<Args>(args)...); // Ensure that the first SSA number we allocate is SsaConfig::FIRST_SSA_NUM assert((ssaNum == SsaConfig::FIRST_SSA_NUM) || (m_count > 1)); return ssaNum; } // Get the number of SSA definitions in the array. unsigned GetCount() const { return m_count; } // Get a pointer to the SSA definition at the specified index. T* GetSsaDefByIndex(unsigned index) { assert(index < m_count); return &m_array[index]; } // Check if the specified SSA number is valid. bool IsValidSsaNum(unsigned ssaNum) const { return (GetMinSsaNum() <= ssaNum) && (ssaNum < (GetMinSsaNum() + m_count)); } // Get a pointer to the SSA definition associated with the specified SSA number. T* GetSsaDef(unsigned ssaNum) { assert(ssaNum != SsaConfig::RESERVED_SSA_NUM); return GetSsaDefByIndex(ssaNum - GetMinSsaNum()); } // Get an SSA number associated with the specified SSA def (that must be in this array). unsigned GetSsaNum(T* ssaDef) { assert((m_array <= ssaDef) && (ssaDef < &m_array[m_count])); return GetMinSsaNum() + static_cast<unsigned>(ssaDef - &m_array[0]); } }; enum RefCountState { RCS_INVALID, // not valid to get/set ref counts RCS_EARLY, // early counts for struct promotion and struct passing RCS_NORMAL, // normal ref counts (from lvaMarkRefs onward) }; #ifdef DEBUG // Reasons why we can't enregister a local. enum class DoNotEnregisterReason { None, AddrExposed, // the address of this local is exposed. DontEnregStructs, // struct enregistration is disabled. NotRegSizeStruct, // the struct size does not much any register size, usually the struct size is too big. LocalField, // the local is accessed with LCL_FLD, note we can do it not only for struct locals. VMNeedsStackAddr, LiveInOutOfHandler, // the local is alive in and out of exception handler and not signle def. BlockOp, // Is read or written via a block operation. IsStructArg, // Is a struct passed as an argument in a way that requires a stack location. DepField, // It is a field of a dependently promoted struct NoRegVars, // opts.compFlags & CLFLG_REGVAR is not set MinOptsGC, // It is a GC Ref and we are compiling MinOpts #if !defined(TARGET_64BIT) LongParamField, // It is a decomposed field of a long parameter. #endif #ifdef JIT32_GCENCODER PinningRef, #endif LclAddrNode, // the local is accessed with LCL_ADDR_VAR/FLD. CastTakesAddr, StoreBlkSrc, // the local is used as STORE_BLK source. OneAsgRetyping, // fgMorphOneAsgBlockOp prevents this local from being enregister. SwizzleArg, // the local is passed using LCL_FLD as another type. BlockOpRet, // the struct is returned and it promoted or there is a cast. ReturnSpCheck, // the local is used to do SP check SimdUserForcesDep // a promoted struct was used by a SIMD/HWI node; it must be dependently promoted }; enum class AddressExposedReason { NONE, PARENT_EXPOSED, // This is a promoted field but the parent is exposed. TOO_CONSERVATIVE, // Were marked as exposed to be conservative, fix these places. ESCAPE_ADDRESS, // The address is escaping, for example, passed as call argument. WIDE_INDIR, // We access via indirection with wider type. OSR_EXPOSED, // It was exposed in the original method, osr has to repeat it. STRESS_LCL_FLD, // Stress mode replaces localVar with localFld and makes them addrExposed. COPY_FLD_BY_FLD, // Field by field copy takes the address of the local, can be fixed. DISPATCH_RET_BUF // Caller return buffer dispatch. }; #endif // DEBUG class LclVarDsc { public: // The constructor. Most things can just be zero'ed. // // Initialize the ArgRegs to REG_STK. // Morph will update if this local is passed in a register. LclVarDsc() : _lvArgReg(REG_STK) , #if FEATURE_MULTIREG_ARGS _lvOtherArgReg(REG_STK) , #endif // FEATURE_MULTIREG_ARGS lvClassHnd(NO_CLASS_HANDLE) , lvRefBlks(BlockSetOps::UninitVal()) , lvPerSsaData() { } // note this only packs because var_types is a typedef of unsigned char var_types lvType : 5; // TYP_INT/LONG/FLOAT/DOUBLE/REF unsigned char lvIsParam : 1; // is this a parameter? unsigned char lvIsRegArg : 1; // is this an argument that was passed by register? unsigned char lvFramePointerBased : 1; // 0 = off of REG_SPBASE (e.g., ESP), 1 = off of REG_FPBASE (e.g., EBP) unsigned char lvOnFrame : 1; // (part of) the variable lives on the frame unsigned char lvRegister : 1; // assigned to live in a register? For RyuJIT backend, this is only set if the // variable is in the same register for the entire function. unsigned char lvTracked : 1; // is this a tracked variable? bool lvTrackedNonStruct() { return lvTracked && lvType != TYP_STRUCT; } unsigned char lvPinned : 1; // is this a pinned variable? unsigned char lvMustInit : 1; // must be initialized private: bool m_addrExposed : 1; // The address of this variable is "exposed" -- passed as an argument, stored in a // global location, etc. // We cannot reason reliably about the value of the variable. public: unsigned char lvDoNotEnregister : 1; // Do not enregister this variable. unsigned char lvFieldAccessed : 1; // The var is a struct local, and a field of the variable is accessed. Affects // struct promotion. unsigned char lvLiveInOutOfHndlr : 1; // The variable is live in or out of an exception handler, and therefore must // be on the stack (at least at those boundaries.) unsigned char lvInSsa : 1; // The variable is in SSA form (set by SsaBuilder) unsigned char lvIsCSE : 1; // Indicates if this LclVar is a CSE variable. unsigned char lvHasLdAddrOp : 1; // has ldloca or ldarga opcode on this local. unsigned char lvStackByref : 1; // This is a compiler temporary of TYP_BYREF that is known to point into our local // stack frame. unsigned char lvHasILStoreOp : 1; // there is at least one STLOC or STARG on this local unsigned char lvHasMultipleILStoreOp : 1; // there is more than one STLOC on this local unsigned char lvIsTemp : 1; // Short-lifetime compiler temp #if defined(TARGET_AMD64) || defined(TARGET_ARM64) unsigned char lvIsImplicitByRef : 1; // Set if the argument is an implicit byref. #endif // defined(TARGET_AMD64) || defined(TARGET_ARM64) unsigned char lvIsBoolean : 1; // set if variable is boolean unsigned char lvSingleDef : 1; // variable has a single def // before lvaMarkLocalVars: identifies ref type locals that can get type updates // after lvaMarkLocalVars: identifies locals that are suitable for optAddCopies unsigned char lvSingleDefRegCandidate : 1; // variable has a single def and hence is a register candidate // Currently, this is only used to decide if an EH variable can be // a register candiate or not. unsigned char lvDisqualifySingleDefRegCandidate : 1; // tracks variable that are disqualified from register // candidancy unsigned char lvSpillAtSingleDef : 1; // variable has a single def (as determined by LSRA interval scan) // and is spilled making it candidate to spill right after the // first (and only) definition. // Note: We cannot reuse lvSingleDefRegCandidate because it is set // in earlier phase and the information might not be appropriate // in LSRA. unsigned char lvDisqualify : 1; // variable is no longer OK for add copy optimization unsigned char lvVolatileHint : 1; // hint for AssertionProp #ifndef TARGET_64BIT unsigned char lvStructDoubleAlign : 1; // Must we double align this struct? #endif // !TARGET_64BIT #ifdef TARGET_64BIT unsigned char lvQuirkToLong : 1; // Quirk to allocate this LclVar as a 64-bit long #endif #ifdef DEBUG unsigned char lvKeepType : 1; // Don't change the type of this variable unsigned char lvNoLclFldStress : 1; // Can't apply local field stress on this one #endif unsigned char lvIsPtr : 1; // Might this be used in an address computation? (used by buffer overflow security // checks) unsigned char lvIsUnsafeBuffer : 1; // Does this contain an unsafe buffer requiring buffer overflow security checks? unsigned char lvPromoted : 1; // True when this local is a promoted struct, a normed struct, or a "split" long on a // 32-bit target. For implicit byref parameters, this gets hijacked between // fgRetypeImplicitByRefArgs and fgMarkDemotedImplicitByRefArgs to indicate whether // references to the arg are being rewritten as references to a promoted shadow local. unsigned char lvIsStructField : 1; // Is this local var a field of a promoted struct local? unsigned char lvOverlappingFields : 1; // True when we have a struct with possibly overlapping fields unsigned char lvContainsHoles : 1; // True when we have a promoted struct that contains holes unsigned char lvCustomLayout : 1; // True when this struct has "CustomLayout" unsigned char lvIsMultiRegArg : 1; // true if this is a multireg LclVar struct used in an argument context unsigned char lvIsMultiRegRet : 1; // true if this is a multireg LclVar struct assigned from a multireg call #ifdef FEATURE_HFA_FIELDS_PRESENT CorInfoHFAElemType _lvHfaElemKind : 3; // What kind of an HFA this is (CORINFO_HFA_ELEM_NONE if it is not an HFA). #endif // FEATURE_HFA_FIELDS_PRESENT #ifdef DEBUG // TODO-Cleanup: See the note on lvSize() - this flag is only in use by asserts that are checking for struct // types, and is needed because of cases where TYP_STRUCT is bashed to an integral type. // Consider cleaning this up so this workaround is not required. unsigned char lvUnusedStruct : 1; // All references to this promoted struct are through its field locals. // I.e. there is no longer any reference to the struct directly. // In this case we can simply remove this struct local. unsigned char lvUndoneStructPromotion : 1; // The struct promotion was undone and hence there should be no // reference to the fields of this struct. #endif unsigned char lvLRACandidate : 1; // Tracked for linear scan register allocation purposes #ifdef FEATURE_SIMD // Note that both SIMD vector args and locals are marked as lvSIMDType = true, but the // type of an arg node is TYP_BYREF and a local node is TYP_SIMD*. unsigned char lvSIMDType : 1; // This is a SIMD struct unsigned char lvUsedInSIMDIntrinsic : 1; // This tells lclvar is used for simd intrinsic unsigned char lvSimdBaseJitType : 5; // Note: this only packs because CorInfoType has less than 32 entries CorInfoType GetSimdBaseJitType() const { return (CorInfoType)lvSimdBaseJitType; } void SetSimdBaseJitType(CorInfoType simdBaseJitType) { assert(simdBaseJitType < (1 << 5)); lvSimdBaseJitType = (unsigned char)simdBaseJitType; } var_types GetSimdBaseType() const; #endif // FEATURE_SIMD unsigned char lvRegStruct : 1; // This is a reg-sized non-field-addressed struct. unsigned char lvClassIsExact : 1; // lvClassHandle is the exact type #ifdef DEBUG unsigned char lvClassInfoUpdated : 1; // true if this var has updated class handle or exactness #endif unsigned char lvImplicitlyReferenced : 1; // true if there are non-IR references to this local (prolog, epilog, gc, // eh) unsigned char lvSuppressedZeroInit : 1; // local needs zero init if we transform tail call to loop unsigned char lvHasExplicitInit : 1; // The local is explicitly initialized and doesn't need zero initialization in // the prolog. If the local has gc pointers, there are no gc-safe points // between the prolog and the explicit initialization. union { unsigned lvFieldLclStart; // The index of the local var representing the first field in the promoted struct // local. For implicit byref parameters, this gets hijacked between // fgRetypeImplicitByRefArgs and fgMarkDemotedImplicitByRefArgs to point to the // struct local created to model the parameter's struct promotion, if any. unsigned lvParentLcl; // The index of the local var representing the parent (i.e. the promoted struct local). // Valid on promoted struct local fields. }; unsigned char lvFieldCnt; // Number of fields in the promoted VarDsc. unsigned char lvFldOffset; unsigned char lvFldOrdinal; #ifdef DEBUG unsigned char lvSingleDefDisqualifyReason = 'H'; #endif #if FEATURE_MULTIREG_ARGS regNumber lvRegNumForSlot(unsigned slotNum) { if (slotNum == 0) { return (regNumber)_lvArgReg; } else if (slotNum == 1) { return GetOtherArgReg(); } else { assert(false && "Invalid slotNum!"); } unreached(); } #endif // FEATURE_MULTIREG_ARGS CorInfoHFAElemType GetLvHfaElemKind() const { #ifdef FEATURE_HFA_FIELDS_PRESENT return _lvHfaElemKind; #else NOWAY_MSG("GetLvHfaElemKind"); return CORINFO_HFA_ELEM_NONE; #endif // FEATURE_HFA_FIELDS_PRESENT } void SetLvHfaElemKind(CorInfoHFAElemType elemKind) { #ifdef FEATURE_HFA_FIELDS_PRESENT _lvHfaElemKind = elemKind; #else NOWAY_MSG("SetLvHfaElemKind"); #endif // FEATURE_HFA_FIELDS_PRESENT } bool lvIsHfa() const { if (GlobalJitOptions::compFeatureHfa) { return IsHfa(GetLvHfaElemKind()); } else { return false; } } bool lvIsHfaRegArg() const { if (GlobalJitOptions::compFeatureHfa) { return lvIsRegArg && lvIsHfa(); } else { return false; } } //------------------------------------------------------------------------------ // lvHfaSlots: Get the number of slots used by an HFA local // // Return Value: // On Arm64 - Returns 1-4 indicating the number of register slots used by the HFA // On Arm32 - Returns the total number of single FP register slots used by the HFA, max is 8 // unsigned lvHfaSlots() const { assert(lvIsHfa()); assert(varTypeIsStruct(lvType)); unsigned slots = 0; #ifdef TARGET_ARM slots = lvExactSize / sizeof(float); assert(slots <= 8); #elif defined(TARGET_ARM64) switch (GetLvHfaElemKind()) { case CORINFO_HFA_ELEM_NONE: assert(!"lvHfaSlots called for non-HFA"); break; case CORINFO_HFA_ELEM_FLOAT: assert((lvExactSize % 4) == 0); slots = lvExactSize >> 2; break; case CORINFO_HFA_ELEM_DOUBLE: case CORINFO_HFA_ELEM_VECTOR64: assert((lvExactSize % 8) == 0); slots = lvExactSize >> 3; break; case CORINFO_HFA_ELEM_VECTOR128: assert((lvExactSize % 16) == 0); slots = lvExactSize >> 4; break; default: unreached(); } assert(slots <= 4); #endif // TARGET_ARM64 return slots; } // lvIsMultiRegArgOrRet() // returns true if this is a multireg LclVar struct used in an argument context // or if this is a multireg LclVar struct assigned from a multireg call bool lvIsMultiRegArgOrRet() { return lvIsMultiRegArg || lvIsMultiRegRet; } #if defined(DEBUG) private: DoNotEnregisterReason m_doNotEnregReason; AddressExposedReason m_addrExposedReason; public: void SetDoNotEnregReason(DoNotEnregisterReason reason) { m_doNotEnregReason = reason; } DoNotEnregisterReason GetDoNotEnregReason() const { return m_doNotEnregReason; } AddressExposedReason GetAddrExposedReason() const { return m_addrExposedReason; } #endif // DEBUG public: void SetAddressExposed(bool value DEBUGARG(AddressExposedReason reason)) { m_addrExposed = value; INDEBUG(m_addrExposedReason = reason); } void CleanAddressExposed() { m_addrExposed = false; } bool IsAddressExposed() const { return m_addrExposed; } private: regNumberSmall _lvRegNum; // Used to store the register this variable is in (or, the low register of a // register pair). It is set during codegen any time the // variable is enregistered (lvRegister is only set // to non-zero if the variable gets the same register assignment for its entire // lifetime). #if !defined(TARGET_64BIT) regNumberSmall _lvOtherReg; // Used for "upper half" of long var. #endif // !defined(TARGET_64BIT) regNumberSmall _lvArgReg; // The (first) register in which this argument is passed. #if FEATURE_MULTIREG_ARGS regNumberSmall _lvOtherArgReg; // Used for the second part of the struct passed in a register. // Note this is defined but not used by ARM32 #endif // FEATURE_MULTIREG_ARGS regNumberSmall _lvArgInitReg; // the register into which the argument is moved at entry public: // The register number is stored in a small format (8 bits), but the getters return and the setters take // a full-size (unsigned) format, to localize the casts here. ///////////////////// regNumber GetRegNum() const { return (regNumber)_lvRegNum; } void SetRegNum(regNumber reg) { _lvRegNum = (regNumberSmall)reg; assert(_lvRegNum == reg); } ///////////////////// #if defined(TARGET_64BIT) regNumber GetOtherReg() const { assert(!"shouldn't get here"); // can't use "unreached();" because it's NORETURN, which causes C4072 // "unreachable code" warnings return REG_NA; } void SetOtherReg(regNumber reg) { assert(!"shouldn't get here"); // can't use "unreached();" because it's NORETURN, which causes C4072 // "unreachable code" warnings } #else // !TARGET_64BIT regNumber GetOtherReg() const { return (regNumber)_lvOtherReg; } void SetOtherReg(regNumber reg) { _lvOtherReg = (regNumberSmall)reg; assert(_lvOtherReg == reg); } #endif // !TARGET_64BIT ///////////////////// regNumber GetArgReg() const { return (regNumber)_lvArgReg; } void SetArgReg(regNumber reg) { _lvArgReg = (regNumberSmall)reg; assert(_lvArgReg == reg); } #if FEATURE_MULTIREG_ARGS regNumber GetOtherArgReg() const { return (regNumber)_lvOtherArgReg; } void SetOtherArgReg(regNumber reg) { _lvOtherArgReg = (regNumberSmall)reg; assert(_lvOtherArgReg == reg); } #endif // FEATURE_MULTIREG_ARGS #ifdef FEATURE_SIMD // Is this is a SIMD struct? bool lvIsSIMDType() const { return lvSIMDType; } // Is this is a SIMD struct which is used for SIMD intrinsic? bool lvIsUsedInSIMDIntrinsic() const { return lvUsedInSIMDIntrinsic; } #else // If feature_simd not enabled, return false bool lvIsSIMDType() const { return false; } bool lvIsUsedInSIMDIntrinsic() const { return false; } #endif ///////////////////// regNumber GetArgInitReg() const { return (regNumber)_lvArgInitReg; } void SetArgInitReg(regNumber reg) { _lvArgInitReg = (regNumberSmall)reg; assert(_lvArgInitReg == reg); } ///////////////////// bool lvIsRegCandidate() const { return lvLRACandidate != 0; } bool lvIsInReg() const { return lvIsRegCandidate() && (GetRegNum() != REG_STK); } regMaskTP lvRegMask() const { regMaskTP regMask = RBM_NONE; if (varTypeUsesFloatReg(TypeGet())) { if (GetRegNum() != REG_STK) { regMask = genRegMaskFloat(GetRegNum(), TypeGet()); } } else { if (GetRegNum() != REG_STK) { regMask = genRegMask(GetRegNum()); } } return regMask; } unsigned short lvVarIndex; // variable tracking index private: unsigned short m_lvRefCnt; // unweighted (real) reference count. For implicit by reference // parameters, this gets hijacked from fgResetImplicitByRefRefCount // through fgMarkDemotedImplicitByRefArgs, to provide a static // appearance count (computed during address-exposed analysis) // that fgMakeOutgoingStructArgCopy consults during global morph // to determine if eliding its copy is legal. weight_t m_lvRefCntWtd; // weighted reference count public: unsigned short lvRefCnt(RefCountState state = RCS_NORMAL) const; void incLvRefCnt(unsigned short delta, RefCountState state = RCS_NORMAL); void setLvRefCnt(unsigned short newValue, RefCountState state = RCS_NORMAL); weight_t lvRefCntWtd(RefCountState state = RCS_NORMAL) const; void incLvRefCntWtd(weight_t delta, RefCountState state = RCS_NORMAL); void setLvRefCntWtd(weight_t newValue, RefCountState state = RCS_NORMAL); private: int lvStkOffs; // stack offset of home in bytes. public: int GetStackOffset() const { return lvStkOffs; } void SetStackOffset(int offset) { lvStkOffs = offset; } unsigned lvExactSize; // (exact) size of the type in bytes // Is this a promoted struct? // This method returns true only for structs (including SIMD structs), not for // locals that are split on a 32-bit target. // It is only necessary to use this: // 1) if only structs are wanted, and // 2) if Lowering has already been done. // Otherwise lvPromoted is valid. bool lvPromotedStruct() { #if !defined(TARGET_64BIT) return (lvPromoted && !varTypeIsLong(lvType)); #else // defined(TARGET_64BIT) return lvPromoted; #endif // defined(TARGET_64BIT) } unsigned lvSize() const; size_t lvArgStackSize() const; unsigned lvSlotNum; // original slot # (if remapped) typeInfo lvVerTypeInfo; // type info needed for verification // class handle for the local or null if not known or not a class, // for a struct handle use `GetStructHnd()`. CORINFO_CLASS_HANDLE lvClassHnd; // Get class handle for a struct local or implicitByRef struct local. CORINFO_CLASS_HANDLE GetStructHnd() const { #ifdef FEATURE_SIMD if (lvSIMDType && (m_layout == nullptr)) { return NO_CLASS_HANDLE; } #endif assert(m_layout != nullptr); #if defined(TARGET_AMD64) || defined(TARGET_ARM64) assert(varTypeIsStruct(TypeGet()) || (lvIsImplicitByRef && (TypeGet() == TYP_BYREF))); #else assert(varTypeIsStruct(TypeGet())); #endif CORINFO_CLASS_HANDLE structHnd = m_layout->GetClassHandle(); assert(structHnd != NO_CLASS_HANDLE); return structHnd; } CORINFO_FIELD_HANDLE lvFieldHnd; // field handle for promoted struct fields private: ClassLayout* m_layout; // layout info for structs public: BlockSet lvRefBlks; // Set of blocks that contain refs Statement* lvDefStmt; // Pointer to the statement with the single definition void lvaDisqualifyVar(); // Call to disqualify a local variable from use in optAddCopies var_types TypeGet() const { return (var_types)lvType; } bool lvStackAligned() const { assert(lvIsStructField); return ((lvFldOffset % TARGET_POINTER_SIZE) == 0); } bool lvNormalizeOnLoad() const { return varTypeIsSmall(TypeGet()) && // lvIsStructField is treated the same as the aliased local, see fgDoNormalizeOnStore. (lvIsParam || m_addrExposed || lvIsStructField); } bool lvNormalizeOnStore() const { return varTypeIsSmall(TypeGet()) && // lvIsStructField is treated the same as the aliased local, see fgDoNormalizeOnStore. !(lvIsParam || m_addrExposed || lvIsStructField); } void incRefCnts(weight_t weight, Compiler* pComp, RefCountState state = RCS_NORMAL, bool propagate = true); var_types GetHfaType() const { if (GlobalJitOptions::compFeatureHfa) { assert(lvIsHfa()); return HfaTypeFromElemKind(GetLvHfaElemKind()); } else { return TYP_UNDEF; } } void SetHfaType(var_types type) { if (GlobalJitOptions::compFeatureHfa) { CorInfoHFAElemType elemKind = HfaElemKindFromType(type); SetLvHfaElemKind(elemKind); // Ensure we've allocated enough bits. assert(GetLvHfaElemKind() == elemKind); } } // Returns true if this variable contains GC pointers (including being a GC pointer itself). bool HasGCPtr() const { return varTypeIsGC(lvType) || ((lvType == TYP_STRUCT) && m_layout->HasGCPtr()); } // Returns the layout of a struct variable. ClassLayout* GetLayout() const { assert(varTypeIsStruct(lvType)); return m_layout; } // Sets the layout of a struct variable. void SetLayout(ClassLayout* layout) { assert(varTypeIsStruct(lvType)); assert((m_layout == nullptr) || ClassLayout::AreCompatible(m_layout, layout)); m_layout = layout; } SsaDefArray<LclSsaVarDsc> lvPerSsaData; // Returns the address of the per-Ssa data for the given ssaNum (which is required // not to be the SsaConfig::RESERVED_SSA_NUM, which indicates that the variable is // not an SSA variable). LclSsaVarDsc* GetPerSsaData(unsigned ssaNum) { return lvPerSsaData.GetSsaDef(ssaNum); } // Returns the SSA number for "ssaDef". Requires "ssaDef" to be a valid definition // of this variable. unsigned GetSsaNumForSsaDef(LclSsaVarDsc* ssaDef) { return lvPerSsaData.GetSsaNum(ssaDef); } var_types GetRegisterType(const GenTreeLclVarCommon* tree) const; var_types GetRegisterType() const; var_types GetActualRegisterType() const; bool IsEnregisterableType() const { return GetRegisterType() != TYP_UNDEF; } bool IsEnregisterableLcl() const { if (lvDoNotEnregister) { return false; } return IsEnregisterableType(); } //----------------------------------------------------------------------------- // IsAlwaysAliveInMemory: Determines if this variable's value is always // up-to-date on stack. This is possible if this is an EH-var or // we decided to spill after single-def. // bool IsAlwaysAliveInMemory() const { return lvLiveInOutOfHndlr || lvSpillAtSingleDef; } bool CanBeReplacedWithItsField(Compiler* comp) const; #ifdef DEBUG public: const char* lvReason; void PrintVarReg() const { printf("%s", getRegName(GetRegNum())); } #endif // DEBUG }; // class LclVarDsc enum class SymbolicIntegerValue : int32_t { LongMin, IntMin, ShortMin, ByteMin, Zero, One, ByteMax, UByteMax, ShortMax, UShortMax, IntMax, UIntMax, LongMax, }; inline constexpr bool operator>(SymbolicIntegerValue left, SymbolicIntegerValue right) { return static_cast<int32_t>(left) > static_cast<int32_t>(right); } inline constexpr bool operator>=(SymbolicIntegerValue left, SymbolicIntegerValue right) { return static_cast<int32_t>(left) >= static_cast<int32_t>(right); } inline constexpr bool operator<(SymbolicIntegerValue left, SymbolicIntegerValue right) { return static_cast<int32_t>(left) < static_cast<int32_t>(right); } inline constexpr bool operator<=(SymbolicIntegerValue left, SymbolicIntegerValue right) { return static_cast<int32_t>(left) <= static_cast<int32_t>(right); } // Represents an integral range useful for reasoning about integral casts. // It uses a symbolic representation for lower and upper bounds so // that it can efficiently handle integers of all sizes on all hosts. // // Note that the ranges represented by this class are **always** in the // "signed" domain. This is so that if we know the range a node produces, it // can be trivially used to determine if a cast above the node does or does not // overflow, which requires that the interpretation of integers be the same both // for the "input" and "output". We choose signed interpretation here because it // produces nice continuous ranges and because IR uses sign-extension for constants. // // Some examples of how ranges are computed for casts: // 1. CAST_OVF(ubyte <- uint): does not overflow for [0..UBYTE_MAX], produces the // same range - all casts that do not change the representation, i. e. have the same // "actual" input and output type, have the same "input" and "output" range. // 2. CAST_OVF(ulong <- uint): never oveflows => the "input" range is [INT_MIN..INT_MAX] // (aka all possible 32 bit integers). Produces [0..UINT_MAX] (aka all possible 32 // bit integers zero-extended to 64 bits). // 3. CAST_OVF(int <- uint): overflows for inputs larger than INT_MAX <=> less than 0 // when interpreting as signed => the "input" range is [0..INT_MAX], the same range // being the produced one as the node does not change the width of the integer. // class IntegralRange { private: SymbolicIntegerValue m_lowerBound; SymbolicIntegerValue m_upperBound; public: IntegralRange() = default; IntegralRange(SymbolicIntegerValue lowerBound, SymbolicIntegerValue upperBound) : m_lowerBound(lowerBound), m_upperBound(upperBound) { assert(lowerBound <= upperBound); } bool Contains(int64_t value) const; bool Contains(IntegralRange other) const { return (m_lowerBound <= other.m_lowerBound) && (other.m_upperBound <= m_upperBound); } bool IsPositive() { return m_lowerBound >= SymbolicIntegerValue::Zero; } bool Equals(IntegralRange other) const { return (m_lowerBound == other.m_lowerBound) && (m_upperBound == other.m_upperBound); } static int64_t SymbolicToRealValue(SymbolicIntegerValue value); static SymbolicIntegerValue LowerBoundForType(var_types type); static SymbolicIntegerValue UpperBoundForType(var_types type); static IntegralRange ForType(var_types type) { return {LowerBoundForType(type), UpperBoundForType(type)}; } static IntegralRange ForNode(GenTree* node, Compiler* compiler); static IntegralRange ForCastInput(GenTreeCast* cast); static IntegralRange ForCastOutput(GenTreeCast* cast); #ifdef DEBUG static void Print(IntegralRange range); #endif // DEBUG }; /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX TempsInfo XX XX XX XX The temporary lclVars allocated by the compiler for code generation XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ /***************************************************************************** * * The following keeps track of temporaries allocated in the stack frame * during code-generation (after register allocation). These spill-temps are * only used if we run out of registers while evaluating a tree. * * These are different from the more common temps allocated by lvaGrabTemp(). */ class TempDsc { public: TempDsc* tdNext; private: int tdOffs; #ifdef DEBUG static const int BAD_TEMP_OFFSET = 0xDDDDDDDD; // used as a sentinel "bad value" for tdOffs in DEBUG #endif // DEBUG int tdNum; BYTE tdSize; var_types tdType; public: TempDsc(int _tdNum, unsigned _tdSize, var_types _tdType) : tdNum(_tdNum), tdSize((BYTE)_tdSize), tdType(_tdType) { #ifdef DEBUG // temps must have a negative number (so they have a different number from all local variables) assert(tdNum < 0); tdOffs = BAD_TEMP_OFFSET; #endif // DEBUG if (tdNum != _tdNum) { IMPL_LIMITATION("too many spill temps"); } } #ifdef DEBUG bool tdLegalOffset() const { return tdOffs != BAD_TEMP_OFFSET; } #endif // DEBUG int tdTempOffs() const { assert(tdLegalOffset()); return tdOffs; } void tdSetTempOffs(int offs) { tdOffs = offs; assert(tdLegalOffset()); } void tdAdjustTempOffs(int offs) { tdOffs += offs; assert(tdLegalOffset()); } int tdTempNum() const { assert(tdNum < 0); return tdNum; } unsigned tdTempSize() const { return tdSize; } var_types tdTempType() const { return tdType; } }; // interface to hide linearscan implementation from rest of compiler class LinearScanInterface { public: virtual void doLinearScan() = 0; virtual void recordVarLocationsAtStartOfBB(BasicBlock* bb) = 0; virtual bool willEnregisterLocalVars() const = 0; #if TRACK_LSRA_STATS virtual void dumpLsraStatsCsv(FILE* file) = 0; virtual void dumpLsraStatsSummary(FILE* file) = 0; #endif // TRACK_LSRA_STATS }; LinearScanInterface* getLinearScanAllocator(Compiler* comp); // Information about arrays: their element type and size, and the offset of the first element. // We label GT_IND's that are array indices with GTF_IND_ARR_INDEX, and, for such nodes, // associate an array info via the map retrieved by GetArrayInfoMap(). This information is used, // for example, in value numbering of array index expressions. struct ArrayInfo { var_types m_elemType; CORINFO_CLASS_HANDLE m_elemStructType; unsigned m_elemSize; unsigned m_elemOffset; ArrayInfo() : m_elemType(TYP_UNDEF), m_elemStructType(nullptr), m_elemSize(0), m_elemOffset(0) { } ArrayInfo(var_types elemType, unsigned elemSize, unsigned elemOffset, CORINFO_CLASS_HANDLE elemStructType) : m_elemType(elemType), m_elemStructType(elemStructType), m_elemSize(elemSize), m_elemOffset(elemOffset) { } }; // This enumeration names the phases into which we divide compilation. The phases should completely // partition a compilation. enum Phases { #define CompPhaseNameMacro(enum_nm, string_nm, short_nm, hasChildren, parent, measureIR) enum_nm, #include "compphases.h" PHASE_NUMBER_OF }; extern const char* PhaseNames[]; extern const char* PhaseEnums[]; extern const LPCWSTR PhaseShortNames[]; // Specify which checks should be run after each phase // enum class PhaseChecks { CHECK_NONE, CHECK_ALL }; // Specify compiler data that a phase might modify enum class PhaseStatus : unsigned { MODIFIED_NOTHING, MODIFIED_EVERYTHING }; // The following enum provides a simple 1:1 mapping to CLR API's enum API_ICorJitInfo_Names { #define DEF_CLR_API(name) API_##name, #include "ICorJitInfo_API_names.h" API_COUNT }; //--------------------------------------------------------------- // Compilation time. // // A "CompTimeInfo" is a structure for tracking the compilation time of one or more methods. // We divide a compilation into a sequence of contiguous phases, and track the total (per-thread) cycles // of the compilation, as well as the cycles for each phase. We also track the number of bytecodes. // If there is a failure in reading a timer at any point, the "CompTimeInfo" becomes invalid, as indicated // by "m_timerFailure" being true. // If FEATURE_JIT_METHOD_PERF is not set, we define a minimal form of this, enough to let other code compile. struct CompTimeInfo { #ifdef FEATURE_JIT_METHOD_PERF // The string names of the phases. static const char* PhaseNames[]; static bool PhaseHasChildren[]; static int PhaseParent[]; static bool PhaseReportsIRSize[]; unsigned m_byteCodeBytes; unsigned __int64 m_totalCycles; unsigned __int64 m_invokesByPhase[PHASE_NUMBER_OF]; unsigned __int64 m_cyclesByPhase[PHASE_NUMBER_OF]; #if MEASURE_CLRAPI_CALLS unsigned __int64 m_CLRinvokesByPhase[PHASE_NUMBER_OF]; unsigned __int64 m_CLRcyclesByPhase[PHASE_NUMBER_OF]; #endif unsigned m_nodeCountAfterPhase[PHASE_NUMBER_OF]; // For better documentation, we call EndPhase on // non-leaf phases. We should also call EndPhase on the // last leaf subphase; obviously, the elapsed cycles between the EndPhase // for the last leaf subphase and the EndPhase for an ancestor should be very small. // We add all such "redundant end phase" intervals to this variable below; we print // it out in a report, so we can verify that it is, indeed, very small. If it ever // isn't, this means that we're doing something significant between the end of the last // declared subphase and the end of its parent. unsigned __int64 m_parentPhaseEndSlop; bool m_timerFailure; #if MEASURE_CLRAPI_CALLS // The following measures the time spent inside each individual CLR API call. unsigned m_allClrAPIcalls; unsigned m_perClrAPIcalls[API_ICorJitInfo_Names::API_COUNT]; unsigned __int64 m_allClrAPIcycles; unsigned __int64 m_perClrAPIcycles[API_ICorJitInfo_Names::API_COUNT]; unsigned __int32 m_maxClrAPIcycles[API_ICorJitInfo_Names::API_COUNT]; #endif // MEASURE_CLRAPI_CALLS CompTimeInfo(unsigned byteCodeBytes); #endif }; #ifdef FEATURE_JIT_METHOD_PERF #if MEASURE_CLRAPI_CALLS struct WrapICorJitInfo; #endif // This class summarizes the JIT time information over the course of a run: the number of methods compiled, // and the total and maximum timings. (These are instances of the "CompTimeInfo" type described above). // The operation of adding a single method's timing to the summary may be performed concurrently by several // threads, so it is protected by a lock. // This class is intended to be used as a singleton type, with only a single instance. class CompTimeSummaryInfo { // This lock protects the fields of all CompTimeSummaryInfo(s) (of which we expect there to be one). static CritSecObject s_compTimeSummaryLock; int m_numMethods; int m_totMethods; CompTimeInfo m_total; CompTimeInfo m_maximum; int m_numFilteredMethods; CompTimeInfo m_filtered; // This can use what ever data you want to determine if the value to be added // belongs in the filtered section (it's always included in the unfiltered section) bool IncludedInFilteredData(CompTimeInfo& info); public: // This is the unique CompTimeSummaryInfo object for this instance of the runtime. static CompTimeSummaryInfo s_compTimeSummary; CompTimeSummaryInfo() : m_numMethods(0), m_totMethods(0), m_total(0), m_maximum(0), m_numFilteredMethods(0), m_filtered(0) { } // Assumes that "info" is a completed CompTimeInfo for a compilation; adds it to the summary. // This is thread safe. void AddInfo(CompTimeInfo& info, bool includePhases); // Print the summary information to "f". // This is not thread-safe; assumed to be called by only one thread. void Print(FILE* f); }; // A JitTimer encapsulates a CompTimeInfo for a single compilation. It also tracks the start of compilation, // and when the current phase started. This is intended to be part of a Compilation object. // class JitTimer { unsigned __int64 m_start; // Start of the compilation. unsigned __int64 m_curPhaseStart; // Start of the current phase. #if MEASURE_CLRAPI_CALLS unsigned __int64 m_CLRcallStart; // Start of the current CLR API call (if any). unsigned __int64 m_CLRcallInvokes; // CLR API invokes under current outer so far unsigned __int64 m_CLRcallCycles; // CLR API cycles under current outer so far. int m_CLRcallAPInum; // The enum/index of the current CLR API call (or -1). static double s_cyclesPerSec; // Cached for speedier measurements #endif #ifdef DEBUG Phases m_lastPhase; // The last phase that was completed (or (Phases)-1 to start). #endif CompTimeInfo m_info; // The CompTimeInfo for this compilation. static CritSecObject s_csvLock; // Lock to protect the time log file. static FILE* s_csvFile; // The time log file handle. void PrintCsvMethodStats(Compiler* comp); private: void* operator new(size_t); void* operator new[](size_t); void operator delete(void*); void operator delete[](void*); public: // Initialized the timer instance JitTimer(unsigned byteCodeSize); static JitTimer* Create(Compiler* comp, unsigned byteCodeSize) { return ::new (comp, CMK_Unknown) JitTimer(byteCodeSize); } static void PrintCsvHeader(); // Ends the current phase (argument is for a redundant check). void EndPhase(Compiler* compiler, Phases phase); #if MEASURE_CLRAPI_CALLS // Start and end a timed CLR API call. void CLRApiCallEnter(unsigned apix); void CLRApiCallLeave(unsigned apix); #endif // MEASURE_CLRAPI_CALLS // Completes the timing of the current method, which is assumed to have "byteCodeBytes" bytes of bytecode, // and adds it to "sum". void Terminate(Compiler* comp, CompTimeSummaryInfo& sum, bool includePhases); // Attempts to query the cycle counter of the current thread. If successful, returns "true" and sets // *cycles to the cycle counter value. Otherwise, returns false and sets the "m_timerFailure" flag of // "m_info" to true. bool GetThreadCycles(unsigned __int64* cycles) { bool res = CycleTimer::GetThreadCyclesS(cycles); if (!res) { m_info.m_timerFailure = true; } return res; } static void Shutdown(); }; #endif // FEATURE_JIT_METHOD_PERF //------------------- Function/Funclet info ------------------------------- enum FuncKind : BYTE { FUNC_ROOT, // The main/root function (always id==0) FUNC_HANDLER, // a funclet associated with an EH handler (finally, fault, catch, filter handler) FUNC_FILTER, // a funclet associated with an EH filter FUNC_COUNT }; class emitLocation; struct FuncInfoDsc { FuncKind funKind; BYTE funFlags; // Currently unused, just here for padding unsigned short funEHIndex; // index, into the ebd table, of innermost EH clause corresponding to this // funclet. It is only valid if funKind field indicates this is a // EH-related funclet: FUNC_HANDLER or FUNC_FILTER #if defined(TARGET_AMD64) // TODO-AMD64-Throughput: make the AMD64 info more like the ARM info to avoid having this large static array. emitLocation* startLoc; emitLocation* endLoc; emitLocation* coldStartLoc; // locations for the cold section, if there is one. emitLocation* coldEndLoc; UNWIND_INFO unwindHeader; // Maximum of 255 UNWIND_CODE 'nodes' and then the unwind header. If there are an odd // number of codes, the VM or Zapper will 4-byte align the whole thing. BYTE unwindCodes[offsetof(UNWIND_INFO, UnwindCode) + (0xFF * sizeof(UNWIND_CODE))]; unsigned unwindCodeSlot; #elif defined(TARGET_X86) emitLocation* startLoc; emitLocation* endLoc; emitLocation* coldStartLoc; // locations for the cold section, if there is one. emitLocation* coldEndLoc; #elif defined(TARGET_ARMARCH) UnwindInfo uwi; // Unwind information for this function/funclet's hot section UnwindInfo* uwiCold; // Unwind information for this function/funclet's cold section // Note: we only have a pointer here instead of the actual object, // to save memory in the JIT case (compared to the NGEN case), // where we don't have any cold section. // Note 2: we currently don't support hot/cold splitting in functions // with EH, so uwiCold will be NULL for all funclets. emitLocation* startLoc; emitLocation* endLoc; emitLocation* coldStartLoc; // locations for the cold section, if there is one. emitLocation* coldEndLoc; #endif // TARGET_ARMARCH #if defined(FEATURE_CFI_SUPPORT) jitstd::vector<CFI_CODE>* cfiCodes; #endif // FEATURE_CFI_SUPPORT // Eventually we may want to move rsModifiedRegsMask, lvaOutgoingArgSize, and anything else // that isn't shared between the main function body and funclets. }; struct fgArgTabEntry { GenTreeCall::Use* use; // Points to the argument's GenTreeCall::Use in gtCallArgs or gtCallThisArg. GenTreeCall::Use* lateUse; // Points to the argument's GenTreeCall::Use in gtCallLateArgs, if any. // Get the node that coresponds to this argument entry. // This is the "real" node and not a placeholder or setup node. GenTree* GetNode() const { return lateUse == nullptr ? use->GetNode() : lateUse->GetNode(); } unsigned argNum; // The original argument number, also specifies the required argument evaluation order from the IL private: regNumberSmall regNums[MAX_ARG_REG_COUNT]; // The registers to use when passing this argument, set to REG_STK for // arguments passed on the stack public: unsigned numRegs; // Count of number of registers that this argument uses. // Note that on ARM, if we have a double hfa, this reflects the number // of DOUBLE registers. #if defined(UNIX_AMD64_ABI) // Unix amd64 will split floating point types and integer types in structs // between floating point and general purpose registers. Keep track of that // information so we do not need to recompute it later. unsigned structIntRegs; unsigned structFloatRegs; #endif // UNIX_AMD64_ABI #if defined(DEBUG_ARG_SLOTS) // These fields were used to calculate stack size in stack slots for arguments // but now they are replaced by precise `m_byteOffset/m_byteSize` because of // arm64 apple abi requirements. // A slot is a pointer sized region in the OutArg area. unsigned slotNum; // When an argument is passed in the OutArg area this is the slot number in the OutArg area unsigned numSlots; // Count of number of slots that this argument uses #endif // DEBUG_ARG_SLOTS // Return number of stack slots that this argument is taking. // TODO-Cleanup: this function does not align with arm64 apple model, // delete it. In most cases we just want to know if we it is using stack or not // but in some cases we are checking if it is a multireg arg, like: // `numRegs + GetStackSlotsNumber() > 1` that is harder to replace. // unsigned GetStackSlotsNumber() const { return roundUp(GetStackByteSize(), TARGET_POINTER_SIZE) / TARGET_POINTER_SIZE; } private: unsigned _lateArgInx; // index into gtCallLateArgs list; UINT_MAX if this is not a late arg. public: unsigned tmpNum; // the LclVar number if we had to force evaluation of this arg var_types argType; // The type used to pass this argument. This is generally the original argument type, but when a // struct is passed as a scalar type, this is that type. // Note that if a struct is passed by reference, this will still be the struct type. bool needTmp : 1; // True when we force this argument's evaluation into a temp LclVar bool needPlace : 1; // True when we must replace this argument with a placeholder node bool isTmp : 1; // True when we setup a temp LclVar for this argument due to size issues with the struct bool processed : 1; // True when we have decided the evaluation order for this argument in the gtCallLateArgs bool isBackFilled : 1; // True when the argument fills a register slot skipped due to alignment requirements of // previous arguments. NonStandardArgKind nonStandardArgKind : 4; // The non-standard arg kind. Non-standard args are args that are forced // to be in certain registers or on the stack, regardless of where they // appear in the arg list. bool isStruct : 1; // True if this is a struct arg bool _isVararg : 1; // True if the argument is in a vararg context. bool passedByRef : 1; // True iff the argument is passed by reference. #if FEATURE_ARG_SPLIT bool _isSplit : 1; // True when this argument is split between the registers and OutArg area #endif // FEATURE_ARG_SPLIT #ifdef FEATURE_HFA_FIELDS_PRESENT CorInfoHFAElemType _hfaElemKind : 3; // What kind of an HFA this is (CORINFO_HFA_ELEM_NONE if it is not an HFA). #endif CorInfoHFAElemType GetHfaElemKind() const { #ifdef FEATURE_HFA_FIELDS_PRESENT return _hfaElemKind; #else NOWAY_MSG("GetHfaElemKind"); return CORINFO_HFA_ELEM_NONE; #endif } void SetHfaElemKind(CorInfoHFAElemType elemKind) { #ifdef FEATURE_HFA_FIELDS_PRESENT _hfaElemKind = elemKind; #else NOWAY_MSG("SetHfaElemKind"); #endif } bool isNonStandard() const { return nonStandardArgKind != NonStandardArgKind::None; } // Returns true if the IR node for this non-standarg arg is added by fgInitArgInfo. // In this case, it must be removed by GenTreeCall::ResetArgInfo. bool isNonStandardArgAddedLate() const { switch (static_cast<NonStandardArgKind>(nonStandardArgKind)) { case NonStandardArgKind::None: case NonStandardArgKind::PInvokeFrame: case NonStandardArgKind::ShiftLow: case NonStandardArgKind::ShiftHigh: case NonStandardArgKind::FixedRetBuffer: case NonStandardArgKind::ValidateIndirectCallTarget: return false; case NonStandardArgKind::WrapperDelegateCell: case NonStandardArgKind::VirtualStubCell: case NonStandardArgKind::PInvokeCookie: case NonStandardArgKind::PInvokeTarget: case NonStandardArgKind::R2RIndirectionCell: return true; default: unreached(); } } bool isLateArg() const { bool isLate = (_lateArgInx != UINT_MAX); return isLate; } unsigned GetLateArgInx() const { assert(isLateArg()); return _lateArgInx; } void SetLateArgInx(unsigned inx) { _lateArgInx = inx; } regNumber GetRegNum() const { return (regNumber)regNums[0]; } regNumber GetOtherRegNum() const { return (regNumber)regNums[1]; } #if defined(UNIX_AMD64_ABI) SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR structDesc; #endif void setRegNum(unsigned int i, regNumber regNum) { assert(i < MAX_ARG_REG_COUNT); regNums[i] = (regNumberSmall)regNum; } regNumber GetRegNum(unsigned int i) { assert(i < MAX_ARG_REG_COUNT); return (regNumber)regNums[i]; } bool IsSplit() const { #if FEATURE_ARG_SPLIT return compFeatureArgSplit() && _isSplit; #else // FEATURE_ARG_SPLIT return false; #endif } void SetSplit(bool value) { #if FEATURE_ARG_SPLIT _isSplit = value; #endif } bool IsVararg() const { return compFeatureVarArg() && _isVararg; } void SetIsVararg(bool value) { if (compFeatureVarArg()) { _isVararg = value; } } bool IsHfaArg() const { if (GlobalJitOptions::compFeatureHfa) { return IsHfa(GetHfaElemKind()); } else { return false; } } bool IsHfaRegArg() const { if (GlobalJitOptions::compFeatureHfa) { return IsHfa(GetHfaElemKind()) && isPassedInRegisters(); } else { return false; } } unsigned intRegCount() const { #if defined(UNIX_AMD64_ABI) if (this->isStruct) { return this->structIntRegs; } #endif // defined(UNIX_AMD64_ABI) if (!this->isPassedInFloatRegisters()) { return this->numRegs; } return 0; } unsigned floatRegCount() const { #if defined(UNIX_AMD64_ABI) if (this->isStruct) { return this->structFloatRegs; } #endif // defined(UNIX_AMD64_ABI) if (this->isPassedInFloatRegisters()) { return this->numRegs; } return 0; } // Get the number of bytes that this argument is occupying on the stack, // including padding up to the target pointer size for platforms // where a stack argument can't take less. unsigned GetStackByteSize() const { if (!IsSplit() && numRegs > 0) { return 0; } assert(!IsHfaArg() || !IsSplit()); assert(GetByteSize() > TARGET_POINTER_SIZE * numRegs); const unsigned stackByteSize = GetByteSize() - TARGET_POINTER_SIZE * numRegs; return stackByteSize; } var_types GetHfaType() const { if (GlobalJitOptions::compFeatureHfa) { return HfaTypeFromElemKind(GetHfaElemKind()); } else { return TYP_UNDEF; } } void SetHfaType(var_types type, unsigned hfaSlots) { if (GlobalJitOptions::compFeatureHfa) { if (type != TYP_UNDEF) { // We must already have set the passing mode. assert(numRegs != 0 || GetStackByteSize() != 0); // We originally set numRegs according to the size of the struct, but if the size of the // hfaType is not the same as the pointer size, we need to correct it. // Note that hfaSlots is the number of registers we will use. For ARM, that is twice // the number of "double registers". unsigned numHfaRegs = hfaSlots; #ifdef TARGET_ARM if (type == TYP_DOUBLE) { // Must be an even number of registers. assert((numRegs & 1) == 0); numHfaRegs = hfaSlots / 2; } #endif // TARGET_ARM if (!IsHfaArg()) { // We haven't previously set this; do so now. CorInfoHFAElemType elemKind = HfaElemKindFromType(type); SetHfaElemKind(elemKind); // Ensure we've allocated enough bits. assert(GetHfaElemKind() == elemKind); if (isPassedInRegisters()) { numRegs = numHfaRegs; } } else { // We've already set this; ensure that it's consistent. if (isPassedInRegisters()) { assert(numRegs == numHfaRegs); } assert(type == HfaTypeFromElemKind(GetHfaElemKind())); } } } } #ifdef TARGET_ARM void SetIsBackFilled(bool backFilled) { isBackFilled = backFilled; } bool IsBackFilled() const { return isBackFilled; } #else // !TARGET_ARM void SetIsBackFilled(bool backFilled) { } bool IsBackFilled() const { return false; } #endif // !TARGET_ARM bool isPassedInRegisters() const { return !IsSplit() && (numRegs != 0); } bool isPassedInFloatRegisters() const { #ifdef TARGET_X86 return false; #else return isValidFloatArgReg(GetRegNum()); #endif } // Can we replace the struct type of this node with a primitive type for argument passing? bool TryPassAsPrimitive() const { return !IsSplit() && ((numRegs == 1) || (m_byteSize <= TARGET_POINTER_SIZE)); } #if defined(DEBUG_ARG_SLOTS) // Returns the number of "slots" used, where for this purpose a // register counts as a slot. unsigned getSlotCount() const { if (isBackFilled) { assert(isPassedInRegisters()); assert(numRegs == 1); } else if (GetRegNum() == REG_STK) { assert(!isPassedInRegisters()); assert(numRegs == 0); } else { assert(numRegs > 0); } return numSlots + numRegs; } #endif #if defined(DEBUG_ARG_SLOTS) // Returns the size as a multiple of pointer-size. // For targets without HFAs, this is the same as getSlotCount(). unsigned getSize() const { unsigned size = getSlotCount(); if (GlobalJitOptions::compFeatureHfa) { if (IsHfaRegArg()) { #ifdef TARGET_ARM // We counted the number of regs, but if they are DOUBLE hfa regs we have to double the size. if (GetHfaType() == TYP_DOUBLE) { assert(!IsSplit()); size <<= 1; } #elif defined(TARGET_ARM64) // We counted the number of regs, but if they are FLOAT hfa regs we have to halve the size, // or if they are SIMD16 vector hfa regs we have to double the size. if (GetHfaType() == TYP_FLOAT) { // Round up in case of odd HFA count. size = (size + 1) >> 1; } #ifdef FEATURE_SIMD else if (GetHfaType() == TYP_SIMD16) { size <<= 1; } #endif // FEATURE_SIMD #endif // TARGET_ARM64 } } return size; } #endif // DEBUG_ARG_SLOTS private: unsigned m_byteOffset; // byte size that this argument takes including the padding after. // For example, 1-byte arg on x64 with 8-byte alignment // will have `m_byteSize == 8`, the same arg on apple arm64 will have `m_byteSize == 1`. unsigned m_byteSize; unsigned m_byteAlignment; // usually 4 or 8 bytes (slots/registers). public: void SetByteOffset(unsigned byteOffset) { DEBUG_ARG_SLOTS_ASSERT(byteOffset / TARGET_POINTER_SIZE == slotNum); m_byteOffset = byteOffset; } unsigned GetByteOffset() const { DEBUG_ARG_SLOTS_ASSERT(m_byteOffset / TARGET_POINTER_SIZE == slotNum); return m_byteOffset; } void SetByteSize(unsigned byteSize, bool isStruct, bool isFloatHfa) { unsigned roundedByteSize; if (compMacOsArm64Abi()) { // Only struct types need extension or rounding to pointer size, but HFA<float> does not. if (isStruct && !isFloatHfa) { roundedByteSize = roundUp(byteSize, TARGET_POINTER_SIZE); } else { roundedByteSize = byteSize; } } else { roundedByteSize = roundUp(byteSize, TARGET_POINTER_SIZE); } #if !defined(TARGET_ARM) // Arm32 could have a struct with 8 byte alignment // which rounded size % 8 is not 0. assert(m_byteAlignment != 0); assert(roundedByteSize % m_byteAlignment == 0); #endif // TARGET_ARM #if defined(DEBUG_ARG_SLOTS) if (!compMacOsArm64Abi() && !isStruct) { assert(roundedByteSize == getSlotCount() * TARGET_POINTER_SIZE); } #endif m_byteSize = roundedByteSize; } unsigned GetByteSize() const { return m_byteSize; } void SetByteAlignment(unsigned byteAlignment) { m_byteAlignment = byteAlignment; } unsigned GetByteAlignment() const { return m_byteAlignment; } // Set the register numbers for a multireg argument. // There's nothing to do on x64/Ux because the structDesc has already been used to set the // register numbers. void SetMultiRegNums() { #if FEATURE_MULTIREG_ARGS && !defined(UNIX_AMD64_ABI) if (numRegs == 1) { return; } regNumber argReg = GetRegNum(0); #ifdef TARGET_ARM unsigned int regSize = (GetHfaType() == TYP_DOUBLE) ? 2 : 1; #else unsigned int regSize = 1; #endif if (numRegs > MAX_ARG_REG_COUNT) NO_WAY("Multireg argument exceeds the maximum length"); for (unsigned int regIndex = 1; regIndex < numRegs; regIndex++) { argReg = (regNumber)(argReg + regSize); setRegNum(regIndex, argReg); } #endif // FEATURE_MULTIREG_ARGS && !defined(UNIX_AMD64_ABI) } #ifdef DEBUG // Check that the value of 'isStruct' is consistent. // A struct arg must be one of the following: // - A node of struct type, // - A GT_FIELD_LIST, or // - A node of a scalar type, passed in a single register or slot // (or two slots in the case of a struct pass on the stack as TYP_DOUBLE). // void checkIsStruct() const { GenTree* node = GetNode(); if (isStruct) { if (!varTypeIsStruct(node) && !node->OperIs(GT_FIELD_LIST)) { // This is the case where we are passing a struct as a primitive type. // On most targets, this is always a single register or slot. // However, on ARM this could be two slots if it is TYP_DOUBLE. bool isPassedAsPrimitiveType = ((numRegs == 1) || ((numRegs == 0) && (GetByteSize() <= TARGET_POINTER_SIZE))); #ifdef TARGET_ARM if (!isPassedAsPrimitiveType) { if (node->TypeGet() == TYP_DOUBLE && numRegs == 0 && (numSlots == 2)) { isPassedAsPrimitiveType = true; } } #endif // TARGET_ARM assert(isPassedAsPrimitiveType); } } else { assert(!varTypeIsStruct(node)); } } void Dump() const; #endif }; //------------------------------------------------------------------------- // // The class fgArgInfo is used to handle the arguments // when morphing a GT_CALL node. // class fgArgInfo { Compiler* compiler; // Back pointer to the compiler instance so that we can allocate memory GenTreeCall* callTree; // Back pointer to the GT_CALL node for this fgArgInfo unsigned argCount; // Updatable arg count value #if defined(DEBUG_ARG_SLOTS) unsigned nextSlotNum; // Updatable slot count value #endif unsigned nextStackByteOffset; unsigned stkLevel; // Stack depth when we make this call (for x86) #if defined(UNIX_X86_ABI) bool alignmentDone; // Updateable flag, set to 'true' after we've done any required alignment. unsigned stkSizeBytes; // Size of stack used by this call, in bytes. Calculated during fgMorphArgs(). unsigned padStkAlign; // Stack alignment in bytes required before arguments are pushed for this call. // Computed dynamically during codegen, based on stkSizeBytes and the current // stack level (genStackLevel) when the first stack adjustment is made for // this call. #endif #if FEATURE_FIXED_OUT_ARGS unsigned outArgSize; // Size of the out arg area for the call, will be at least MIN_ARG_AREA_FOR_CALL #endif unsigned argTableSize; // size of argTable array (equal to the argCount when done with fgMorphArgs) bool hasRegArgs; // true if we have one or more register arguments bool hasStackArgs; // true if we have one or more stack arguments bool argsComplete; // marker for state bool argsSorted; // marker for state bool needsTemps; // one or more arguments must be copied to a temp by EvalArgsToTemps fgArgTabEntry** argTable; // variable sized array of per argument descrption: (i.e. argTable[argTableSize]) private: void AddArg(fgArgTabEntry* curArgTabEntry); public: fgArgInfo(Compiler* comp, GenTreeCall* call, unsigned argCount); fgArgInfo(GenTreeCall* newCall, GenTreeCall* oldCall); fgArgTabEntry* AddRegArg(unsigned argNum, GenTree* node, GenTreeCall::Use* use, regNumber regNum, unsigned numRegs, unsigned byteSize, unsigned byteAlignment, bool isStruct, bool isFloatHfa, bool isVararg = false); #ifdef UNIX_AMD64_ABI fgArgTabEntry* AddRegArg(unsigned argNum, GenTree* node, GenTreeCall::Use* use, regNumber regNum, unsigned numRegs, unsigned byteSize, unsigned byteAlignment, const bool isStruct, const bool isFloatHfa, const bool isVararg, const regNumber otherRegNum, const unsigned structIntRegs, const unsigned structFloatRegs, const SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR* const structDescPtr = nullptr); #endif // UNIX_AMD64_ABI fgArgTabEntry* AddStkArg(unsigned argNum, GenTree* node, GenTreeCall::Use* use, unsigned numSlots, unsigned byteSize, unsigned byteAlignment, bool isStruct, bool isFloatHfa, bool isVararg = false); void RemorphReset(); void UpdateRegArg(fgArgTabEntry* argEntry, GenTree* node, bool reMorphing); void UpdateStkArg(fgArgTabEntry* argEntry, GenTree* node, bool reMorphing); void SplitArg(unsigned argNum, unsigned numRegs, unsigned numSlots); void EvalToTmp(fgArgTabEntry* curArgTabEntry, unsigned tmpNum, GenTree* newNode); void ArgsComplete(); void SortArgs(); void EvalArgsToTemps(); unsigned ArgCount() const { return argCount; } fgArgTabEntry** ArgTable() const { return argTable; } #if defined(DEBUG_ARG_SLOTS) unsigned GetNextSlotNum() const { return nextSlotNum; } #endif unsigned GetNextSlotByteOffset() const { return nextStackByteOffset; } bool HasRegArgs() const { return hasRegArgs; } bool NeedsTemps() const { return needsTemps; } bool HasStackArgs() const { return hasStackArgs; } bool AreArgsComplete() const { return argsComplete; } #if FEATURE_FIXED_OUT_ARGS unsigned GetOutArgSize() const { return outArgSize; } void SetOutArgSize(unsigned newVal) { outArgSize = newVal; } #endif // FEATURE_FIXED_OUT_ARGS #if defined(UNIX_X86_ABI) void ComputeStackAlignment(unsigned curStackLevelInBytes) { padStkAlign = AlignmentPad(curStackLevelInBytes, STACK_ALIGN); } unsigned GetStkAlign() const { return padStkAlign; } void SetStkSizeBytes(unsigned newStkSizeBytes) { stkSizeBytes = newStkSizeBytes; } unsigned GetStkSizeBytes() const { return stkSizeBytes; } bool IsStkAlignmentDone() const { return alignmentDone; } void SetStkAlignmentDone() { alignmentDone = true; } #endif // defined(UNIX_X86_ABI) // Get the fgArgTabEntry for the arg at position argNum. fgArgTabEntry* GetArgEntry(unsigned argNum, bool reMorphing = true) const { fgArgTabEntry* curArgTabEntry = nullptr; if (!reMorphing) { // The arg table has not yet been sorted. curArgTabEntry = argTable[argNum]; assert(curArgTabEntry->argNum == argNum); return curArgTabEntry; } for (unsigned i = 0; i < argCount; i++) { curArgTabEntry = argTable[i]; if (curArgTabEntry->argNum == argNum) { return curArgTabEntry; } } noway_assert(!"GetArgEntry: argNum not found"); return nullptr; } void SetNeedsTemps() { needsTemps = true; } // Get the node for the arg at position argIndex. // Caller must ensure that this index is a valid arg index. GenTree* GetArgNode(unsigned argIndex) const { return GetArgEntry(argIndex)->GetNode(); } void Dump(Compiler* compiler) const; }; #ifdef DEBUG // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // We have the ability to mark source expressions with "Test Labels." // These drive assertions within the JIT, or internal JIT testing. For example, we could label expressions // that should be CSE defs, and other expressions that should uses of those defs, with a shared label. enum TestLabel // This must be kept identical to System.Runtime.CompilerServices.JitTestLabel.TestLabel. { TL_SsaName, TL_VN, // Defines a "VN equivalence class". (For full VN, including exceptions thrown). TL_VNNorm, // Like above, but uses the non-exceptional value of the expression. TL_CSE_Def, // This must be identified in the JIT as a CSE def TL_CSE_Use, // This must be identified in the JIT as a CSE use TL_LoopHoist, // Expression must (or must not) be hoisted out of the loop. }; struct TestLabelAndNum { TestLabel m_tl; ssize_t m_num; TestLabelAndNum() : m_tl(TestLabel(0)), m_num(0) { } }; typedef JitHashTable<GenTree*, JitPtrKeyFuncs<GenTree>, TestLabelAndNum> NodeToTestDataMap; // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #endif // DEBUG //------------------------------------------------------------------------- // LoopFlags: flags for the loop table. // enum LoopFlags : unsigned short { LPFLG_EMPTY = 0, // LPFLG_UNUSED = 0x0001, // LPFLG_UNUSED = 0x0002, LPFLG_ITER = 0x0004, // loop of form: for (i = icon or lclVar; test_condition(); i++) // LPFLG_UNUSED = 0x0008, LPFLG_CONTAINS_CALL = 0x0010, // If executing the loop body *may* execute a call LPFLG_VAR_INIT = 0x0020, // iterator is initialized with a local var (var # found in lpVarInit) LPFLG_CONST_INIT = 0x0040, // iterator is initialized with a constant (found in lpConstInit) LPFLG_SIMD_LIMIT = 0x0080, // iterator is compared with vector element count (found in lpConstLimit) LPFLG_VAR_LIMIT = 0x0100, // iterator is compared with a local var (var # found in lpVarLimit) LPFLG_CONST_LIMIT = 0x0200, // iterator is compared with a constant (found in lpConstLimit) LPFLG_ARRLEN_LIMIT = 0x0400, // iterator is compared with a.len or a[i].len (found in lpArrLenLimit) LPFLG_HAS_PREHEAD = 0x0800, // lpHead is known to be a preHead for this loop LPFLG_REMOVED = 0x1000, // has been removed from the loop table (unrolled or optimized away) LPFLG_DONT_UNROLL = 0x2000, // do not unroll this loop LPFLG_ASGVARS_YES = 0x4000, // "lpAsgVars" has been computed LPFLG_ASGVARS_INC = 0x8000, // "lpAsgVars" is incomplete -- vars beyond those representable in an AllVarSet // type are assigned to. }; inline constexpr LoopFlags operator~(LoopFlags a) { return (LoopFlags)(~(unsigned short)a); } inline constexpr LoopFlags operator|(LoopFlags a, LoopFlags b) { return (LoopFlags)((unsigned short)a | (unsigned short)b); } inline constexpr LoopFlags operator&(LoopFlags a, LoopFlags b) { return (LoopFlags)((unsigned short)a & (unsigned short)b); } inline LoopFlags& operator|=(LoopFlags& a, LoopFlags b) { return a = (LoopFlags)((unsigned short)a | (unsigned short)b); } inline LoopFlags& operator&=(LoopFlags& a, LoopFlags b) { return a = (LoopFlags)((unsigned short)a & (unsigned short)b); } // The following holds information about instr offsets in terms of generated code. enum class IPmappingDscKind { Prolog, // The mapping represents the start of a prolog. Epilog, // The mapping represents the start of an epilog. NoMapping, // This does not map to any IL offset. Normal, // The mapping maps to an IL offset. }; struct IPmappingDsc { emitLocation ipmdNativeLoc; // the emitter location of the native code corresponding to the IL offset IPmappingDscKind ipmdKind; // The kind of mapping ILLocation ipmdLoc; // The location for normal mappings bool ipmdIsLabel; // Can this code be a branch label? }; struct PreciseIPMapping { emitLocation nativeLoc; DebugInfo debugInfo; }; /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX The big guy. The sections are currently organized as : XX XX XX XX o GenTree and BasicBlock XX XX o LclVarsInfo XX XX o Importer XX XX o FlowGraph XX XX o Optimizer XX XX o RegAlloc XX XX o EEInterface XX XX o TempsInfo XX XX o RegSet XX XX o GCInfo XX XX o Instruction XX XX o ScopeInfo XX XX o PrologScopeInfo XX XX o CodeGenerator XX XX o UnwindInfo XX XX o Compiler XX XX o typeInfo XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ struct HWIntrinsicInfo; class Compiler { friend class emitter; friend class UnwindInfo; friend class UnwindFragmentInfo; friend class UnwindEpilogInfo; friend class JitTimer; friend class LinearScan; friend class fgArgInfo; friend class Rationalizer; friend class Phase; friend class Lowering; friend class CSE_DataFlow; friend class CSE_Heuristic; friend class CodeGenInterface; friend class CodeGen; friend class LclVarDsc; friend class TempDsc; friend class LIR; friend class ObjectAllocator; friend class LocalAddressVisitor; friend struct GenTree; friend class MorphInitBlockHelper; friend class MorphCopyBlockHelper; #ifdef FEATURE_HW_INTRINSICS friend struct HWIntrinsicInfo; #endif // FEATURE_HW_INTRINSICS #ifndef TARGET_64BIT friend class DecomposeLongs; #endif // !TARGET_64BIT /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX Misc structs definitions XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ public: hashBvGlobalData hbvGlobalData; // Used by the hashBv bitvector package. #ifdef DEBUG bool verbose; bool verboseTrees; bool shouldUseVerboseTrees(); bool asciiTrees; // If true, dump trees using only ASCII characters bool shouldDumpASCIITrees(); bool verboseSsa; // If true, produce especially verbose dump output in SSA construction. bool shouldUseVerboseSsa(); bool treesBeforeAfterMorph; // If true, print trees before/after morphing (paired by an intra-compilation id: int morphNum; // This counts the the trees that have been morphed, allowing us to label each uniquely. bool doExtraSuperPmiQueries; void makeExtraStructQueries(CORINFO_CLASS_HANDLE structHandle, int level); // Make queries recursively 'level' deep. const char* VarNameToStr(VarName name) { return name; } DWORD expensiveDebugCheckLevel; #endif #if FEATURE_MULTIREG_RET GenTree* impAssignMultiRegTypeToVar(GenTree* op, CORINFO_CLASS_HANDLE hClass DEBUGARG(CorInfoCallConvExtension callConv)); #endif // FEATURE_MULTIREG_RET #ifdef TARGET_X86 bool isTrivialPointerSizedStruct(CORINFO_CLASS_HANDLE clsHnd) const; #endif // TARGET_X86 //------------------------------------------------------------------------- // Functions to handle homogeneous floating-point aggregates (HFAs) in ARM/ARM64. // HFAs are one to four element structs where each element is the same // type, either all float or all double. We handle HVAs (one to four elements of // vector types) uniformly with HFAs. HFAs are treated specially // in the ARM/ARM64 Procedure Call Standards, specifically, they are passed in // floating-point registers instead of the general purpose registers. // bool IsHfa(CORINFO_CLASS_HANDLE hClass); bool IsHfa(GenTree* tree); var_types GetHfaType(GenTree* tree); unsigned GetHfaCount(GenTree* tree); var_types GetHfaType(CORINFO_CLASS_HANDLE hClass); unsigned GetHfaCount(CORINFO_CLASS_HANDLE hClass); bool IsMultiRegReturnedType(CORINFO_CLASS_HANDLE hClass, CorInfoCallConvExtension callConv); //------------------------------------------------------------------------- // The following is used for validating format of EH table // struct EHNodeDsc; typedef struct EHNodeDsc* pEHNodeDsc; EHNodeDsc* ehnTree; // root of the tree comprising the EHnodes. EHNodeDsc* ehnNext; // root of the tree comprising the EHnodes. struct EHNodeDsc { enum EHBlockType { TryNode, FilterNode, HandlerNode, FinallyNode, FaultNode }; EHBlockType ehnBlockType; // kind of EH block IL_OFFSET ehnStartOffset; // IL offset of start of the EH block IL_OFFSET ehnEndOffset; // IL offset past end of the EH block. (TODO: looks like verInsertEhNode() sets this to // the last IL offset, not "one past the last one", i.e., the range Start to End is // inclusive). pEHNodeDsc ehnNext; // next (non-nested) block in sequential order pEHNodeDsc ehnChild; // leftmost nested block union { pEHNodeDsc ehnTryNode; // for filters and handlers, the corresponding try node pEHNodeDsc ehnHandlerNode; // for a try node, the corresponding handler node }; pEHNodeDsc ehnFilterNode; // if this is a try node and has a filter, otherwise 0 pEHNodeDsc ehnEquivalent; // if blockType=tryNode, start offset and end offset is same, void ehnSetTryNodeType() { ehnBlockType = TryNode; } void ehnSetFilterNodeType() { ehnBlockType = FilterNode; } void ehnSetHandlerNodeType() { ehnBlockType = HandlerNode; } void ehnSetFinallyNodeType() { ehnBlockType = FinallyNode; } void ehnSetFaultNodeType() { ehnBlockType = FaultNode; } bool ehnIsTryBlock() { return ehnBlockType == TryNode; } bool ehnIsFilterBlock() { return ehnBlockType == FilterNode; } bool ehnIsHandlerBlock() { return ehnBlockType == HandlerNode; } bool ehnIsFinallyBlock() { return ehnBlockType == FinallyNode; } bool ehnIsFaultBlock() { return ehnBlockType == FaultNode; } // returns true if there is any overlap between the two nodes static bool ehnIsOverlap(pEHNodeDsc node1, pEHNodeDsc node2) { if (node1->ehnStartOffset < node2->ehnStartOffset) { return (node1->ehnEndOffset >= node2->ehnStartOffset); } else { return (node1->ehnStartOffset <= node2->ehnEndOffset); } } // fails with BADCODE if inner is not completely nested inside outer static bool ehnIsNested(pEHNodeDsc inner, pEHNodeDsc outer) { return ((inner->ehnStartOffset >= outer->ehnStartOffset) && (inner->ehnEndOffset <= outer->ehnEndOffset)); } }; //------------------------------------------------------------------------- // Exception handling functions // #if !defined(FEATURE_EH_FUNCLETS) bool ehNeedsShadowSPslots() { return (info.compXcptnsCount || opts.compDbgEnC); } // 0 for methods with no EH // 1 for methods with non-nested EH, or where only the try blocks are nested // 2 for a method with a catch within a catch // etc. unsigned ehMaxHndNestingCount; #endif // !FEATURE_EH_FUNCLETS static bool jitIsBetween(unsigned value, unsigned start, unsigned end); static bool jitIsBetweenInclusive(unsigned value, unsigned start, unsigned end); bool bbInCatchHandlerILRange(BasicBlock* blk); bool bbInFilterILRange(BasicBlock* blk); bool bbInTryRegions(unsigned regionIndex, BasicBlock* blk); bool bbInExnFlowRegions(unsigned regionIndex, BasicBlock* blk); bool bbInHandlerRegions(unsigned regionIndex, BasicBlock* blk); bool bbInCatchHandlerRegions(BasicBlock* tryBlk, BasicBlock* hndBlk); unsigned short bbFindInnermostCommonTryRegion(BasicBlock* bbOne, BasicBlock* bbTwo); unsigned short bbFindInnermostTryRegionContainingHandlerRegion(unsigned handlerIndex); unsigned short bbFindInnermostHandlerRegionContainingTryRegion(unsigned tryIndex); // Returns true if "block" is the start of a try region. bool bbIsTryBeg(BasicBlock* block); // Returns true if "block" is the start of a handler or filter region. bool bbIsHandlerBeg(BasicBlock* block); // Returns true iff "block" is where control flows if an exception is raised in the // try region, and sets "*regionIndex" to the index of the try for the handler. // Differs from "IsHandlerBeg" in the case of filters, where this is true for the first // block of the filter, but not for the filter's handler. bool bbIsExFlowBlock(BasicBlock* block, unsigned* regionIndex); bool ehHasCallableHandlers(); // Return the EH descriptor for the given region index. EHblkDsc* ehGetDsc(unsigned regionIndex); // Return the EH index given a region descriptor. unsigned ehGetIndex(EHblkDsc* ehDsc); // Return the EH descriptor index of the enclosing try, for the given region index. unsigned ehGetEnclosingTryIndex(unsigned regionIndex); // Return the EH descriptor index of the enclosing handler, for the given region index. unsigned ehGetEnclosingHndIndex(unsigned regionIndex); // Return the EH descriptor for the most nested 'try' region this BasicBlock is a member of (or nullptr if this // block is not in a 'try' region). EHblkDsc* ehGetBlockTryDsc(BasicBlock* block); // Return the EH descriptor for the most nested filter or handler region this BasicBlock is a member of (or nullptr // if this block is not in a filter or handler region). EHblkDsc* ehGetBlockHndDsc(BasicBlock* block); // Return the EH descriptor for the most nested region that may handle exceptions raised in this BasicBlock (or // nullptr if this block's exceptions propagate to caller). EHblkDsc* ehGetBlockExnFlowDsc(BasicBlock* block); EHblkDsc* ehIsBlockTryLast(BasicBlock* block); EHblkDsc* ehIsBlockHndLast(BasicBlock* block); bool ehIsBlockEHLast(BasicBlock* block); bool ehBlockHasExnFlowDsc(BasicBlock* block); // Return the region index of the most nested EH region this block is in. unsigned ehGetMostNestedRegionIndex(BasicBlock* block, bool* inTryRegion); // Find the true enclosing try index, ignoring 'mutual protect' try. Uses IL ranges to check. unsigned ehTrueEnclosingTryIndexIL(unsigned regionIndex); // Return the index of the most nested enclosing region for a particular EH region. Returns NO_ENCLOSING_INDEX // if there is no enclosing region. If the returned index is not NO_ENCLOSING_INDEX, then '*inTryRegion' // is set to 'true' if the enclosing region is a 'try', or 'false' if the enclosing region is a handler. // (It can never be a filter.) unsigned ehGetEnclosingRegionIndex(unsigned regionIndex, bool* inTryRegion); // A block has been deleted. Update the EH table appropriately. void ehUpdateForDeletedBlock(BasicBlock* block); // Determine whether a block can be deleted while preserving the EH normalization rules. bool ehCanDeleteEmptyBlock(BasicBlock* block); // Update the 'last' pointers in the EH table to reflect new or deleted blocks in an EH region. void ehUpdateLastBlocks(BasicBlock* oldLast, BasicBlock* newLast); // For a finally handler, find the region index that the BBJ_CALLFINALLY lives in that calls the handler, // or NO_ENCLOSING_INDEX if the BBJ_CALLFINALLY lives in the main function body. Normally, the index // is the same index as the handler (and the BBJ_CALLFINALLY lives in the 'try' region), but for AMD64 the // BBJ_CALLFINALLY lives in the enclosing try or handler region, whichever is more nested, or the main function // body. If the returned index is not NO_ENCLOSING_INDEX, then '*inTryRegion' is set to 'true' if the // BBJ_CALLFINALLY lives in the returned index's 'try' region, or 'false' if lives in the handler region. (It never // lives in a filter.) unsigned ehGetCallFinallyRegionIndex(unsigned finallyIndex, bool* inTryRegion); // Find the range of basic blocks in which all BBJ_CALLFINALLY will be found that target the 'finallyIndex' region's // handler. Set begBlk to the first block, and endBlk to the block after the last block of the range // (nullptr if the last block is the last block in the program). // Precondition: 'finallyIndex' is the EH region of a try/finally clause. void ehGetCallFinallyBlockRange(unsigned finallyIndex, BasicBlock** begBlk, BasicBlock** endBlk); #ifdef DEBUG // Given a BBJ_CALLFINALLY block and the EH region index of the finally it is calling, return // 'true' if the BBJ_CALLFINALLY is in the correct EH region. bool ehCallFinallyInCorrectRegion(BasicBlock* blockCallFinally, unsigned finallyIndex); #endif // DEBUG #if defined(FEATURE_EH_FUNCLETS) // Do we need a PSPSym in the main function? For codegen purposes, we only need one // if there is a filter that protects a region with a nested EH clause (such as a // try/catch nested in the 'try' body of a try/filter/filter-handler). See // genFuncletProlog() for more details. However, the VM seems to use it for more // purposes, maybe including debugging. Until we are sure otherwise, always create // a PSPSym for functions with any EH. bool ehNeedsPSPSym() const { #ifdef TARGET_X86 return false; #else // TARGET_X86 return compHndBBtabCount > 0; #endif // TARGET_X86 } bool ehAnyFunclets(); // Are there any funclets in this function? unsigned ehFuncletCount(); // Return the count of funclets in the function unsigned bbThrowIndex(BasicBlock* blk); // Get the index to use as the cache key for sharing throw blocks #else // !FEATURE_EH_FUNCLETS bool ehAnyFunclets() { return false; } unsigned ehFuncletCount() { return 0; } unsigned bbThrowIndex(BasicBlock* blk) { return blk->bbTryIndex; } // Get the index to use as the cache key for sharing throw blocks #endif // !FEATURE_EH_FUNCLETS // Returns a flowList representing the "EH predecessors" of "blk". These are the normal predecessors of // "blk", plus one special case: if "blk" is the first block of a handler, considers the predecessor(s) of the first // first block of the corresponding try region to be "EH predecessors". (If there is a single such predecessor, // for example, we want to consider that the immediate dominator of the catch clause start block, so it's // convenient to also consider it a predecessor.) flowList* BlockPredsWithEH(BasicBlock* blk); // This table is useful for memoization of the method above. typedef JitHashTable<BasicBlock*, JitPtrKeyFuncs<BasicBlock>, flowList*> BlockToFlowListMap; BlockToFlowListMap* m_blockToEHPreds; BlockToFlowListMap* GetBlockToEHPreds() { if (m_blockToEHPreds == nullptr) { m_blockToEHPreds = new (getAllocator()) BlockToFlowListMap(getAllocator()); } return m_blockToEHPreds; } void* ehEmitCookie(BasicBlock* block); UNATIVE_OFFSET ehCodeOffset(BasicBlock* block); EHblkDsc* ehInitHndRange(BasicBlock* src, IL_OFFSET* hndBeg, IL_OFFSET* hndEnd, bool* inFilter); EHblkDsc* ehInitTryRange(BasicBlock* src, IL_OFFSET* tryBeg, IL_OFFSET* tryEnd); EHblkDsc* ehInitHndBlockRange(BasicBlock* blk, BasicBlock** hndBeg, BasicBlock** hndLast, bool* inFilter); EHblkDsc* ehInitTryBlockRange(BasicBlock* blk, BasicBlock** tryBeg, BasicBlock** tryLast); void fgSetTryBeg(EHblkDsc* handlerTab, BasicBlock* newTryBeg); void fgSetTryEnd(EHblkDsc* handlerTab, BasicBlock* newTryLast); void fgSetHndEnd(EHblkDsc* handlerTab, BasicBlock* newHndLast); void fgSkipRmvdBlocks(EHblkDsc* handlerTab); void fgAllocEHTable(); void fgRemoveEHTableEntry(unsigned XTnum); #if defined(FEATURE_EH_FUNCLETS) EHblkDsc* fgAddEHTableEntry(unsigned XTnum); #endif // FEATURE_EH_FUNCLETS #if !FEATURE_EH void fgRemoveEH(); #endif // !FEATURE_EH void fgSortEHTable(); // Causes the EH table to obey some well-formedness conditions, by inserting // empty BB's when necessary: // * No block is both the first block of a handler and the first block of a try. // * No block is the first block of multiple 'try' regions. // * No block is the last block of multiple EH regions. void fgNormalizeEH(); bool fgNormalizeEHCase1(); bool fgNormalizeEHCase2(); bool fgNormalizeEHCase3(); void fgCheckForLoopsInHandlers(); #ifdef DEBUG void dispIncomingEHClause(unsigned num, const CORINFO_EH_CLAUSE& clause); void dispOutgoingEHClause(unsigned num, const CORINFO_EH_CLAUSE& clause); void fgVerifyHandlerTab(); void fgDispHandlerTab(); #endif // DEBUG bool fgNeedToSortEHTable; void verInitEHTree(unsigned numEHClauses); void verInsertEhNode(CORINFO_EH_CLAUSE* clause, EHblkDsc* handlerTab); void verInsertEhNodeInTree(EHNodeDsc** ppRoot, EHNodeDsc* node); void verInsertEhNodeParent(EHNodeDsc** ppRoot, EHNodeDsc* node); void verCheckNestingLevel(EHNodeDsc* initRoot); /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX GenTree and BasicBlock XX XX XX XX Functions to allocate and display the GenTrees and BasicBlocks XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ // Functions to create nodes Statement* gtNewStmt(GenTree* expr = nullptr); Statement* gtNewStmt(GenTree* expr, const DebugInfo& di); // For unary opers. GenTree* gtNewOperNode(genTreeOps oper, var_types type, GenTree* op1, bool doSimplifications = TRUE); // For binary opers. GenTree* gtNewOperNode(genTreeOps oper, var_types type, GenTree* op1, GenTree* op2); GenTreeQmark* gtNewQmarkNode(var_types type, GenTree* cond, GenTreeColon* colon); GenTree* gtNewLargeOperNode(genTreeOps oper, var_types type = TYP_I_IMPL, GenTree* op1 = nullptr, GenTree* op2 = nullptr); GenTreeIntCon* gtNewIconNode(ssize_t value, var_types type = TYP_INT); GenTreeIntCon* gtNewIconNode(unsigned fieldOffset, FieldSeqNode* fieldSeq); GenTree* gtNewPhysRegNode(regNumber reg, var_types type); GenTree* gtNewJmpTableNode(); GenTree* gtNewIndOfIconHandleNode(var_types indType, size_t value, GenTreeFlags iconFlags, bool isInvariant); GenTree* gtNewIconHandleNode(size_t value, GenTreeFlags flags, FieldSeqNode* fields = nullptr); GenTreeFlags gtTokenToIconFlags(unsigned token); GenTree* gtNewIconEmbHndNode(void* value, void* pValue, GenTreeFlags flags, void* compileTimeHandle); GenTree* gtNewIconEmbScpHndNode(CORINFO_MODULE_HANDLE scpHnd); GenTree* gtNewIconEmbClsHndNode(CORINFO_CLASS_HANDLE clsHnd); GenTree* gtNewIconEmbMethHndNode(CORINFO_METHOD_HANDLE methHnd); GenTree* gtNewIconEmbFldHndNode(CORINFO_FIELD_HANDLE fldHnd); GenTree* gtNewStringLiteralNode(InfoAccessType iat, void* pValue); GenTreeIntCon* gtNewStringLiteralLength(GenTreeStrCon* node); GenTree* gtNewLconNode(__int64 value); GenTree* gtNewDconNode(double value, var_types type = TYP_DOUBLE); GenTree* gtNewSconNode(int CPX, CORINFO_MODULE_HANDLE scpHandle); GenTree* gtNewZeroConNode(var_types type); GenTree* gtNewOneConNode(var_types type); GenTreeLclVar* gtNewStoreLclVar(unsigned dstLclNum, GenTree* src); #ifdef FEATURE_SIMD GenTree* gtNewSIMDVectorZero(var_types simdType, CorInfoType simdBaseJitType, unsigned simdSize); #endif GenTree* gtNewBlkOpNode(GenTree* dst, GenTree* srcOrFillVal, bool isVolatile, bool isCopyBlock); GenTree* gtNewPutArgReg(var_types type, GenTree* arg, regNumber argReg); GenTree* gtNewBitCastNode(var_types type, GenTree* arg); protected: void gtBlockOpInit(GenTree* result, GenTree* dst, GenTree* srcOrFillVal, bool isVolatile); public: GenTreeObj* gtNewObjNode(CORINFO_CLASS_HANDLE structHnd, GenTree* addr); void gtSetObjGcInfo(GenTreeObj* objNode); GenTree* gtNewStructVal(CORINFO_CLASS_HANDLE structHnd, GenTree* addr); GenTree* gtNewBlockVal(GenTree* addr, unsigned size); GenTree* gtNewCpObjNode(GenTree* dst, GenTree* src, CORINFO_CLASS_HANDLE structHnd, bool isVolatile); GenTreeCall::Use* gtNewCallArgs(GenTree* node); GenTreeCall::Use* gtNewCallArgs(GenTree* node1, GenTree* node2); GenTreeCall::Use* gtNewCallArgs(GenTree* node1, GenTree* node2, GenTree* node3); GenTreeCall::Use* gtNewCallArgs(GenTree* node1, GenTree* node2, GenTree* node3, GenTree* node4); GenTreeCall::Use* gtPrependNewCallArg(GenTree* node, GenTreeCall::Use* args); GenTreeCall::Use* gtInsertNewCallArgAfter(GenTree* node, GenTreeCall::Use* after); GenTreeCall* gtNewCallNode(gtCallTypes callType, CORINFO_METHOD_HANDLE handle, var_types type, GenTreeCall::Use* args, const DebugInfo& di = DebugInfo()); GenTreeCall* gtNewIndCallNode(GenTree* addr, var_types type, GenTreeCall::Use* args, const DebugInfo& di = DebugInfo()); GenTreeCall* gtNewHelperCallNode(unsigned helper, var_types type, GenTreeCall::Use* args = nullptr); GenTreeCall* gtNewRuntimeLookupHelperCallNode(CORINFO_RUNTIME_LOOKUP* pRuntimeLookup, GenTree* ctxTree, void* compileTimeHandle); GenTreeLclVar* gtNewLclvNode(unsigned lnum, var_types type DEBUGARG(IL_OFFSET offs = BAD_IL_OFFSET)); GenTreeLclVar* gtNewLclLNode(unsigned lnum, var_types type DEBUGARG(IL_OFFSET offs = BAD_IL_OFFSET)); GenTreeLclVar* gtNewLclVarAddrNode(unsigned lclNum, var_types type = TYP_I_IMPL); GenTreeLclFld* gtNewLclFldAddrNode(unsigned lclNum, unsigned lclOffs, FieldSeqNode* fieldSeq, var_types type = TYP_I_IMPL); #ifdef FEATURE_SIMD GenTreeSIMD* gtNewSIMDNode( var_types type, GenTree* op1, SIMDIntrinsicID simdIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize); GenTreeSIMD* gtNewSIMDNode(var_types type, GenTree* op1, GenTree* op2, SIMDIntrinsicID simdIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize); void SetOpLclRelatedToSIMDIntrinsic(GenTree* op); #endif #ifdef FEATURE_HW_INTRINSICS GenTreeHWIntrinsic* gtNewSimdHWIntrinsicNode(var_types type, NamedIntrinsic hwIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic = false); GenTreeHWIntrinsic* gtNewSimdHWIntrinsicNode(var_types type, GenTree* op1, NamedIntrinsic hwIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic = false); GenTreeHWIntrinsic* gtNewSimdHWIntrinsicNode(var_types type, GenTree* op1, GenTree* op2, NamedIntrinsic hwIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic = false); GenTreeHWIntrinsic* gtNewSimdHWIntrinsicNode(var_types type, GenTree* op1, GenTree* op2, GenTree* op3, NamedIntrinsic hwIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic = false); GenTreeHWIntrinsic* gtNewSimdHWIntrinsicNode(var_types type, GenTree* op1, GenTree* op2, GenTree* op3, GenTree* op4, NamedIntrinsic hwIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic = false); GenTreeHWIntrinsic* gtNewSimdHWIntrinsicNode(var_types type, GenTree** operands, size_t operandCount, NamedIntrinsic hwIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic = false); GenTreeHWIntrinsic* gtNewSimdHWIntrinsicNode(var_types type, IntrinsicNodeBuilder&& nodeBuilder, NamedIntrinsic hwIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic = false); GenTreeHWIntrinsic* gtNewSimdAsHWIntrinsicNode(var_types type, NamedIntrinsic hwIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize) { bool isSimdAsHWIntrinsic = true; return gtNewSimdHWIntrinsicNode(type, hwIntrinsicID, simdBaseJitType, simdSize, isSimdAsHWIntrinsic); } GenTreeHWIntrinsic* gtNewSimdAsHWIntrinsicNode( var_types type, GenTree* op1, NamedIntrinsic hwIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize) { bool isSimdAsHWIntrinsic = true; return gtNewSimdHWIntrinsicNode(type, op1, hwIntrinsicID, simdBaseJitType, simdSize, isSimdAsHWIntrinsic); } GenTreeHWIntrinsic* gtNewSimdAsHWIntrinsicNode(var_types type, GenTree* op1, GenTree* op2, NamedIntrinsic hwIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize) { bool isSimdAsHWIntrinsic = true; return gtNewSimdHWIntrinsicNode(type, op1, op2, hwIntrinsicID, simdBaseJitType, simdSize, isSimdAsHWIntrinsic); } GenTreeHWIntrinsic* gtNewSimdAsHWIntrinsicNode(var_types type, GenTree* op1, GenTree* op2, GenTree* op3, NamedIntrinsic hwIntrinsicID, CorInfoType simdBaseJitType, unsigned simdSize) { bool isSimdAsHWIntrinsic = true; return gtNewSimdHWIntrinsicNode(type, op1, op2, op3, hwIntrinsicID, simdBaseJitType, simdSize, isSimdAsHWIntrinsic); } GenTree* gtNewSimdAbsNode( var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdBinOpNode(genTreeOps op, var_types type, GenTree* op1, GenTree* op2, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdCeilNode( var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdCmpOpNode(genTreeOps op, var_types type, GenTree* op1, GenTree* op2, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdCmpOpAllNode(genTreeOps op, var_types type, GenTree* op1, GenTree* op2, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdCmpOpAnyNode(genTreeOps op, var_types type, GenTree* op1, GenTree* op2, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdCndSelNode(var_types type, GenTree* op1, GenTree* op2, GenTree* op3, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdCreateBroadcastNode( var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdDotProdNode(var_types type, GenTree* op1, GenTree* op2, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdFloorNode( var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdGetElementNode(var_types type, GenTree* op1, GenTree* op2, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdMaxNode(var_types type, GenTree* op1, GenTree* op2, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdMinNode(var_types type, GenTree* op1, GenTree* op2, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdNarrowNode(var_types type, GenTree* op1, GenTree* op2, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdSqrtNode( var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdSumNode( var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdUnOpNode(genTreeOps op, var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdWidenLowerNode( var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdWidenUpperNode( var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdWithElementNode(var_types type, GenTree* op1, GenTree* op2, GenTree* op3, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTree* gtNewSimdZeroNode(var_types type, CorInfoType simdBaseJitType, unsigned simdSize, bool isSimdAsHWIntrinsic); GenTreeHWIntrinsic* gtNewScalarHWIntrinsicNode(var_types type, NamedIntrinsic hwIntrinsicID); GenTreeHWIntrinsic* gtNewScalarHWIntrinsicNode(var_types type, GenTree* op1, NamedIntrinsic hwIntrinsicID); GenTreeHWIntrinsic* gtNewScalarHWIntrinsicNode(var_types type, GenTree* op1, GenTree* op2, NamedIntrinsic hwIntrinsicID); GenTreeHWIntrinsic* gtNewScalarHWIntrinsicNode( var_types type, GenTree* op1, GenTree* op2, GenTree* op3, NamedIntrinsic hwIntrinsicID); CORINFO_CLASS_HANDLE gtGetStructHandleForHWSIMD(var_types simdType, CorInfoType simdBaseJitType); CorInfoType getBaseJitTypeFromArgIfNeeded(NamedIntrinsic intrinsic, CORINFO_CLASS_HANDLE clsHnd, CORINFO_SIG_INFO* sig, CorInfoType simdBaseJitType); #endif // FEATURE_HW_INTRINSICS GenTree* gtNewMustThrowException(unsigned helper, var_types type, CORINFO_CLASS_HANDLE clsHnd); GenTreeLclFld* gtNewLclFldNode(unsigned lnum, var_types type, unsigned offset); GenTree* gtNewInlineCandidateReturnExpr(GenTree* inlineCandidate, var_types type, BasicBlockFlags bbFlags); GenTree* gtNewFieldRef(var_types type, CORINFO_FIELD_HANDLE fldHnd, GenTree* obj = nullptr, DWORD offset = 0); GenTree* gtNewIndexRef(var_types typ, GenTree* arrayOp, GenTree* indexOp); GenTreeArrLen* gtNewArrLen(var_types typ, GenTree* arrayOp, int lenOffset, BasicBlock* block); GenTreeIndir* gtNewIndir(var_types typ, GenTree* addr); GenTree* gtNewNullCheck(GenTree* addr, BasicBlock* basicBlock); var_types gtTypeForNullCheck(GenTree* tree); void gtChangeOperToNullCheck(GenTree* tree, BasicBlock* block); static fgArgTabEntry* gtArgEntryByArgNum(GenTreeCall* call, unsigned argNum); static fgArgTabEntry* gtArgEntryByNode(GenTreeCall* call, GenTree* node); fgArgTabEntry* gtArgEntryByLateArgIndex(GenTreeCall* call, unsigned lateArgInx); static GenTree* gtArgNodeByLateArgInx(GenTreeCall* call, unsigned lateArgInx); GenTreeOp* gtNewAssignNode(GenTree* dst, GenTree* src); GenTree* gtNewTempAssign(unsigned tmp, GenTree* val, Statement** pAfterStmt = nullptr, const DebugInfo& di = DebugInfo(), BasicBlock* block = nullptr); GenTree* gtNewRefCOMfield(GenTree* objPtr, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_ACCESS_FLAGS access, CORINFO_FIELD_INFO* pFieldInfo, var_types lclTyp, CORINFO_CLASS_HANDLE structType, GenTree* assg); GenTree* gtNewNothingNode(); GenTree* gtNewArgPlaceHolderNode(var_types type, CORINFO_CLASS_HANDLE clsHnd); GenTree* gtUnusedValNode(GenTree* expr); GenTree* gtNewKeepAliveNode(GenTree* op); GenTreeCast* gtNewCastNode(var_types typ, GenTree* op1, bool fromUnsigned, var_types castType); GenTreeCast* gtNewCastNodeL(var_types typ, GenTree* op1, bool fromUnsigned, var_types castType); GenTreeAllocObj* gtNewAllocObjNode( unsigned int helper, bool helperHasSideEffects, CORINFO_CLASS_HANDLE clsHnd, var_types type, GenTree* op1); GenTreeAllocObj* gtNewAllocObjNode(CORINFO_RESOLVED_TOKEN* pResolvedToken, bool useParent); GenTree* gtNewRuntimeLookup(CORINFO_GENERIC_HANDLE hnd, CorInfoGenericHandleType hndTyp, GenTree* lookupTree); GenTreeIndir* gtNewMethodTableLookup(GenTree* obj); //------------------------------------------------------------------------ // Other GenTree functions GenTree* gtClone(GenTree* tree, bool complexOK = false); // If `tree` is a lclVar with lclNum `varNum`, return an IntCns with value `varVal`; otherwise, // create a copy of `tree`, adding specified flags, replacing uses of lclVar `deepVarNum` with // IntCnses with value `deepVarVal`. GenTree* gtCloneExpr( GenTree* tree, GenTreeFlags addFlags, unsigned varNum, int varVal, unsigned deepVarNum, int deepVarVal); // Create a copy of `tree`, optionally adding specifed flags, and optionally mapping uses of local // `varNum` to int constants with value `varVal`. GenTree* gtCloneExpr(GenTree* tree, GenTreeFlags addFlags = GTF_EMPTY, unsigned varNum = BAD_VAR_NUM, int varVal = 0) { return gtCloneExpr(tree, addFlags, varNum, varVal, varNum, varVal); } Statement* gtCloneStmt(Statement* stmt) { GenTree* exprClone = gtCloneExpr(stmt->GetRootNode()); return gtNewStmt(exprClone, stmt->GetDebugInfo()); } // Internal helper for cloning a call GenTreeCall* gtCloneExprCallHelper(GenTreeCall* call, GenTreeFlags addFlags = GTF_EMPTY, unsigned deepVarNum = BAD_VAR_NUM, int deepVarVal = 0); // Create copy of an inline or guarded devirtualization candidate tree. GenTreeCall* gtCloneCandidateCall(GenTreeCall* call); void gtUpdateSideEffects(Statement* stmt, GenTree* tree); void gtUpdateTreeAncestorsSideEffects(GenTree* tree); void gtUpdateStmtSideEffects(Statement* stmt); void gtUpdateNodeSideEffects(GenTree* tree); void gtUpdateNodeOperSideEffects(GenTree* tree); void gtUpdateNodeOperSideEffectsPost(GenTree* tree); // Returns "true" iff the complexity (not formally defined, but first interpretation // is #of nodes in subtree) of "tree" is greater than "limit". // (This is somewhat redundant with the "GetCostEx()/GetCostSz()" fields, but can be used // before they have been set.) bool gtComplexityExceeds(GenTree** tree, unsigned limit); GenTree* gtReverseCond(GenTree* tree); static bool gtHasRef(GenTree* tree, ssize_t lclNum); bool gtHasLocalsWithAddrOp(GenTree* tree); unsigned gtSetCallArgsOrder(const GenTreeCall::UseList& args, bool lateArgs, int* callCostEx, int* callCostSz); unsigned gtSetMultiOpOrder(GenTreeMultiOp* multiOp); void gtWalkOp(GenTree** op1, GenTree** op2, GenTree* base, bool constOnly); #ifdef DEBUG unsigned gtHashValue(GenTree* tree); GenTree* gtWalkOpEffectiveVal(GenTree* op); #endif void gtPrepareCost(GenTree* tree); bool gtIsLikelyRegVar(GenTree* tree); // Returns true iff the secondNode can be swapped with firstNode. bool gtCanSwapOrder(GenTree* firstNode, GenTree* secondNode); // Given an address expression, compute its costs and addressing mode opportunities, // and mark addressing mode candidates as GTF_DONT_CSE. // TODO-Throughput - Consider actually instantiating these early, to avoid // having to re-run the algorithm that looks for them (might also improve CQ). bool gtMarkAddrMode(GenTree* addr, int* costEx, int* costSz, var_types type); unsigned gtSetEvalOrder(GenTree* tree); void gtSetStmtInfo(Statement* stmt); // Returns "true" iff "node" has any of the side effects in "flags". bool gtNodeHasSideEffects(GenTree* node, GenTreeFlags flags); // Returns "true" iff "tree" or its (transitive) children have any of the side effects in "flags". bool gtTreeHasSideEffects(GenTree* tree, GenTreeFlags flags); // Appends 'expr' in front of 'list' // 'list' will typically start off as 'nullptr' // when 'list' is non-null a GT_COMMA node is used to insert 'expr' GenTree* gtBuildCommaList(GenTree* list, GenTree* expr); void gtExtractSideEffList(GenTree* expr, GenTree** pList, GenTreeFlags GenTreeFlags = GTF_SIDE_EFFECT, bool ignoreRoot = false); GenTree* gtGetThisArg(GenTreeCall* call); // Static fields of struct types (and sometimes the types that those are reduced to) are represented by having the // static field contain an object pointer to the boxed struct. This simplifies the GC implementation...but // complicates the JIT somewhat. This predicate returns "true" iff a node with type "fieldNodeType", representing // the given "fldHnd", is such an object pointer. bool gtIsStaticFieldPtrToBoxedStruct(var_types fieldNodeType, CORINFO_FIELD_HANDLE fldHnd); // Return true if call is a recursive call; return false otherwise. // Note when inlining, this looks for calls back to the root method. bool gtIsRecursiveCall(GenTreeCall* call) { return gtIsRecursiveCall(call->gtCallMethHnd); } bool gtIsRecursiveCall(CORINFO_METHOD_HANDLE callMethodHandle) { return (callMethodHandle == impInlineRoot()->info.compMethodHnd); } //------------------------------------------------------------------------- GenTree* gtFoldExpr(GenTree* tree); GenTree* gtFoldExprConst(GenTree* tree); GenTree* gtFoldExprSpecial(GenTree* tree); GenTree* gtFoldBoxNullable(GenTree* tree); GenTree* gtFoldExprCompare(GenTree* tree); GenTree* gtCreateHandleCompare(genTreeOps oper, GenTree* op1, GenTree* op2, CorInfoInlineTypeCheck typeCheckInliningResult); GenTree* gtFoldExprCall(GenTreeCall* call); GenTree* gtFoldTypeCompare(GenTree* tree); GenTree* gtFoldTypeEqualityCall(bool isEq, GenTree* op1, GenTree* op2); // Options to control behavior of gtTryRemoveBoxUpstreamEffects enum BoxRemovalOptions { BR_REMOVE_AND_NARROW, // remove effects, minimize remaining work, return possibly narrowed source tree BR_REMOVE_AND_NARROW_WANT_TYPE_HANDLE, // remove effects and minimize remaining work, return type handle tree BR_REMOVE_BUT_NOT_NARROW, // remove effects, return original source tree BR_DONT_REMOVE, // check if removal is possible, return copy source tree BR_DONT_REMOVE_WANT_TYPE_HANDLE, // check if removal is possible, return type handle tree BR_MAKE_LOCAL_COPY // revise box to copy to temp local and return local's address }; GenTree* gtTryRemoveBoxUpstreamEffects(GenTree* tree, BoxRemovalOptions options = BR_REMOVE_AND_NARROW); GenTree* gtOptimizeEnumHasFlag(GenTree* thisOp, GenTree* flagOp); //------------------------------------------------------------------------- // Get the handle, if any. CORINFO_CLASS_HANDLE gtGetStructHandleIfPresent(GenTree* tree); // Get the handle, and assert if not found. CORINFO_CLASS_HANDLE gtGetStructHandle(GenTree* tree); // Get the handle for a ref type. CORINFO_CLASS_HANDLE gtGetClassHandle(GenTree* tree, bool* pIsExact, bool* pIsNonNull); // Get the class handle for an helper call CORINFO_CLASS_HANDLE gtGetHelperCallClassHandle(GenTreeCall* call, bool* pIsExact, bool* pIsNonNull); // Get the element handle for an array of ref type. CORINFO_CLASS_HANDLE gtGetArrayElementClassHandle(GenTree* array); // Get a class handle from a helper call argument CORINFO_CLASS_HANDLE gtGetHelperArgClassHandle(GenTree* array); // Get the class handle for a field CORINFO_CLASS_HANDLE gtGetFieldClassHandle(CORINFO_FIELD_HANDLE fieldHnd, bool* pIsExact, bool* pIsNonNull); // Check if this tree is a gc static base helper call bool gtIsStaticGCBaseHelperCall(GenTree* tree); //------------------------------------------------------------------------- // Functions to display the trees #ifdef DEBUG void gtDispNode(GenTree* tree, IndentStack* indentStack, _In_z_ const char* msg, bool isLIR); void gtDispConst(GenTree* tree); void gtDispLeaf(GenTree* tree, IndentStack* indentStack); void gtDispNodeName(GenTree* tree); #if FEATURE_MULTIREG_RET unsigned gtDispRegCount(GenTree* tree); #endif void gtDispRegVal(GenTree* tree); void gtDispZeroFieldSeq(GenTree* tree); void gtDispVN(GenTree* tree); void gtDispCommonEndLine(GenTree* tree); enum IndentInfo { IINone, IIArc, IIArcTop, IIArcBottom, IIEmbedded, IIError, IndentInfoCount }; void gtDispChild(GenTree* child, IndentStack* indentStack, IndentInfo arcType, _In_opt_ const char* msg = nullptr, bool topOnly = false); void gtDispTree(GenTree* tree, IndentStack* indentStack = nullptr, _In_opt_ const char* msg = nullptr, bool topOnly = false, bool isLIR = false); void gtGetLclVarNameInfo(unsigned lclNum, const char** ilKindOut, const char** ilNameOut, unsigned* ilNumOut); int gtGetLclVarName(unsigned lclNum, char* buf, unsigned buf_remaining); char* gtGetLclVarName(unsigned lclNum); void gtDispLclVar(unsigned lclNum, bool padForBiggestDisp = true); void gtDispLclVarStructType(unsigned lclNum); void gtDispClassLayout(ClassLayout* layout, var_types type); void gtDispILLocation(const ILLocation& loc); void gtDispStmt(Statement* stmt, const char* msg = nullptr); void gtDispBlockStmts(BasicBlock* block); void gtGetArgMsg(GenTreeCall* call, GenTree* arg, unsigned argNum, char* bufp, unsigned bufLength); void gtGetLateArgMsg(GenTreeCall* call, GenTree* arg, int argNum, char* bufp, unsigned bufLength); void gtDispArgList(GenTreeCall* call, GenTree* lastCallOperand, IndentStack* indentStack); void gtDispAnyFieldSeq(FieldSeqNode* fieldSeq); void gtDispFieldSeq(FieldSeqNode* pfsn); void gtDispRange(LIR::ReadOnlyRange const& range); void gtDispTreeRange(LIR::Range& containingRange, GenTree* tree); void gtDispLIRNode(GenTree* node, const char* prefixMsg = nullptr); #endif // For tree walks enum fgWalkResult { WALK_CONTINUE, WALK_SKIP_SUBTREES, WALK_ABORT }; struct fgWalkData; typedef fgWalkResult(fgWalkPreFn)(GenTree** pTree, fgWalkData* data); typedef fgWalkResult(fgWalkPostFn)(GenTree** pTree, fgWalkData* data); static fgWalkPreFn gtMarkColonCond; static fgWalkPreFn gtClearColonCond; struct FindLinkData { GenTree* nodeToFind; GenTree** result; GenTree* parent; }; FindLinkData gtFindLink(Statement* stmt, GenTree* node); bool gtHasCatchArg(GenTree* tree); typedef ArrayStack<GenTree*> GenTreeStack; static bool gtHasCallOnStack(GenTreeStack* parentStack); //========================================================================= // BasicBlock functions #ifdef DEBUG // This is a debug flag we will use to assert when creating block during codegen // as this interferes with procedure splitting. If you know what you're doing, set // it to true before creating the block. (DEBUG only) bool fgSafeBasicBlockCreation; #endif BasicBlock* bbNewBasicBlock(BBjumpKinds jumpKind); void placeLoopAlignInstructions(); /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX LclVarsInfo XX XX XX XX The variables to be used by the code generator. XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ // // For both PROMOTION_TYPE_NONE and PROMOTION_TYPE_DEPENDENT the struct will // be placed in the stack frame and it's fields must be laid out sequentially. // // For PROMOTION_TYPE_INDEPENDENT each of the struct's fields is replaced by // a local variable that can be enregistered or placed in the stack frame. // The fields do not need to be laid out sequentially // enum lvaPromotionType { PROMOTION_TYPE_NONE, // The struct local is not promoted PROMOTION_TYPE_INDEPENDENT, // The struct local is promoted, // and its field locals are independent of its parent struct local. PROMOTION_TYPE_DEPENDENT // The struct local is promoted, // but its field locals depend on its parent struct local. }; /*****************************************************************************/ enum FrameLayoutState { NO_FRAME_LAYOUT, INITIAL_FRAME_LAYOUT, PRE_REGALLOC_FRAME_LAYOUT, REGALLOC_FRAME_LAYOUT, TENTATIVE_FRAME_LAYOUT, FINAL_FRAME_LAYOUT }; public: RefCountState lvaRefCountState; // Current local ref count state bool lvaLocalVarRefCounted() const { return lvaRefCountState == RCS_NORMAL; } bool lvaTrackedFixed; // true: We cannot add new 'tracked' variable unsigned lvaCount; // total number of locals, which includes function arguments, // special arguments, IL local variables, and JIT temporary variables LclVarDsc* lvaTable; // variable descriptor table unsigned lvaTableCnt; // lvaTable size (>= lvaCount) unsigned lvaTrackedCount; // actual # of locals being tracked unsigned lvaTrackedCountInSizeTUnits; // min # of size_t's sufficient to hold a bit for all the locals being tracked #ifdef DEBUG VARSET_TP lvaTrackedVars; // set of tracked variables #endif #ifndef TARGET_64BIT VARSET_TP lvaLongVars; // set of long (64-bit) variables #endif VARSET_TP lvaFloatVars; // set of floating-point (32-bit and 64-bit) variables unsigned lvaCurEpoch; // VarSets are relative to a specific set of tracked var indices. // It that changes, this changes. VarSets from different epochs // cannot be meaningfully combined. unsigned GetCurLVEpoch() { return lvaCurEpoch; } // reverse map of tracked number to var number unsigned lvaTrackedToVarNumSize; unsigned* lvaTrackedToVarNum; #if DOUBLE_ALIGN #ifdef DEBUG // # of procs compiled a with double-aligned stack static unsigned s_lvaDoubleAlignedProcsCount; #endif #endif // Getters and setters for address-exposed and do-not-enregister local var properties. bool lvaVarAddrExposed(unsigned varNum) const; void lvaSetVarAddrExposed(unsigned varNum DEBUGARG(AddressExposedReason reason)); void lvaSetVarLiveInOutOfHandler(unsigned varNum); bool lvaVarDoNotEnregister(unsigned varNum); void lvSetMinOptsDoNotEnreg(); bool lvaEnregEHVars; bool lvaEnregMultiRegVars; void lvaSetVarDoNotEnregister(unsigned varNum DEBUGARG(DoNotEnregisterReason reason)); unsigned lvaVarargsHandleArg; #ifdef TARGET_X86 unsigned lvaVarargsBaseOfStkArgs; // Pointer (computed based on incoming varargs handle) to the start of the stack // arguments #endif // TARGET_X86 unsigned lvaInlinedPInvokeFrameVar; // variable representing the InlinedCallFrame unsigned lvaReversePInvokeFrameVar; // variable representing the reverse PInvoke frame #if FEATURE_FIXED_OUT_ARGS unsigned lvaPInvokeFrameRegSaveVar; // variable representing the RegSave for PInvoke inlining. #endif unsigned lvaMonAcquired; // boolean variable introduced into in synchronized methods // that tracks whether the lock has been taken unsigned lvaArg0Var; // The lclNum of arg0. Normally this will be info.compThisArg. // However, if there is a "ldarga 0" or "starg 0" in the IL, // we will redirect all "ldarg(a) 0" and "starg 0" to this temp. unsigned lvaInlineeReturnSpillTemp; // The temp to spill the non-VOID return expression // in case there are multiple BBJ_RETURN blocks in the inlinee // or if the inlinee has GC ref locals. #if FEATURE_FIXED_OUT_ARGS unsigned lvaOutgoingArgSpaceVar; // dummy TYP_LCLBLK var for fixed outgoing argument space PhasedVar<unsigned> lvaOutgoingArgSpaceSize; // size of fixed outgoing argument space #endif // FEATURE_FIXED_OUT_ARGS static unsigned GetOutgoingArgByteSize(unsigned sizeWithoutPadding) { return roundUp(sizeWithoutPadding, TARGET_POINTER_SIZE); } // Variable representing the return address. The helper-based tailcall // mechanism passes the address of the return address to a runtime helper // where it is used to detect tail-call chains. unsigned lvaRetAddrVar; #if defined(DEBUG) && defined(TARGET_XARCH) unsigned lvaReturnSpCheck; // Stores SP to confirm it is not corrupted on return. #endif // defined(DEBUG) && defined(TARGET_XARCH) #if defined(DEBUG) && defined(TARGET_X86) unsigned lvaCallSpCheck; // Stores SP to confirm it is not corrupted after every call. #endif // defined(DEBUG) && defined(TARGET_X86) bool lvaGenericsContextInUse; bool lvaKeepAliveAndReportThis(); // Synchronized instance method of a reference type, or // CORINFO_GENERICS_CTXT_FROM_THIS? bool lvaReportParamTypeArg(); // Exceptions and CORINFO_GENERICS_CTXT_FROM_PARAMTYPEARG? //------------------------------------------------------------------------- // All these frame offsets are inter-related and must be kept in sync #if !defined(FEATURE_EH_FUNCLETS) // This is used for the callable handlers unsigned lvaShadowSPslotsVar; // TYP_BLK variable for all the shadow SP slots #endif // FEATURE_EH_FUNCLETS int lvaCachedGenericContextArgOffs; int lvaCachedGenericContextArgOffset(); // For CORINFO_CALLCONV_PARAMTYPE and if generic context is passed as // THIS pointer #ifdef JIT32_GCENCODER unsigned lvaLocAllocSPvar; // variable which stores the value of ESP after the the last alloca/localloc #endif // JIT32_GCENCODER unsigned lvaNewObjArrayArgs; // variable with arguments for new MD array helper // TODO-Review: Prior to reg predict we reserve 24 bytes for Spill temps. // after the reg predict we will use a computed maxTmpSize // which is based upon the number of spill temps predicted by reg predict // All this is necessary because if we under-estimate the size of the spill // temps we could fail when encoding instructions that reference stack offsets for ARM. // // Pre codegen max spill temp size. static const unsigned MAX_SPILL_TEMP_SIZE = 24; //------------------------------------------------------------------------- unsigned lvaGetMaxSpillTempSize(); #ifdef TARGET_ARM bool lvaIsPreSpilled(unsigned lclNum, regMaskTP preSpillMask); #endif // TARGET_ARM void lvaAssignFrameOffsets(FrameLayoutState curState); void lvaFixVirtualFrameOffsets(); void lvaUpdateArgWithInitialReg(LclVarDsc* varDsc); void lvaUpdateArgsWithInitialReg(); void lvaAssignVirtualFrameOffsetsToArgs(); #ifdef UNIX_AMD64_ABI int lvaAssignVirtualFrameOffsetToArg(unsigned lclNum, unsigned argSize, int argOffs, int* callerArgOffset); #else // !UNIX_AMD64_ABI int lvaAssignVirtualFrameOffsetToArg(unsigned lclNum, unsigned argSize, int argOffs); #endif // !UNIX_AMD64_ABI void lvaAssignVirtualFrameOffsetsToLocals(); int lvaAllocLocalAndSetVirtualOffset(unsigned lclNum, unsigned size, int stkOffs); #ifdef TARGET_AMD64 // Returns true if compCalleeRegsPushed (including RBP if used as frame pointer) is even. bool lvaIsCalleeSavedIntRegCountEven(); #endif void lvaAlignFrame(); void lvaAssignFrameOffsetsToPromotedStructs(); int lvaAllocateTemps(int stkOffs, bool mustDoubleAlign); #ifdef DEBUG void lvaDumpRegLocation(unsigned lclNum); void lvaDumpFrameLocation(unsigned lclNum); void lvaDumpEntry(unsigned lclNum, FrameLayoutState curState, size_t refCntWtdWidth = 6); void lvaTableDump(FrameLayoutState curState = NO_FRAME_LAYOUT); // NO_FRAME_LAYOUT means use the current frame // layout state defined by lvaDoneFrameLayout #endif // Limit frames size to 1GB. The maximum is 2GB in theory - make it intentionally smaller // to avoid bugs from borderline cases. #define MAX_FrameSize 0x3FFFFFFF void lvaIncrementFrameSize(unsigned size); unsigned lvaFrameSize(FrameLayoutState curState); // Returns the caller-SP-relative offset for the SP/FP relative offset determined by FP based. int lvaToCallerSPRelativeOffset(int offs, bool isFpBased, bool forRootFrame = true) const; // Returns the caller-SP-relative offset for the local variable "varNum." int lvaGetCallerSPRelativeOffset(unsigned varNum); // Returns the SP-relative offset for the local variable "varNum". Illegal to ask this for functions with localloc. int lvaGetSPRelativeOffset(unsigned varNum); int lvaToInitialSPRelativeOffset(unsigned offset, bool isFpBased); int lvaGetInitialSPRelativeOffset(unsigned varNum); // True if this is an OSR compilation and this local is potentially // located on the original method stack frame. bool lvaIsOSRLocal(unsigned varNum); //------------------------ For splitting types ---------------------------- void lvaInitTypeRef(); void lvaInitArgs(InitVarDscInfo* varDscInfo); void lvaInitThisPtr(InitVarDscInfo* varDscInfo); void lvaInitRetBuffArg(InitVarDscInfo* varDscInfo, bool useFixedRetBufReg); void lvaInitUserArgs(InitVarDscInfo* varDscInfo, unsigned skipArgs, unsigned takeArgs); void lvaInitGenericsCtxt(InitVarDscInfo* varDscInfo); void lvaInitVarArgsHandle(InitVarDscInfo* varDscInfo); void lvaInitVarDsc(LclVarDsc* varDsc, unsigned varNum, CorInfoType corInfoType, CORINFO_CLASS_HANDLE typeHnd, CORINFO_ARG_LIST_HANDLE varList, CORINFO_SIG_INFO* varSig); static unsigned lvaTypeRefMask(var_types type); var_types lvaGetActualType(unsigned lclNum); var_types lvaGetRealType(unsigned lclNum); //------------------------------------------------------------------------- void lvaInit(); LclVarDsc* lvaGetDesc(unsigned lclNum) { assert(lclNum < lvaCount); return &lvaTable[lclNum]; } LclVarDsc* lvaGetDesc(unsigned lclNum) const { assert(lclNum < lvaCount); return &lvaTable[lclNum]; } LclVarDsc* lvaGetDesc(const GenTreeLclVarCommon* lclVar) { return lvaGetDesc(lclVar->GetLclNum()); } unsigned lvaTrackedIndexToLclNum(unsigned trackedIndex) { assert(trackedIndex < lvaTrackedCount); unsigned lclNum = lvaTrackedToVarNum[trackedIndex]; assert(lclNum < lvaCount); return lclNum; } LclVarDsc* lvaGetDescByTrackedIndex(unsigned trackedIndex) { return lvaGetDesc(lvaTrackedIndexToLclNum(trackedIndex)); } unsigned lvaGetLclNum(const LclVarDsc* varDsc) { assert((lvaTable <= varDsc) && (varDsc < lvaTable + lvaCount)); // varDsc must point within the table assert(((char*)varDsc - (char*)lvaTable) % sizeof(LclVarDsc) == 0); // varDsc better not point in the middle of a variable unsigned varNum = (unsigned)(varDsc - lvaTable); assert(varDsc == &lvaTable[varNum]); return varNum; } unsigned lvaLclSize(unsigned varNum); unsigned lvaLclExactSize(unsigned varNum); bool lvaHaveManyLocals() const; unsigned lvaGrabTemp(bool shortLifetime DEBUGARG(const char* reason)); unsigned lvaGrabTemps(unsigned cnt DEBUGARG(const char* reason)); unsigned lvaGrabTempWithImplicitUse(bool shortLifetime DEBUGARG(const char* reason)); void lvaSortByRefCount(); void lvaMarkLocalVars(); // Local variable ref-counting void lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers); void lvaMarkLocalVars(BasicBlock* block, bool isRecompute); void lvaAllocOutgoingArgSpaceVar(); // Set up lvaOutgoingArgSpaceVar VARSET_VALRET_TP lvaStmtLclMask(Statement* stmt); #ifdef DEBUG struct lvaStressLclFldArgs { Compiler* m_pCompiler; bool m_bFirstPass; }; static fgWalkPreFn lvaStressLclFldCB; void lvaStressLclFld(); void lvaDispVarSet(VARSET_VALARG_TP set, VARSET_VALARG_TP allVars); void lvaDispVarSet(VARSET_VALARG_TP set); #endif #ifdef TARGET_ARM int lvaFrameAddress(int varNum, bool mustBeFPBased, regNumber* pBaseReg, int addrModeOffset, bool isFloatUsage); #else int lvaFrameAddress(int varNum, bool* pFPbased); #endif bool lvaIsParameter(unsigned varNum); bool lvaIsRegArgument(unsigned varNum); bool lvaIsOriginalThisArg(unsigned varNum); // Is this varNum the original this argument? bool lvaIsOriginalThisReadOnly(); // return true if there is no place in the code // that writes to arg0 // For x64 this is 3, 5, 6, 7, >8 byte structs that are passed by reference. // For ARM64, this is structs larger than 16 bytes that are passed by reference. bool lvaIsImplicitByRefLocal(unsigned varNum) { #if defined(TARGET_AMD64) || defined(TARGET_ARM64) LclVarDsc* varDsc = lvaGetDesc(varNum); if (varDsc->lvIsImplicitByRef) { assert(varDsc->lvIsParam); assert(varTypeIsStruct(varDsc) || (varDsc->lvType == TYP_BYREF)); return true; } #endif // defined(TARGET_AMD64) || defined(TARGET_ARM64) return false; } // Returns true if this local var is a multireg struct bool lvaIsMultiregStruct(LclVarDsc* varDsc, bool isVararg); // If the local is a TYP_STRUCT, get/set a class handle describing it CORINFO_CLASS_HANDLE lvaGetStruct(unsigned varNum); void lvaSetStruct(unsigned varNum, CORINFO_CLASS_HANDLE typeHnd, bool unsafeValueClsCheck, bool setTypeInfo = true); void lvaSetStructUsedAsVarArg(unsigned varNum); // If the local is TYP_REF, set or update the associated class information. void lvaSetClass(unsigned varNum, CORINFO_CLASS_HANDLE clsHnd, bool isExact = false); void lvaSetClass(unsigned varNum, GenTree* tree, CORINFO_CLASS_HANDLE stackHandle = nullptr); void lvaUpdateClass(unsigned varNum, CORINFO_CLASS_HANDLE clsHnd, bool isExact = false); void lvaUpdateClass(unsigned varNum, GenTree* tree, CORINFO_CLASS_HANDLE stackHandle = nullptr); #define MAX_NumOfFieldsInPromotableStruct 4 // Maximum number of fields in promotable struct // Info about struct type fields. struct lvaStructFieldInfo { CORINFO_FIELD_HANDLE fldHnd; unsigned char fldOffset; unsigned char fldOrdinal; var_types fldType; unsigned fldSize; CORINFO_CLASS_HANDLE fldTypeHnd; lvaStructFieldInfo() : fldHnd(nullptr), fldOffset(0), fldOrdinal(0), fldType(TYP_UNDEF), fldSize(0), fldTypeHnd(nullptr) { } }; // Info about a struct type, instances of which may be candidates for promotion. struct lvaStructPromotionInfo { CORINFO_CLASS_HANDLE typeHnd; bool canPromote; bool containsHoles; bool customLayout; bool fieldsSorted; unsigned char fieldCnt; lvaStructFieldInfo fields[MAX_NumOfFieldsInPromotableStruct]; lvaStructPromotionInfo(CORINFO_CLASS_HANDLE typeHnd = nullptr) : typeHnd(typeHnd) , canPromote(false) , containsHoles(false) , customLayout(false) , fieldsSorted(false) , fieldCnt(0) { } }; struct lvaFieldOffsetCmp { bool operator()(const lvaStructFieldInfo& field1, const lvaStructFieldInfo& field2); }; // This class is responsible for checking validity and profitability of struct promotion. // If it is both legal and profitable, then TryPromoteStructVar promotes the struct and initializes // nessesary information for fgMorphStructField to use. class StructPromotionHelper { public: StructPromotionHelper(Compiler* compiler); bool CanPromoteStructType(CORINFO_CLASS_HANDLE typeHnd); bool TryPromoteStructVar(unsigned lclNum); void Clear() { structPromotionInfo.typeHnd = NO_CLASS_HANDLE; } #ifdef DEBUG void CheckRetypedAsScalar(CORINFO_FIELD_HANDLE fieldHnd, var_types requestedType); #endif // DEBUG private: bool CanPromoteStructVar(unsigned lclNum); bool ShouldPromoteStructVar(unsigned lclNum); void PromoteStructVar(unsigned lclNum); void SortStructFields(); lvaStructFieldInfo GetFieldInfo(CORINFO_FIELD_HANDLE fieldHnd, BYTE ordinal); bool TryPromoteStructField(lvaStructFieldInfo& outerFieldInfo); private: Compiler* compiler; lvaStructPromotionInfo structPromotionInfo; #ifdef DEBUG typedef JitHashTable<CORINFO_FIELD_HANDLE, JitPtrKeyFuncs<CORINFO_FIELD_STRUCT_>, var_types> RetypedAsScalarFieldsMap; RetypedAsScalarFieldsMap retypedFieldsMap; #endif // DEBUG }; StructPromotionHelper* structPromotionHelper; unsigned lvaGetFieldLocal(const LclVarDsc* varDsc, unsigned int fldOffset); lvaPromotionType lvaGetPromotionType(const LclVarDsc* varDsc); lvaPromotionType lvaGetPromotionType(unsigned varNum); lvaPromotionType lvaGetParentPromotionType(const LclVarDsc* varDsc); lvaPromotionType lvaGetParentPromotionType(unsigned varNum); bool lvaIsFieldOfDependentlyPromotedStruct(const LclVarDsc* varDsc); bool lvaIsGCTracked(const LclVarDsc* varDsc); #if defined(FEATURE_SIMD) bool lvaMapSimd12ToSimd16(const LclVarDsc* varDsc) { assert(varDsc->lvType == TYP_SIMD12); assert(varDsc->lvExactSize == 12); #if defined(TARGET_64BIT) assert(compMacOsArm64Abi() || varDsc->lvSize() == 16); #endif // defined(TARGET_64BIT) // We make local variable SIMD12 types 16 bytes instead of just 12. // lvSize() will return 16 bytes for SIMD12, even for fields. // However, we can't do that mapping if the var is a dependently promoted struct field. // Such a field must remain its exact size within its parent struct unless it is a single // field *and* it is the only field in a struct of 16 bytes. if (varDsc->lvSize() != 16) { return false; } if (lvaIsFieldOfDependentlyPromotedStruct(varDsc)) { LclVarDsc* parentVarDsc = lvaGetDesc(varDsc->lvParentLcl); return (parentVarDsc->lvFieldCnt == 1) && (parentVarDsc->lvSize() == 16); } return true; } #endif // defined(FEATURE_SIMD) unsigned lvaGSSecurityCookie; // LclVar number bool lvaTempsHaveLargerOffsetThanVars(); // Returns "true" iff local variable "lclNum" is in SSA form. bool lvaInSsa(unsigned lclNum) { assert(lclNum < lvaCount); return lvaTable[lclNum].lvInSsa; } unsigned lvaStubArgumentVar; // variable representing the secret stub argument coming in EAX #if defined(FEATURE_EH_FUNCLETS) unsigned lvaPSPSym; // variable representing the PSPSym #endif InlineInfo* impInlineInfo; // Only present for inlinees InlineStrategy* m_inlineStrategy; InlineContext* compInlineContext; // Always present // The Compiler* that is the root of the inlining tree of which "this" is a member. Compiler* impInlineRoot(); #if defined(DEBUG) || defined(INLINE_DATA) unsigned __int64 getInlineCycleCount() { return m_compCycles; } #endif // defined(DEBUG) || defined(INLINE_DATA) bool fgNoStructPromotion; // Set to TRUE to turn off struct promotion for this method. bool fgNoStructParamPromotion; // Set to TRUE to turn off struct promotion for parameters this method. //========================================================================= // PROTECTED //========================================================================= protected: //---------------- Local variable ref-counting ---------------------------- void lvaMarkLclRefs(GenTree* tree, BasicBlock* block, Statement* stmt, bool isRecompute); bool IsDominatedByExceptionalEntry(BasicBlock* block); void SetVolatileHint(LclVarDsc* varDsc); // Keeps the mapping from SSA #'s to VN's for the implicit memory variables. SsaDefArray<SsaMemDef> lvMemoryPerSsaData; public: // Returns the address of the per-Ssa data for memory at the given ssaNum (which is required // not to be the SsaConfig::RESERVED_SSA_NUM, which indicates that the variable is // not an SSA variable). SsaMemDef* GetMemoryPerSsaData(unsigned ssaNum) { return lvMemoryPerSsaData.GetSsaDef(ssaNum); } /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX Importer XX XX XX XX Imports the given method and converts it to semantic trees XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ private: // For prefixFlags enum { PREFIX_TAILCALL_EXPLICIT = 0x00000001, // call has "tail" IL prefix PREFIX_TAILCALL_IMPLICIT = 0x00000010, // call is treated as having "tail" prefix even though there is no "tail" IL prefix PREFIX_TAILCALL_STRESS = 0x00000100, // call doesn't "tail" IL prefix but is treated as explicit because of tail call stress PREFIX_TAILCALL = (PREFIX_TAILCALL_EXPLICIT | PREFIX_TAILCALL_IMPLICIT | PREFIX_TAILCALL_STRESS), PREFIX_VOLATILE = 0x00001000, PREFIX_UNALIGNED = 0x00010000, PREFIX_CONSTRAINED = 0x00100000, PREFIX_READONLY = 0x01000000 }; static void impValidateMemoryAccessOpcode(const BYTE* codeAddr, const BYTE* codeEndp, bool volatilePrefix); static OPCODE impGetNonPrefixOpcode(const BYTE* codeAddr, const BYTE* codeEndp); static bool impOpcodeIsCallOpcode(OPCODE opcode); public: void impInit(); void impImport(); CORINFO_CLASS_HANDLE impGetRefAnyClass(); CORINFO_CLASS_HANDLE impGetRuntimeArgumentHandle(); CORINFO_CLASS_HANDLE impGetTypeHandleClass(); CORINFO_CLASS_HANDLE impGetStringClass(); CORINFO_CLASS_HANDLE impGetObjectClass(); // Returns underlying type of handles returned by ldtoken instruction var_types GetRuntimeHandleUnderlyingType() { // RuntimeTypeHandle is backed by raw pointer on CoreRT and by object reference on other runtimes return IsTargetAbi(CORINFO_CORERT_ABI) ? TYP_I_IMPL : TYP_REF; } void impDevirtualizeCall(GenTreeCall* call, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_METHOD_HANDLE* method, unsigned* methodFlags, CORINFO_CONTEXT_HANDLE* contextHandle, CORINFO_CONTEXT_HANDLE* exactContextHandle, bool isLateDevirtualization, bool isExplicitTailCall, IL_OFFSET ilOffset = BAD_IL_OFFSET); //========================================================================= // PROTECTED //========================================================================= protected: //-------------------- Stack manipulation --------------------------------- unsigned impStkSize; // Size of the full stack #define SMALL_STACK_SIZE 16 // number of elements in impSmallStack struct SavedStack // used to save/restore stack contents. { unsigned ssDepth; // number of values on stack StackEntry* ssTrees; // saved tree values }; bool impIsPrimitive(CorInfoType type); bool impILConsumesAddr(const BYTE* codeAddr); void impResolveToken(const BYTE* addr, CORINFO_RESOLVED_TOKEN* pResolvedToken, CorInfoTokenKind kind); void impPushOnStack(GenTree* tree, typeInfo ti); void impPushNullObjRefOnStack(); StackEntry impPopStack(); StackEntry& impStackTop(unsigned n = 0); unsigned impStackHeight(); void impSaveStackState(SavedStack* savePtr, bool copy); void impRestoreStackState(SavedStack* savePtr); GenTree* impImportLdvirtftn(GenTree* thisPtr, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_CALL_INFO* pCallInfo); int impBoxPatternMatch(CORINFO_RESOLVED_TOKEN* pResolvedToken, const BYTE* codeAddr, const BYTE* codeEndp, bool makeInlineObservation = false); void impImportAndPushBox(CORINFO_RESOLVED_TOKEN* pResolvedToken); void impImportNewObjArray(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_CALL_INFO* pCallInfo); bool impCanPInvokeInline(); bool impCanPInvokeInlineCallSite(BasicBlock* block); void impCheckForPInvokeCall( GenTreeCall* call, CORINFO_METHOD_HANDLE methHnd, CORINFO_SIG_INFO* sig, unsigned mflags, BasicBlock* block); GenTreeCall* impImportIndirectCall(CORINFO_SIG_INFO* sig, const DebugInfo& di = DebugInfo()); void impPopArgsForUnmanagedCall(GenTree* call, CORINFO_SIG_INFO* sig); void impInsertHelperCall(CORINFO_HELPER_DESC* helperCall); void impHandleAccessAllowed(CorInfoIsAccessAllowedResult result, CORINFO_HELPER_DESC* helperCall); void impHandleAccessAllowedInternal(CorInfoIsAccessAllowedResult result, CORINFO_HELPER_DESC* helperCall); var_types impImportCall(OPCODE opcode, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken, // Is this a "constrained." call on a // type parameter? GenTree* newobjThis, int prefixFlags, CORINFO_CALL_INFO* callInfo, IL_OFFSET rawILOffset); CORINFO_CLASS_HANDLE impGetSpecialIntrinsicExactReturnType(CORINFO_METHOD_HANDLE specialIntrinsicHandle); bool impMethodInfo_hasRetBuffArg(CORINFO_METHOD_INFO* methInfo, CorInfoCallConvExtension callConv); GenTree* impFixupCallStructReturn(GenTreeCall* call, CORINFO_CLASS_HANDLE retClsHnd); GenTree* impFixupStructReturnType(GenTree* op, CORINFO_CLASS_HANDLE retClsHnd, CorInfoCallConvExtension unmgdCallConv); #ifdef DEBUG var_types impImportJitTestLabelMark(int numArgs); #endif // DEBUG GenTree* impInitClass(CORINFO_RESOLVED_TOKEN* pResolvedToken); GenTree* impImportStaticReadOnlyField(void* fldAddr, var_types lclTyp); GenTree* impImportStaticFieldAccess(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_ACCESS_FLAGS access, CORINFO_FIELD_INFO* pFieldInfo, var_types lclTyp); static void impBashVarAddrsToI(GenTree* tree1, GenTree* tree2 = nullptr); GenTree* impImplicitIorI4Cast(GenTree* tree, var_types dstTyp); GenTree* impImplicitR4orR8Cast(GenTree* tree, var_types dstTyp); void impImportLeave(BasicBlock* block); void impResetLeaveBlock(BasicBlock* block, unsigned jmpAddr); GenTree* impTypeIsAssignable(GenTree* typeTo, GenTree* typeFrom); GenTree* impIntrinsic(GenTree* newobjThis, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig, unsigned methodFlags, int memberRef, bool readonlyCall, bool tailCall, CORINFO_RESOLVED_TOKEN* pContstrainedResolvedToken, CORINFO_THIS_TRANSFORM constraintCallThisTransform, NamedIntrinsic* pIntrinsicName, bool* isSpecialIntrinsic = nullptr); GenTree* impMathIntrinsic(CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig, var_types callType, NamedIntrinsic intrinsicName, bool tailCall); NamedIntrinsic lookupNamedIntrinsic(CORINFO_METHOD_HANDLE method); GenTree* impUnsupportedNamedIntrinsic(unsigned helper, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig, bool mustExpand); #ifdef FEATURE_HW_INTRINSICS GenTree* impHWIntrinsic(NamedIntrinsic intrinsic, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig, bool mustExpand); GenTree* impSimdAsHWIntrinsic(NamedIntrinsic intrinsic, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig, GenTree* newobjThis); protected: bool compSupportsHWIntrinsic(CORINFO_InstructionSet isa); GenTree* impSimdAsHWIntrinsicSpecial(NamedIntrinsic intrinsic, CORINFO_CLASS_HANDLE clsHnd, CORINFO_SIG_INFO* sig, var_types retType, CorInfoType simdBaseJitType, unsigned simdSize, GenTree* newobjThis); GenTree* impSpecialIntrinsic(NamedIntrinsic intrinsic, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig, CorInfoType simdBaseJitType, var_types retType, unsigned simdSize); GenTree* getArgForHWIntrinsic(var_types argType, CORINFO_CLASS_HANDLE argClass, bool expectAddr = false, GenTree* newobjThis = nullptr); GenTree* impNonConstFallback(NamedIntrinsic intrinsic, var_types simdType, CorInfoType simdBaseJitType); GenTree* addRangeCheckIfNeeded( NamedIntrinsic intrinsic, GenTree* immOp, bool mustExpand, int immLowerBound, int immUpperBound); GenTree* addRangeCheckForHWIntrinsic(GenTree* immOp, int immLowerBound, int immUpperBound); #ifdef TARGET_XARCH GenTree* impBaseIntrinsic(NamedIntrinsic intrinsic, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig, CorInfoType simdBaseJitType, var_types retType, unsigned simdSize); GenTree* impSSEIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); GenTree* impSSE2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); GenTree* impAvxOrAvx2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); GenTree* impBMI1OrBMI2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); #endif // TARGET_XARCH #endif // FEATURE_HW_INTRINSICS GenTree* impArrayAccessIntrinsic(CORINFO_CLASS_HANDLE clsHnd, CORINFO_SIG_INFO* sig, int memberRef, bool readonlyCall, NamedIntrinsic intrinsicName); GenTree* impInitializeArrayIntrinsic(CORINFO_SIG_INFO* sig); GenTree* impCreateSpanIntrinsic(CORINFO_SIG_INFO* sig); GenTree* impKeepAliveIntrinsic(GenTree* objToKeepAlive); GenTree* impMethodPointer(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_CALL_INFO* pCallInfo); GenTree* impTransformThis(GenTree* thisPtr, CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken, CORINFO_THIS_TRANSFORM transform); //----------------- Manipulating the trees and stmts ---------------------- Statement* impStmtList; // Statements for the BB being imported. Statement* impLastStmt; // The last statement for the current BB. public: enum { CHECK_SPILL_ALL = -1, CHECK_SPILL_NONE = -2 }; void impBeginTreeList(); void impEndTreeList(BasicBlock* block, Statement* firstStmt, Statement* lastStmt); void impEndTreeList(BasicBlock* block); void impAppendStmtCheck(Statement* stmt, unsigned chkLevel); void impAppendStmt(Statement* stmt, unsigned chkLevel, bool checkConsumedDebugInfo = true); void impAppendStmt(Statement* stmt); void impInsertStmtBefore(Statement* stmt, Statement* stmtBefore); Statement* impAppendTree(GenTree* tree, unsigned chkLevel, const DebugInfo& di, bool checkConsumedDebugInfo = true); void impInsertTreeBefore(GenTree* tree, const DebugInfo& di, Statement* stmtBefore); void impAssignTempGen(unsigned tmp, GenTree* val, unsigned curLevel, Statement** pAfterStmt = nullptr, const DebugInfo& di = DebugInfo(), BasicBlock* block = nullptr); void impAssignTempGen(unsigned tmpNum, GenTree* val, CORINFO_CLASS_HANDLE structHnd, unsigned curLevel, Statement** pAfterStmt = nullptr, const DebugInfo& di = DebugInfo(), BasicBlock* block = nullptr); Statement* impExtractLastStmt(); GenTree* impCloneExpr(GenTree* tree, GenTree** clone, CORINFO_CLASS_HANDLE structHnd, unsigned curLevel, Statement** pAfterStmt DEBUGARG(const char* reason)); GenTree* impAssignStruct(GenTree* dest, GenTree* src, CORINFO_CLASS_HANDLE structHnd, unsigned curLevel, Statement** pAfterStmt = nullptr, const DebugInfo& di = DebugInfo(), BasicBlock* block = nullptr); GenTree* impAssignStructPtr(GenTree* dest, GenTree* src, CORINFO_CLASS_HANDLE structHnd, unsigned curLevel, Statement** pAfterStmt = nullptr, const DebugInfo& di = DebugInfo(), BasicBlock* block = nullptr); GenTree* impGetStructAddr(GenTree* structVal, CORINFO_CLASS_HANDLE structHnd, unsigned curLevel, bool willDeref); var_types impNormStructType(CORINFO_CLASS_HANDLE structHnd, CorInfoType* simdBaseJitType = nullptr); GenTree* impNormStructVal(GenTree* structVal, CORINFO_CLASS_HANDLE structHnd, unsigned curLevel, bool forceNormalization = false); GenTree* impTokenToHandle(CORINFO_RESOLVED_TOKEN* pResolvedToken, bool* pRuntimeLookup = nullptr, bool mustRestoreHandle = false, bool importParent = false); GenTree* impParentClassTokenToHandle(CORINFO_RESOLVED_TOKEN* pResolvedToken, bool* pRuntimeLookup = nullptr, bool mustRestoreHandle = false) { return impTokenToHandle(pResolvedToken, pRuntimeLookup, mustRestoreHandle, true); } GenTree* impLookupToTree(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_LOOKUP* pLookup, GenTreeFlags flags, void* compileTimeHandle); GenTree* getRuntimeContextTree(CORINFO_RUNTIME_LOOKUP_KIND kind); GenTree* impRuntimeLookupToTree(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_LOOKUP* pLookup, void* compileTimeHandle); GenTree* impReadyToRunLookupToTree(CORINFO_CONST_LOOKUP* pLookup, GenTreeFlags flags, void* compileTimeHandle); GenTreeCall* impReadyToRunHelperToTree(CORINFO_RESOLVED_TOKEN* pResolvedToken, CorInfoHelpFunc helper, var_types type, GenTreeCall::Use* args = nullptr, CORINFO_LOOKUP_KIND* pGenericLookupKind = nullptr); bool impIsCastHelperEligibleForClassProbe(GenTree* tree); bool impIsCastHelperMayHaveProfileData(GenTree* tree); GenTree* impCastClassOrIsInstToTree( GenTree* op1, GenTree* op2, CORINFO_RESOLVED_TOKEN* pResolvedToken, bool isCastClass, IL_OFFSET ilOffset); GenTree* impOptimizeCastClassOrIsInst(GenTree* op1, CORINFO_RESOLVED_TOKEN* pResolvedToken, bool isCastClass); bool VarTypeIsMultiByteAndCanEnreg(var_types type, CORINFO_CLASS_HANDLE typeClass, unsigned* typeSize, bool forReturn, bool isVarArg, CorInfoCallConvExtension callConv); bool IsIntrinsicImplementedByUserCall(NamedIntrinsic intrinsicName); bool IsTargetIntrinsic(NamedIntrinsic intrinsicName); bool IsMathIntrinsic(NamedIntrinsic intrinsicName); bool IsMathIntrinsic(GenTree* tree); private: //----------------- Importing the method ---------------------------------- CORINFO_CONTEXT_HANDLE impTokenLookupContextHandle; // The context used for looking up tokens. #ifdef DEBUG unsigned impCurOpcOffs; const char* impCurOpcName; bool impNestedStackSpill; // For displaying instrs with generated native code (-n:B) Statement* impLastILoffsStmt; // oldest stmt added for which we did not call SetLastILOffset(). void impNoteLastILoffs(); #endif // Debug info of current statement being imported. It gets set to contain // no IL location (!impCurStmtDI.GetLocation().IsValid) after it has been // set in the appended trees. Then it gets updated at IL instructions for // which we have to report mapping info. // It will always contain the current inline context. DebugInfo impCurStmtDI; DebugInfo impCreateDIWithCurrentStackInfo(IL_OFFSET offs, bool isCall); void impCurStmtOffsSet(IL_OFFSET offs); void impNoteBranchOffs(); unsigned impInitBlockLineInfo(); bool impIsThis(GenTree* obj); bool impIsLDFTN_TOKEN(const BYTE* delegateCreateStart, const BYTE* newobjCodeAddr); bool impIsDUP_LDVIRTFTN_TOKEN(const BYTE* delegateCreateStart, const BYTE* newobjCodeAddr); bool impIsAnySTLOC(OPCODE opcode) { return ((opcode == CEE_STLOC) || (opcode == CEE_STLOC_S) || ((opcode >= CEE_STLOC_0) && (opcode <= CEE_STLOC_3))); } GenTreeCall::Use* impPopCallArgs(unsigned count, CORINFO_SIG_INFO* sig, GenTreeCall::Use* prefixArgs = nullptr); bool impCheckImplicitArgumentCoercion(var_types sigType, var_types nodeType) const; GenTreeCall::Use* impPopReverseCallArgs(unsigned count, CORINFO_SIG_INFO* sig, unsigned skipReverseCount = 0); //---------------- Spilling the importer stack ---------------------------- // The maximum number of bytes of IL processed without clean stack state. // It allows to limit the maximum tree size and depth. static const unsigned MAX_TREE_SIZE = 200; bool impCanSpillNow(OPCODE prevOpcode); struct PendingDsc { PendingDsc* pdNext; BasicBlock* pdBB; SavedStack pdSavedStack; ThisInitState pdThisPtrInit; }; PendingDsc* impPendingList; // list of BBs currently waiting to be imported. PendingDsc* impPendingFree; // Freed up dscs that can be reused // We keep a byte-per-block map (dynamically extended) in the top-level Compiler object of a compilation. JitExpandArray<BYTE> impPendingBlockMembers; // Return the byte for "b" (allocating/extending impPendingBlockMembers if necessary.) // Operates on the map in the top-level ancestor. BYTE impGetPendingBlockMember(BasicBlock* blk) { return impInlineRoot()->impPendingBlockMembers.Get(blk->bbInd()); } // Set the byte for "b" to "val" (allocating/extending impPendingBlockMembers if necessary.) // Operates on the map in the top-level ancestor. void impSetPendingBlockMember(BasicBlock* blk, BYTE val) { impInlineRoot()->impPendingBlockMembers.Set(blk->bbInd(), val); } bool impCanReimport; bool impSpillStackEntry(unsigned level, unsigned varNum #ifdef DEBUG , bool bAssertOnRecursion, const char* reason #endif ); void impSpillStackEnsure(bool spillLeaves = false); void impEvalSideEffects(); void impSpillSpecialSideEff(); void impSpillSideEffects(bool spillGlobEffects, unsigned chkLevel DEBUGARG(const char* reason)); void impSpillValueClasses(); void impSpillEvalStack(); static fgWalkPreFn impFindValueClasses; void impSpillLclRefs(ssize_t lclNum); BasicBlock* impPushCatchArgOnStack(BasicBlock* hndBlk, CORINFO_CLASS_HANDLE clsHnd, bool isSingleBlockFilter); bool impBlockIsInALoop(BasicBlock* block); void impImportBlockCode(BasicBlock* block); void impReimportMarkBlock(BasicBlock* block); void impReimportMarkSuccessors(BasicBlock* block); void impVerifyEHBlock(BasicBlock* block, bool isTryStart); void impImportBlockPending(BasicBlock* block); // Similar to impImportBlockPending, but assumes that block has already been imported once and is being // reimported for some reason. It specifically does *not* look at verCurrentState to set the EntryState // for the block, but instead, just re-uses the block's existing EntryState. void impReimportBlockPending(BasicBlock* block); var_types impGetByRefResultType(genTreeOps oper, bool fUnsigned, GenTree** pOp1, GenTree** pOp2); void impImportBlock(BasicBlock* block); // Assumes that "block" is a basic block that completes with a non-empty stack. We will assign the values // on the stack to local variables (the "spill temp" variables). The successor blocks will assume that // its incoming stack contents are in those locals. This requires "block" and its successors to agree on // the variables that will be used -- and for all the predecessors of those successors, and the // successors of those predecessors, etc. Call such a set of blocks closed under alternating // successor/predecessor edges a "spill clique." A block is a "predecessor" or "successor" member of the // clique (or, conceivably, both). Each block has a specified sequence of incoming and outgoing spill // temps. If "block" already has its outgoing spill temps assigned (they are always a contiguous series // of local variable numbers, so we represent them with the base local variable number), returns that. // Otherwise, picks a set of spill temps, and propagates this choice to all blocks in the spill clique of // which "block" is a member (asserting, in debug mode, that no block in this clique had its spill temps // chosen already. More precisely, that the incoming or outgoing spill temps are not chosen, depending // on which kind of member of the clique the block is). unsigned impGetSpillTmpBase(BasicBlock* block); // Assumes that "block" is a basic block that completes with a non-empty stack. We have previously // assigned the values on the stack to local variables (the "spill temp" variables). The successor blocks // will assume that its incoming stack contents are in those locals. This requires "block" and its // successors to agree on the variables and their types that will be used. The CLI spec allows implicit // conversions between 'int' and 'native int' or 'float' and 'double' stack types. So one predecessor can // push an int and another can push a native int. For 64-bit we have chosen to implement this by typing // the "spill temp" as native int, and then importing (or re-importing as needed) so that all the // predecessors in the "spill clique" push a native int (sign-extending if needed), and all the // successors receive a native int. Similarly float and double are unified to double. // This routine is called after a type-mismatch is detected, and it will walk the spill clique to mark // blocks for re-importation as appropriate (both successors, so they get the right incoming type, and // predecessors, so they insert an upcast if needed). void impReimportSpillClique(BasicBlock* block); // When we compute a "spill clique" (see above) these byte-maps are allocated to have a byte per basic // block, and represent the predecessor and successor members of the clique currently being computed. // *** Access to these will need to be locked in a parallel compiler. JitExpandArray<BYTE> impSpillCliquePredMembers; JitExpandArray<BYTE> impSpillCliqueSuccMembers; enum SpillCliqueDir { SpillCliquePred, SpillCliqueSucc }; // Abstract class for receiving a callback while walking a spill clique class SpillCliqueWalker { public: virtual void Visit(SpillCliqueDir predOrSucc, BasicBlock* blk) = 0; }; // This class is used for setting the bbStkTempsIn and bbStkTempsOut on the blocks within a spill clique class SetSpillTempsBase : public SpillCliqueWalker { unsigned m_baseTmp; public: SetSpillTempsBase(unsigned baseTmp) : m_baseTmp(baseTmp) { } virtual void Visit(SpillCliqueDir predOrSucc, BasicBlock* blk); }; // This class is used for implementing impReimportSpillClique part on each block within the spill clique class ReimportSpillClique : public SpillCliqueWalker { Compiler* m_pComp; public: ReimportSpillClique(Compiler* pComp) : m_pComp(pComp) { } virtual void Visit(SpillCliqueDir predOrSucc, BasicBlock* blk); }; // This is the heart of the algorithm for walking spill cliques. It invokes callback->Visit for each // predecessor or successor within the spill clique void impWalkSpillCliqueFromPred(BasicBlock* pred, SpillCliqueWalker* callback); // For a BasicBlock that has already been imported, the EntryState has an array of GenTrees for the // incoming locals. This walks that list an resets the types of the GenTrees to match the types of // the VarDscs. They get out of sync when we have int/native int issues (see impReimportSpillClique). void impRetypeEntryStateTemps(BasicBlock* blk); BYTE impSpillCliqueGetMember(SpillCliqueDir predOrSucc, BasicBlock* blk); void impSpillCliqueSetMember(SpillCliqueDir predOrSucc, BasicBlock* blk, BYTE val); void impPushVar(GenTree* op, typeInfo tiRetVal); GenTreeLclVar* impCreateLocalNode(unsigned lclNum DEBUGARG(IL_OFFSET offset)); void impLoadVar(unsigned lclNum, IL_OFFSET offset, const typeInfo& tiRetVal); void impLoadVar(unsigned lclNum, IL_OFFSET offset) { impLoadVar(lclNum, offset, lvaGetDesc(lclNum)->lvVerTypeInfo); } void impLoadArg(unsigned ilArgNum, IL_OFFSET offset); void impLoadLoc(unsigned ilLclNum, IL_OFFSET offset); bool impReturnInstruction(int prefixFlags, OPCODE& opcode); #ifdef TARGET_ARM void impMarkLclDstNotPromotable(unsigned tmpNum, GenTree* op, CORINFO_CLASS_HANDLE hClass); #endif // A free list of linked list nodes used to represent to-do stacks of basic blocks. struct BlockListNode { BasicBlock* m_blk; BlockListNode* m_next; BlockListNode(BasicBlock* blk, BlockListNode* next = nullptr) : m_blk(blk), m_next(next) { } void* operator new(size_t sz, Compiler* comp); }; BlockListNode* impBlockListNodeFreeList; void FreeBlockListNode(BlockListNode* node); bool impIsValueType(typeInfo* pTypeInfo); var_types mangleVarArgsType(var_types type); regNumber getCallArgIntRegister(regNumber floatReg); regNumber getCallArgFloatRegister(regNumber intReg); #if defined(DEBUG) static unsigned jitTotalMethodCompiled; #endif #ifdef DEBUG static LONG jitNestingLevel; #endif // DEBUG static bool impIsAddressInLocal(const GenTree* tree, GenTree** lclVarTreeOut = nullptr); void impMakeDiscretionaryInlineObservations(InlineInfo* pInlineInfo, InlineResult* inlineResult); // STATIC inlining decision based on the IL code. void impCanInlineIL(CORINFO_METHOD_HANDLE fncHandle, CORINFO_METHOD_INFO* methInfo, bool forceInline, InlineResult* inlineResult); void impCheckCanInline(GenTreeCall* call, CORINFO_METHOD_HANDLE fncHandle, unsigned methAttr, CORINFO_CONTEXT_HANDLE exactContextHnd, InlineCandidateInfo** ppInlineCandidateInfo, InlineResult* inlineResult); void impInlineRecordArgInfo(InlineInfo* pInlineInfo, GenTree* curArgVal, unsigned argNum, InlineResult* inlineResult); void impInlineInitVars(InlineInfo* pInlineInfo); unsigned impInlineFetchLocal(unsigned lclNum DEBUGARG(const char* reason)); GenTree* impInlineFetchArg(unsigned lclNum, InlArgInfo* inlArgInfo, InlLclVarInfo* lclTypeInfo); bool impInlineIsThis(GenTree* tree, InlArgInfo* inlArgInfo); bool impInlineIsGuaranteedThisDerefBeforeAnySideEffects(GenTree* additionalTree, GenTreeCall::Use* additionalCallArgs, GenTree* dereferencedAddress, InlArgInfo* inlArgInfo); void impMarkInlineCandidate(GenTree* call, CORINFO_CONTEXT_HANDLE exactContextHnd, bool exactContextNeedsRuntimeLookup, CORINFO_CALL_INFO* callInfo); void impMarkInlineCandidateHelper(GenTreeCall* call, CORINFO_CONTEXT_HANDLE exactContextHnd, bool exactContextNeedsRuntimeLookup, CORINFO_CALL_INFO* callInfo); bool impTailCallRetTypeCompatible(bool allowWidening, var_types callerRetType, CORINFO_CLASS_HANDLE callerRetTypeClass, CorInfoCallConvExtension callerCallConv, var_types calleeRetType, CORINFO_CLASS_HANDLE calleeRetTypeClass, CorInfoCallConvExtension calleeCallConv); bool impIsTailCallILPattern( bool tailPrefixed, OPCODE curOpcode, const BYTE* codeAddrOfNextOpcode, const BYTE* codeEnd, bool isRecursive); bool impIsImplicitTailCallCandidate( OPCODE curOpcode, const BYTE* codeAddrOfNextOpcode, const BYTE* codeEnd, int prefixFlags, bool isRecursive); bool impIsClassExact(CORINFO_CLASS_HANDLE classHnd); bool impCanSkipCovariantStoreCheck(GenTree* value, GenTree* array); CORINFO_RESOLVED_TOKEN* impAllocateToken(const CORINFO_RESOLVED_TOKEN& token); /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX FlowGraph XX XX XX XX Info about the basic-blocks, their contents and the flow analysis XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ public: BasicBlock* fgFirstBB; // Beginning of the basic block list BasicBlock* fgLastBB; // End of the basic block list BasicBlock* fgFirstColdBlock; // First block to be placed in the cold section BasicBlock* fgEntryBB; // For OSR, the original method's entry point BasicBlock* fgOSREntryBB; // For OSR, the logical entry point (~ patchpoint) #if defined(FEATURE_EH_FUNCLETS) BasicBlock* fgFirstFuncletBB; // First block of outlined funclets (to allow block insertion before the funclets) #endif BasicBlock* fgFirstBBScratch; // Block inserted for initialization stuff. Is nullptr if no such block has been // created. BasicBlockList* fgReturnBlocks; // list of BBJ_RETURN blocks unsigned fgEdgeCount; // # of control flow edges between the BBs unsigned fgBBcount; // # of BBs in the method #ifdef DEBUG unsigned fgBBcountAtCodegen; // # of BBs in the method at the start of codegen #endif unsigned fgBBNumMax; // The max bbNum that has been assigned to basic blocks unsigned fgDomBBcount; // # of BBs for which we have dominator and reachability information BasicBlock** fgBBInvPostOrder; // The flow graph stored in an array sorted in topological order, needed to compute // dominance. Indexed by block number. Size: fgBBNumMax + 1. // After the dominance tree is computed, we cache a DFS preorder number and DFS postorder number to compute // dominance queries in O(1). fgDomTreePreOrder and fgDomTreePostOrder are arrays giving the block's preorder and // postorder number, respectively. The arrays are indexed by basic block number. (Note that blocks are numbered // starting from one. Thus, we always waste element zero. This makes debugging easier and makes the code less likely // to suffer from bugs stemming from forgetting to add or subtract one from the block number to form an array // index). The arrays are of size fgBBNumMax + 1. unsigned* fgDomTreePreOrder; unsigned* fgDomTreePostOrder; // Dominator tree used by SSA construction and copy propagation (the two are expected to use the same tree // in order to avoid the need for SSA reconstruction and an "out of SSA" phase). DomTreeNode* fgSsaDomTree; bool fgBBVarSetsInited; // Allocate array like T* a = new T[fgBBNumMax + 1]; // Using helper so we don't keep forgetting +1. template <typename T> T* fgAllocateTypeForEachBlk(CompMemKind cmk = CMK_Unknown) { return getAllocator(cmk).allocate<T>(fgBBNumMax + 1); } // BlockSets are relative to a specific set of BasicBlock numbers. If that changes // (if the blocks are renumbered), this changes. BlockSets from different epochs // cannot be meaningfully combined. Note that new blocks can be created with higher // block numbers without changing the basic block epoch. These blocks *cannot* // participate in a block set until the blocks are all renumbered, causing the epoch // to change. This is useful if continuing to use previous block sets is valuable. // If the epoch is zero, then it is uninitialized, and block sets can't be used. unsigned fgCurBBEpoch; unsigned GetCurBasicBlockEpoch() { return fgCurBBEpoch; } // The number of basic blocks in the current epoch. When the blocks are renumbered, // this is fgBBcount. As blocks are added, fgBBcount increases, fgCurBBEpochSize remains // the same, until a new BasicBlock epoch is created, such as when the blocks are all renumbered. unsigned fgCurBBEpochSize; // The number of "size_t" elements required to hold a bitset large enough for fgCurBBEpochSize // bits. This is precomputed to avoid doing math every time BasicBlockBitSetTraits::GetArrSize() is called. unsigned fgBBSetCountInSizeTUnits; void NewBasicBlockEpoch() { INDEBUG(unsigned oldEpochArrSize = fgBBSetCountInSizeTUnits); // We have a new epoch. Compute and cache the size needed for new BlockSets. fgCurBBEpoch++; fgCurBBEpochSize = fgBBNumMax + 1; fgBBSetCountInSizeTUnits = roundUp(fgCurBBEpochSize, (unsigned)(sizeof(size_t) * 8)) / unsigned(sizeof(size_t) * 8); #ifdef DEBUG // All BlockSet objects are now invalid! fgReachabilitySetsValid = false; // the bbReach sets are now invalid! fgEnterBlksSetValid = false; // the fgEnterBlks set is now invalid! if (verbose) { unsigned epochArrSize = BasicBlockBitSetTraits::GetArrSize(this, sizeof(size_t)); printf("\nNew BlockSet epoch %d, # of blocks (including unused BB00): %u, bitset array size: %u (%s)", fgCurBBEpoch, fgCurBBEpochSize, epochArrSize, (epochArrSize <= 1) ? "short" : "long"); if ((fgCurBBEpoch != 1) && ((oldEpochArrSize <= 1) != (epochArrSize <= 1))) { // If we're not just establishing the first epoch, and the epoch array size has changed such that we're // going to change our bitset representation from short (just a size_t bitset) to long (a pointer to an // array of size_t bitsets), then print that out. printf("; NOTE: BlockSet size was previously %s!", (oldEpochArrSize <= 1) ? "short" : "long"); } printf("\n"); } #endif // DEBUG } void EnsureBasicBlockEpoch() { if (fgCurBBEpochSize != fgBBNumMax + 1) { NewBasicBlockEpoch(); } } BasicBlock* fgNewBasicBlock(BBjumpKinds jumpKind); void fgEnsureFirstBBisScratch(); bool fgFirstBBisScratch(); bool fgBBisScratch(BasicBlock* block); void fgExtendEHRegionBefore(BasicBlock* block); void fgExtendEHRegionAfter(BasicBlock* block); BasicBlock* fgNewBBbefore(BBjumpKinds jumpKind, BasicBlock* block, bool extendRegion); BasicBlock* fgNewBBafter(BBjumpKinds jumpKind, BasicBlock* block, bool extendRegion); BasicBlock* fgNewBBinRegion(BBjumpKinds jumpKind, unsigned tryIndex, unsigned hndIndex, BasicBlock* nearBlk, bool putInFilter = false, bool runRarely = false, bool insertAtEnd = false); BasicBlock* fgNewBBinRegion(BBjumpKinds jumpKind, BasicBlock* srcBlk, bool runRarely = false, bool insertAtEnd = false); BasicBlock* fgNewBBinRegion(BBjumpKinds jumpKind); BasicBlock* fgNewBBinRegionWorker(BBjumpKinds jumpKind, BasicBlock* afterBlk, unsigned xcptnIndex, bool putInTryRegion); void fgInsertBBbefore(BasicBlock* insertBeforeBlk, BasicBlock* newBlk); void fgInsertBBafter(BasicBlock* insertAfterBlk, BasicBlock* newBlk); void fgUnlinkBlock(BasicBlock* block); #ifdef FEATURE_JIT_METHOD_PERF unsigned fgMeasureIR(); #endif // FEATURE_JIT_METHOD_PERF bool fgModified; // True if the flow graph has been modified recently bool fgComputePredsDone; // Have we computed the bbPreds list bool fgCheapPredsValid; // Is the bbCheapPreds list valid? bool fgDomsComputed; // Have we computed the dominator sets? bool fgReturnBlocksComputed; // Have we computed the return blocks list? bool fgOptimizedFinally; // Did we optimize any try-finallys? bool fgHasSwitch; // any BBJ_SWITCH jumps? BlockSet fgEnterBlks; // Set of blocks which have a special transfer of control; the "entry" blocks plus EH handler // begin blocks. #if defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM) BlockSet fgAlwaysBlks; // Set of blocks which are BBJ_ALWAYS part of BBJ_CALLFINALLY/BBJ_ALWAYS pair that should // never be removed due to a requirement to use the BBJ_ALWAYS for generating code and // not have "retless" blocks. #endif // defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM) #ifdef DEBUG bool fgReachabilitySetsValid; // Are the bbReach sets valid? bool fgEnterBlksSetValid; // Is the fgEnterBlks set valid? #endif // DEBUG bool fgRemoveRestOfBlock; // true if we know that we will throw bool fgStmtRemoved; // true if we remove statements -> need new DFA // There are two modes for ordering of the trees. // - In FGOrderTree, the dominant ordering is the tree order, and the nodes contained in // each tree and sub-tree are contiguous, and can be traversed (in gtNext/gtPrev order) // by traversing the tree according to the order of the operands. // - In FGOrderLinear, the dominant ordering is the linear order. enum FlowGraphOrder { FGOrderTree, FGOrderLinear }; FlowGraphOrder fgOrder; // The following are boolean flags that keep track of the state of internal data structures bool fgStmtListThreaded; // true if the node list is now threaded bool fgCanRelocateEHRegions; // true if we are allowed to relocate the EH regions bool fgEdgeWeightsComputed; // true after we have called fgComputeEdgeWeights bool fgHaveValidEdgeWeights; // true if we were successful in computing all of the edge weights bool fgSlopUsedInEdgeWeights; // true if their was some slop used when computing the edge weights bool fgRangeUsedInEdgeWeights; // true if some of the edgeWeight are expressed in Min..Max form bool fgNeedsUpdateFlowGraph; // true if we need to run fgUpdateFlowGraph weight_t fgCalledCount; // count of the number of times this method was called // This is derived from the profile data // or is BB_UNITY_WEIGHT when we don't have profile data #if defined(FEATURE_EH_FUNCLETS) bool fgFuncletsCreated; // true if the funclet creation phase has been run #endif // FEATURE_EH_FUNCLETS bool fgGlobalMorph; // indicates if we are during the global morphing phase // since fgMorphTree can be called from several places bool impBoxTempInUse; // the temp below is valid and available unsigned impBoxTemp; // a temporary that is used for boxing #ifdef DEBUG bool jitFallbackCompile; // Are we doing a fallback compile? That is, have we executed a NO_WAY assert, // and we are trying to compile again in a "safer", minopts mode? #endif #if defined(DEBUG) unsigned impInlinedCodeSize; bool fgPrintInlinedMethods; #endif jitstd::vector<flowList*>* fgPredListSortVector; //------------------------------------------------------------------------- void fgInit(); PhaseStatus fgImport(); PhaseStatus fgTransformIndirectCalls(); PhaseStatus fgTransformPatchpoints(); PhaseStatus fgInline(); PhaseStatus fgRemoveEmptyTry(); PhaseStatus fgRemoveEmptyFinally(); PhaseStatus fgMergeFinallyChains(); PhaseStatus fgCloneFinally(); void fgCleanupContinuation(BasicBlock* continuation); #if defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM) PhaseStatus fgUpdateFinallyTargetFlags(); void fgClearAllFinallyTargetBits(); void fgAddFinallyTargetFlags(); #endif // defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM) PhaseStatus fgTailMergeThrows(); void fgTailMergeThrowsFallThroughHelper(BasicBlock* predBlock, BasicBlock* nonCanonicalBlock, BasicBlock* canonicalBlock, flowList* predEdge); void fgTailMergeThrowsJumpToHelper(BasicBlock* predBlock, BasicBlock* nonCanonicalBlock, BasicBlock* canonicalBlock, flowList* predEdge); GenTree* fgCheckCallArgUpdate(GenTree* parent, GenTree* child, var_types origType); #if defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM) // Sometimes we need to defer updating the BBF_FINALLY_TARGET bit. fgNeedToAddFinallyTargetBits signals // when this is necessary. bool fgNeedToAddFinallyTargetBits; #endif // defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM) bool fgRetargetBranchesToCanonicalCallFinally(BasicBlock* block, BasicBlock* handler, BlockToBlockMap& continuationMap); GenTree* fgGetCritSectOfStaticMethod(); #if defined(FEATURE_EH_FUNCLETS) void fgAddSyncMethodEnterExit(); GenTree* fgCreateMonitorTree(unsigned lvaMonitorBool, unsigned lvaThisVar, BasicBlock* block, bool enter); void fgConvertSyncReturnToLeave(BasicBlock* block); #endif // FEATURE_EH_FUNCLETS void fgAddReversePInvokeEnterExit(); bool fgMoreThanOneReturnBlock(); // The number of separate return points in the method. unsigned fgReturnCount; void fgAddInternal(); enum class FoldResult { FOLD_DID_NOTHING, FOLD_CHANGED_CONTROL_FLOW, FOLD_REMOVED_LAST_STMT, FOLD_ALTERED_LAST_STMT, }; FoldResult fgFoldConditional(BasicBlock* block); void fgMorphStmts(BasicBlock* block); void fgMorphBlocks(); void fgMergeBlockReturn(BasicBlock* block); bool fgMorphBlockStmt(BasicBlock* block, Statement* stmt DEBUGARG(const char* msg)); void fgSetOptions(); #ifdef DEBUG static fgWalkPreFn fgAssertNoQmark; void fgPreExpandQmarkChecks(GenTree* expr); void fgPostExpandQmarkChecks(); static void fgCheckQmarkAllowedForm(GenTree* tree); #endif IL_OFFSET fgFindBlockILOffset(BasicBlock* block); void fgFixEntryFlowForOSR(); BasicBlock* fgSplitBlockAtBeginning(BasicBlock* curr); BasicBlock* fgSplitBlockAtEnd(BasicBlock* curr); BasicBlock* fgSplitBlockAfterStatement(BasicBlock* curr, Statement* stmt); BasicBlock* fgSplitBlockAfterNode(BasicBlock* curr, GenTree* node); // for LIR BasicBlock* fgSplitEdge(BasicBlock* curr, BasicBlock* succ); Statement* fgNewStmtFromTree(GenTree* tree, BasicBlock* block, const DebugInfo& di); Statement* fgNewStmtFromTree(GenTree* tree); Statement* fgNewStmtFromTree(GenTree* tree, BasicBlock* block); Statement* fgNewStmtFromTree(GenTree* tree, const DebugInfo& di); GenTree* fgGetTopLevelQmark(GenTree* expr, GenTree** ppDst = nullptr); void fgExpandQmarkForCastInstOf(BasicBlock* block, Statement* stmt); void fgExpandQmarkStmt(BasicBlock* block, Statement* stmt); void fgExpandQmarkNodes(); // Do "simple lowering." This functionality is (conceptually) part of "general" // lowering that is distributed between fgMorph and the lowering phase of LSRA. void fgSimpleLowering(); GenTree* fgInitThisClass(); GenTreeCall* fgGetStaticsCCtorHelper(CORINFO_CLASS_HANDLE cls, CorInfoHelpFunc helper); GenTreeCall* fgGetSharedCCtor(CORINFO_CLASS_HANDLE cls); bool backendRequiresLocalVarLifetimes() { return !opts.MinOpts() || m_pLinearScan->willEnregisterLocalVars(); } void fgLocalVarLiveness(); void fgLocalVarLivenessInit(); void fgPerNodeLocalVarLiveness(GenTree* node); void fgPerBlockLocalVarLiveness(); VARSET_VALRET_TP fgGetHandlerLiveVars(BasicBlock* block); void fgLiveVarAnalysis(bool updateInternalOnly = false); void fgComputeLifeCall(VARSET_TP& life, GenTreeCall* call); void fgComputeLifeTrackedLocalUse(VARSET_TP& life, LclVarDsc& varDsc, GenTreeLclVarCommon* node); bool fgComputeLifeTrackedLocalDef(VARSET_TP& life, VARSET_VALARG_TP keepAliveVars, LclVarDsc& varDsc, GenTreeLclVarCommon* node); bool fgComputeLifeUntrackedLocal(VARSET_TP& life, VARSET_VALARG_TP keepAliveVars, LclVarDsc& varDsc, GenTreeLclVarCommon* lclVarNode); bool fgComputeLifeLocal(VARSET_TP& life, VARSET_VALARG_TP keepAliveVars, GenTree* lclVarNode); void fgComputeLife(VARSET_TP& life, GenTree* startNode, GenTree* endNode, VARSET_VALARG_TP volatileVars, bool* pStmtInfoDirty DEBUGARG(bool* treeModf)); void fgComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VARSET_VALARG_TP volatileVars); bool fgTryRemoveNonLocal(GenTree* node, LIR::Range* blockRange); void fgRemoveDeadStoreLIR(GenTree* store, BasicBlock* block); bool fgRemoveDeadStore(GenTree** pTree, LclVarDsc* varDsc, VARSET_VALARG_TP life, bool* doAgain, bool* pStmtInfoDirty, bool* pStoreRemoved DEBUGARG(bool* treeModf)); void fgInterBlockLocalVarLiveness(); // Blocks: convenience methods for enabling range-based `for` iteration over the function's blocks, e.g.: // 1. for (BasicBlock* const block : compiler->Blocks()) ... // 2. for (BasicBlock* const block : compiler->Blocks(startBlock)) ... // 3. for (BasicBlock* const block : compiler->Blocks(startBlock, endBlock)) ... // In case (1), the block list can be empty. In case (2), `startBlock` can be nullptr. In case (3), // both `startBlock` and `endBlock` must be non-null. // BasicBlockSimpleList Blocks() const { return BasicBlockSimpleList(fgFirstBB); } BasicBlockSimpleList Blocks(BasicBlock* startBlock) const { return BasicBlockSimpleList(startBlock); } BasicBlockRangeList Blocks(BasicBlock* startBlock, BasicBlock* endBlock) const { return BasicBlockRangeList(startBlock, endBlock); } // The presence of a partial definition presents some difficulties for SSA: this is both a use of some SSA name // of "x", and a def of a new SSA name for "x". The tree only has one local variable for "x", so it has to choose // whether to treat that as the use or def. It chooses the "use", and thus the old SSA name. This map allows us // to record/recover the "def" SSA number, given the lcl var node for "x" in such a tree. typedef JitHashTable<GenTree*, JitPtrKeyFuncs<GenTree>, unsigned> NodeToUnsignedMap; NodeToUnsignedMap* m_opAsgnVarDefSsaNums; NodeToUnsignedMap* GetOpAsgnVarDefSsaNums() { if (m_opAsgnVarDefSsaNums == nullptr) { m_opAsgnVarDefSsaNums = new (getAllocator()) NodeToUnsignedMap(getAllocator()); } return m_opAsgnVarDefSsaNums; } // This map tracks nodes whose value numbers explicitly or implicitly depend on memory states. // The map provides the entry block of the most closely enclosing loop that // defines the memory region accessed when defining the nodes's VN. // // This information should be consulted when considering hoisting node out of a loop, as the VN // for the node will only be valid within the indicated loop. // // It is not fine-grained enough to track memory dependence within loops, so cannot be used // for more general code motion. // // If a node does not have an entry in the map we currently assume the VN is not memory dependent // and so memory does not constrain hoisting. // typedef JitHashTable<GenTree*, JitPtrKeyFuncs<GenTree>, BasicBlock*> NodeToLoopMemoryBlockMap; NodeToLoopMemoryBlockMap* m_nodeToLoopMemoryBlockMap; NodeToLoopMemoryBlockMap* GetNodeToLoopMemoryBlockMap() { if (m_nodeToLoopMemoryBlockMap == nullptr) { m_nodeToLoopMemoryBlockMap = new (getAllocator()) NodeToLoopMemoryBlockMap(getAllocator()); } return m_nodeToLoopMemoryBlockMap; } void optRecordLoopMemoryDependence(GenTree* tree, BasicBlock* block, ValueNum memoryVN); void optCopyLoopMemoryDependence(GenTree* fromTree, GenTree* toTree); // Requires value numbering phase to have completed. Returns the value number ("gtVN") of the // "tree," EXCEPT in the case of GTF_VAR_USEASG, because the tree node's gtVN member is the // "use" VN. Performs a lookup into the map of (use asg tree -> def VN.) to return the "def's" // VN. inline ValueNum GetUseAsgDefVNOrTreeVN(GenTree* tree); // Requires that "lcl" has the GTF_VAR_DEF flag set. Returns the SSA number of "lcl". // Except: assumes that lcl is a def, and if it is // a partial def (GTF_VAR_USEASG), looks up and returns the SSA number for the "def", // rather than the "use" SSA number recorded in the tree "lcl". inline unsigned GetSsaNumForLocalVarDef(GenTree* lcl); inline bool PreciseRefCountsRequired(); // Performs SSA conversion. void fgSsaBuild(); // Reset any data structures to the state expected by "fgSsaBuild", so it can be run again. void fgResetForSsa(); unsigned fgSsaPassesCompleted; // Number of times fgSsaBuild has been run. // Returns "true" if this is a special variable that is never zero initialized in the prolog. inline bool fgVarIsNeverZeroInitializedInProlog(unsigned varNum); // Returns "true" if the variable needs explicit zero initialization. inline bool fgVarNeedsExplicitZeroInit(unsigned varNum, bool bbInALoop, bool bbIsReturn); // The value numbers for this compilation. ValueNumStore* vnStore; public: ValueNumStore* GetValueNumStore() { return vnStore; } // Do value numbering (assign a value number to each // tree node). void fgValueNumber(); // Computes new GcHeap VN via the assignment H[elemTypeEq][arrVN][inx][fldSeq] = rhsVN. // Assumes that "elemTypeEq" is the (equivalence class rep) of the array element type. // The 'indType' is the indirection type of the lhs of the assignment and will typically // match the element type of the array or fldSeq. When this type doesn't match // or if the fldSeq is 'NotAField' we invalidate the array contents H[elemTypeEq][arrVN] // ValueNum fgValueNumberArrIndexAssign(CORINFO_CLASS_HANDLE elemTypeEq, ValueNum arrVN, ValueNum inxVN, FieldSeqNode* fldSeq, ValueNum rhsVN, var_types indType); // Requires that "tree" is a GT_IND marked as an array index, and that its address argument // has been parsed to yield the other input arguments. If evaluation of the address // can raise exceptions, those should be captured in the exception set "addrXvnp". // Assumes that "elemTypeEq" is the (equivalence class rep) of the array element type. // Marks "tree" with the VN for H[elemTypeEq][arrVN][inx][fldSeq] (for the liberal VN; a new unique // VN for the conservative VN.) Also marks the tree's argument as the address of an array element. // The type tree->TypeGet() will typically match the element type of the array or fldSeq. // When this type doesn't match or if the fldSeq is 'NotAField' we return a new unique VN // ValueNum fgValueNumberArrIndexVal(GenTree* tree, CORINFO_CLASS_HANDLE elemTypeEq, ValueNum arrVN, ValueNum inxVN, ValueNumPair addrXvnp, FieldSeqNode* fldSeq); // Requires "funcApp" to be a VNF_PtrToArrElem, and "addrXvnp" to represent the exception set thrown // by evaluating the array index expression "tree". Returns the value number resulting from // dereferencing the array in the current GcHeap state. If "tree" is non-null, it must be the // "GT_IND" that does the dereference, and it is given the returned value number. ValueNum fgValueNumberArrIndexVal(GenTree* tree, VNFuncApp* funcApp, ValueNumPair addrXvnp); // Compute the value number for a byref-exposed load of the given type via the given pointerVN. ValueNum fgValueNumberByrefExposedLoad(var_types type, ValueNum pointerVN); unsigned fgVNPassesCompleted; // Number of times fgValueNumber has been run. // Utility functions for fgValueNumber. // Perform value-numbering for the trees in "blk". void fgValueNumberBlock(BasicBlock* blk); // Requires that "entryBlock" is the entry block of loop "loopNum", and that "loopNum" is the // innermost loop of which "entryBlock" is the entry. Returns the value number that should be // assumed for the memoryKind at the start "entryBlk". ValueNum fgMemoryVNForLoopSideEffects(MemoryKind memoryKind, BasicBlock* entryBlock, unsigned loopNum); // Called when an operation (performed by "tree", described by "msg") may cause the GcHeap to be mutated. // As GcHeap is a subset of ByrefExposed, this will also annotate the ByrefExposed mutation. void fgMutateGcHeap(GenTree* tree DEBUGARG(const char* msg)); // Called when an operation (performed by "tree", described by "msg") may cause an address-exposed local to be // mutated. void fgMutateAddressExposedLocal(GenTree* tree DEBUGARG(const char* msg)); // For a GC heap store at curTree, record the new curMemoryVN's and update curTree's MemorySsaMap. // As GcHeap is a subset of ByrefExposed, this will also record the ByrefExposed store. void recordGcHeapStore(GenTree* curTree, ValueNum gcHeapVN DEBUGARG(const char* msg)); // For a store to an address-exposed local at curTree, record the new curMemoryVN and update curTree's MemorySsaMap. void recordAddressExposedLocalStore(GenTree* curTree, ValueNum memoryVN DEBUGARG(const char* msg)); void fgSetCurrentMemoryVN(MemoryKind memoryKind, ValueNum newMemoryVN); // Tree caused an update in the current memory VN. If "tree" has an associated heap SSA #, record that // value in that SSA #. void fgValueNumberRecordMemorySsa(MemoryKind memoryKind, GenTree* tree); // The input 'tree' is a leaf node that is a constant // Assign the proper value number to the tree void fgValueNumberTreeConst(GenTree* tree); // If the VN store has been initialized, reassign the // proper value number to the constant tree. void fgUpdateConstTreeValueNumber(GenTree* tree); // Assumes that all inputs to "tree" have had value numbers assigned; assigns a VN to tree. // (With some exceptions: the VN of the lhs of an assignment is assigned as part of the // assignment.) void fgValueNumberTree(GenTree* tree); void fgValueNumberAssignment(GenTreeOp* tree); // Does value-numbering for a block assignment. void fgValueNumberBlockAssignment(GenTree* tree); bool fgValueNumberBlockAssignmentTypeCheck(LclVarDsc* dstVarDsc, FieldSeqNode* dstFldSeq, GenTree* src); // Does value-numbering for a cast tree. void fgValueNumberCastTree(GenTree* tree); // Does value-numbering for an intrinsic tree. void fgValueNumberIntrinsic(GenTree* tree); #ifdef FEATURE_SIMD // Does value-numbering for a GT_SIMD tree void fgValueNumberSimd(GenTreeSIMD* tree); #endif // FEATURE_SIMD #ifdef FEATURE_HW_INTRINSICS // Does value-numbering for a GT_HWINTRINSIC tree void fgValueNumberHWIntrinsic(GenTreeHWIntrinsic* tree); #endif // FEATURE_HW_INTRINSICS // Does value-numbering for a call. We interpret some helper calls. void fgValueNumberCall(GenTreeCall* call); // Does value-numbering for a helper representing a cast operation. void fgValueNumberCastHelper(GenTreeCall* call); // Does value-numbering for a helper "call" that has a VN function symbol "vnf". void fgValueNumberHelperCallFunc(GenTreeCall* call, VNFunc vnf, ValueNumPair vnpExc); // Requires "helpCall" to be a helper call. Assigns it a value number; // we understand the semantics of some of the calls. Returns "true" if // the call may modify the heap (we assume arbitrary memory side effects if so). bool fgValueNumberHelperCall(GenTreeCall* helpCall); // Requires that "helpFunc" is one of the pure Jit Helper methods. // Returns the corresponding VNFunc to use for value numbering VNFunc fgValueNumberJitHelperMethodVNFunc(CorInfoHelpFunc helpFunc); // Adds the exception set for the current tree node which has a memory indirection operation void fgValueNumberAddExceptionSetForIndirection(GenTree* tree, GenTree* baseAddr); // Adds the exception sets for the current tree node which is performing a division or modulus operation void fgValueNumberAddExceptionSetForDivision(GenTree* tree); // Adds the exception set for the current tree node which is performing a overflow checking operation void fgValueNumberAddExceptionSetForOverflow(GenTree* tree); // Adds the exception set for the current tree node which is performing a bounds check operation void fgValueNumberAddExceptionSetForBoundsCheck(GenTree* tree); // Adds the exception set for the current tree node which is performing a ckfinite operation void fgValueNumberAddExceptionSetForCkFinite(GenTree* tree); // Adds the exception sets for the current tree node void fgValueNumberAddExceptionSet(GenTree* tree); #ifdef DEBUG void fgDebugCheckExceptionSets(); void fgDebugCheckValueNumberedTree(GenTree* tree); #endif // These are the current value number for the memory implicit variables while // doing value numbering. These are the value numbers under the "liberal" interpretation // of memory values; the "conservative" interpretation needs no VN, since every access of // memory yields an unknown value. ValueNum fgCurMemoryVN[MemoryKindCount]; // Return a "pseudo"-class handle for an array element type. If "elemType" is TYP_STRUCT, // requires "elemStructType" to be non-null (and to have a low-order zero). Otherwise, low order bit // is 1, and the rest is an encoding of "elemTyp". static CORINFO_CLASS_HANDLE EncodeElemType(var_types elemTyp, CORINFO_CLASS_HANDLE elemStructType) { if (elemStructType != nullptr) { assert(varTypeIsStruct(elemTyp) || elemTyp == TYP_REF || elemTyp == TYP_BYREF || varTypeIsIntegral(elemTyp)); assert((size_t(elemStructType) & 0x1) == 0x0); // Make sure the encoding below is valid. return elemStructType; } else { assert(elemTyp != TYP_STRUCT); elemTyp = varTypeToSigned(elemTyp); return CORINFO_CLASS_HANDLE(size_t(elemTyp) << 1 | 0x1); } } // If "clsHnd" is the result of an "EncodePrim" call, returns true and sets "*pPrimType" to the // var_types it represents. Otherwise, returns TYP_STRUCT (on the assumption that "clsHnd" is // the struct type of the element). static var_types DecodeElemType(CORINFO_CLASS_HANDLE clsHnd) { size_t clsHndVal = size_t(clsHnd); if (clsHndVal & 0x1) { return var_types(clsHndVal >> 1); } else { return TYP_STRUCT; } } // Convert a BYTE which represents the VM's CorInfoGCtype to the JIT's var_types var_types getJitGCType(BYTE gcType); // Returns true if the provided type should be treated as a primitive type // for the unmanaged calling conventions. bool isNativePrimitiveStructType(CORINFO_CLASS_HANDLE clsHnd); enum structPassingKind { SPK_Unknown, // Invalid value, never returned SPK_PrimitiveType, // The struct is passed/returned using a primitive type. SPK_EnclosingType, // Like SPK_Primitive type, but used for return types that // require a primitive type temp that is larger than the struct size. // Currently used for structs of size 3, 5, 6, or 7 bytes. SPK_ByValue, // The struct is passed/returned by value (using the ABI rules) // for ARM64 and UNIX_X64 in multiple registers. (when all of the // parameters registers are used, then the stack will be used) // for X86 passed on the stack, for ARM32 passed in registers // or the stack or split between registers and the stack. SPK_ByValueAsHfa, // The struct is passed/returned as an HFA in multiple registers. SPK_ByReference }; // The struct is passed/returned by reference to a copy/buffer. // Get the "primitive" type that is is used when we are given a struct of size 'structSize'. // For pointer sized structs the 'clsHnd' is used to determine if the struct contains GC ref. // A "primitive" type is one of the scalar types: byte, short, int, long, ref, float, double // If we can't or shouldn't use a "primitive" type then TYP_UNKNOWN is returned. // // isVarArg is passed for use on Windows Arm64 to change the decision returned regarding // hfa types. // var_types getPrimitiveTypeForStruct(unsigned structSize, CORINFO_CLASS_HANDLE clsHnd, bool isVarArg); // Get the type that is used to pass values of the given struct type. // isVarArg is passed for use on Windows Arm64 to change the decision returned regarding // hfa types. // var_types getArgTypeForStruct(CORINFO_CLASS_HANDLE clsHnd, structPassingKind* wbPassStruct, bool isVarArg, unsigned structSize); // Get the type that is used to return values of the given struct type. // If the size is unknown, pass 0 and it will be determined from 'clsHnd'. var_types getReturnTypeForStruct(CORINFO_CLASS_HANDLE clsHnd, CorInfoCallConvExtension callConv, structPassingKind* wbPassStruct = nullptr, unsigned structSize = 0); #ifdef DEBUG // Print a representation of "vnp" or "vn" on standard output. // If "level" is non-zero, we also print out a partial expansion of the value. void vnpPrint(ValueNumPair vnp, unsigned level); void vnPrint(ValueNum vn, unsigned level); #endif bool fgDominate(BasicBlock* b1, BasicBlock* b2); // Return true if b1 dominates b2 // Dominator computation member functions // Not exposed outside Compiler protected: bool fgReachable(BasicBlock* b1, BasicBlock* b2); // Returns true if block b1 can reach block b2 // Compute immediate dominators, the dominator tree and and its pre/post-order travsersal numbers. void fgComputeDoms(); void fgCompDominatedByExceptionalEntryBlocks(); BlockSet_ValRet_T fgGetDominatorSet(BasicBlock* block); // Returns a set of blocks that dominate the given block. // Note: this is relatively slow compared to calling fgDominate(), // especially if dealing with a single block versus block check. void fgComputeReachabilitySets(); // Compute bbReach sets. (Also sets BBF_GC_SAFE_POINT flag on blocks.) void fgComputeReturnBlocks(); // Initialize fgReturnBlocks to a list of BBJ_RETURN blocks. void fgComputeEnterBlocksSet(); // Compute the set of entry blocks, 'fgEnterBlks'. bool fgRemoveUnreachableBlocks(); // Remove blocks determined to be unreachable by the bbReach sets. void fgComputeReachability(); // Perform flow graph node reachability analysis. BasicBlock* fgIntersectDom(BasicBlock* a, BasicBlock* b); // Intersect two immediate dominator sets. void fgDfsInvPostOrder(); // In order to compute dominance using fgIntersectDom, the flow graph nodes must be // processed in topological sort, this function takes care of that. void fgDfsInvPostOrderHelper(BasicBlock* block, BlockSet& visited, unsigned* count); BlockSet_ValRet_T fgDomFindStartNodes(); // Computes which basic blocks don't have incoming edges in the flow graph. // Returns this as a set. INDEBUG(void fgDispDomTree(DomTreeNode* domTree);) // Helper that prints out the Dominator Tree in debug builds. DomTreeNode* fgBuildDomTree(); // Once we compute all the immediate dominator sets for each node in the flow graph // (performed by fgComputeDoms), this procedure builds the dominance tree represented // adjacency lists. // In order to speed up the queries of the form 'Does A dominates B', we can perform a DFS preorder and postorder // traversal of the dominance tree and the dominance query will become A dominates B iif preOrder(A) <= preOrder(B) // && postOrder(A) >= postOrder(B) making the computation O(1). void fgNumberDomTree(DomTreeNode* domTree); // When the flow graph changes, we need to update the block numbers, predecessor lists, reachability sets, // dominators, and possibly loops. void fgUpdateChangedFlowGraph(const bool computePreds = true, const bool computeDoms = true, const bool computeReturnBlocks = false, const bool computeLoops = false); public: // Compute the predecessors of the blocks in the control flow graph. void fgComputePreds(); // Remove all predecessor information. void fgRemovePreds(); // Compute the cheap flow graph predecessors lists. This is used in some early phases // before the full predecessors lists are computed. void fgComputeCheapPreds(); private: void fgAddCheapPred(BasicBlock* block, BasicBlock* blockPred); void fgRemoveCheapPred(BasicBlock* block, BasicBlock* blockPred); public: enum GCPollType { GCPOLL_NONE, GCPOLL_CALL, GCPOLL_INLINE }; // Initialize the per-block variable sets (used for liveness analysis). void fgInitBlockVarSets(); PhaseStatus fgInsertGCPolls(); BasicBlock* fgCreateGCPoll(GCPollType pollType, BasicBlock* block); // Requires that "block" is a block that returns from // a finally. Returns the number of successors (jump targets of // of blocks in the covered "try" that did a "LEAVE".) unsigned fgNSuccsOfFinallyRet(BasicBlock* block); // Requires that "block" is a block that returns (in the sense of BBJ_EHFINALLYRET) from // a finally. Returns its "i"th successor (jump targets of // of blocks in the covered "try" that did a "LEAVE".) // Requires that "i" < fgNSuccsOfFinallyRet(block). BasicBlock* fgSuccOfFinallyRet(BasicBlock* block, unsigned i); private: // Factor out common portions of the impls of the methods above. void fgSuccOfFinallyRetWork(BasicBlock* block, unsigned i, BasicBlock** bres, unsigned* nres); public: // For many purposes, it is desirable to be able to enumerate the *distinct* targets of a switch statement, // skipping duplicate targets. (E.g., in flow analyses that are only interested in the set of possible targets.) // SwitchUniqueSuccSet contains the non-duplicated switch targets. // (Code that modifies the jump table of a switch has an obligation to call Compiler::UpdateSwitchTableTarget, // which in turn will call the "UpdateTarget" method of this type if a SwitchUniqueSuccSet has already // been computed for the switch block. If a switch block is deleted or is transformed into a non-switch, // we leave the entry associated with the block, but it will no longer be accessed.) struct SwitchUniqueSuccSet { unsigned numDistinctSuccs; // Number of distinct targets of the switch. BasicBlock** nonDuplicates; // Array of "numDistinctSuccs", containing all the distinct switch target // successors. // The switch block "switchBlk" just had an entry with value "from" modified to the value "to". // Update "this" as necessary: if "from" is no longer an element of the jump table of "switchBlk", // remove it from "this", and ensure that "to" is a member. Use "alloc" to do any required allocation. void UpdateTarget(CompAllocator alloc, BasicBlock* switchBlk, BasicBlock* from, BasicBlock* to); }; typedef JitHashTable<BasicBlock*, JitPtrKeyFuncs<BasicBlock>, SwitchUniqueSuccSet> BlockToSwitchDescMap; private: // Maps BasicBlock*'s that end in switch statements to SwitchUniqueSuccSets that allow // iteration over only the distinct successors. BlockToSwitchDescMap* m_switchDescMap; public: BlockToSwitchDescMap* GetSwitchDescMap(bool createIfNull = true) { if ((m_switchDescMap == nullptr) && createIfNull) { m_switchDescMap = new (getAllocator()) BlockToSwitchDescMap(getAllocator()); } return m_switchDescMap; } // Invalidate the map of unique switch block successors. For example, since the hash key of the map // depends on block numbers, we must invalidate the map when the blocks are renumbered, to ensure that // we don't accidentally look up and return the wrong switch data. void InvalidateUniqueSwitchSuccMap() { m_switchDescMap = nullptr; } // Requires "switchBlock" to be a block that ends in a switch. Returns // the corresponding SwitchUniqueSuccSet. SwitchUniqueSuccSet GetDescriptorForSwitch(BasicBlock* switchBlk); // The switch block "switchBlk" just had an entry with value "from" modified to the value "to". // Update "this" as necessary: if "from" is no longer an element of the jump table of "switchBlk", // remove it from "this", and ensure that "to" is a member. void UpdateSwitchTableTarget(BasicBlock* switchBlk, BasicBlock* from, BasicBlock* to); // Remove the "SwitchUniqueSuccSet" of "switchBlk" in the BlockToSwitchDescMap. void fgInvalidateSwitchDescMapEntry(BasicBlock* switchBlk); BasicBlock* fgFirstBlockOfHandler(BasicBlock* block); bool fgIsFirstBlockOfFilterOrHandler(BasicBlock* block); flowList* fgGetPredForBlock(BasicBlock* block, BasicBlock* blockPred); flowList* fgGetPredForBlock(BasicBlock* block, BasicBlock* blockPred, flowList*** ptrToPred); flowList* fgRemoveRefPred(BasicBlock* block, BasicBlock* blockPred); flowList* fgRemoveAllRefPreds(BasicBlock* block, BasicBlock* blockPred); void fgRemoveBlockAsPred(BasicBlock* block); void fgChangeSwitchBlock(BasicBlock* oldSwitchBlock, BasicBlock* newSwitchBlock); void fgReplaceSwitchJumpTarget(BasicBlock* blockSwitch, BasicBlock* newTarget, BasicBlock* oldTarget); void fgReplaceJumpTarget(BasicBlock* block, BasicBlock* newTarget, BasicBlock* oldTarget); void fgReplacePred(BasicBlock* block, BasicBlock* oldPred, BasicBlock* newPred); flowList* fgAddRefPred(BasicBlock* block, BasicBlock* blockPred, flowList* oldEdge = nullptr, bool initializingPreds = false); // Only set to 'true' when we are computing preds in // fgComputePreds() void fgFindBasicBlocks(); bool fgIsBetterFallThrough(BasicBlock* bCur, BasicBlock* bAlt); bool fgCheckEHCanInsertAfterBlock(BasicBlock* blk, unsigned regionIndex, bool putInTryRegion); BasicBlock* fgFindInsertPoint(unsigned regionIndex, bool putInTryRegion, BasicBlock* startBlk, BasicBlock* endBlk, BasicBlock* nearBlk, BasicBlock* jumpBlk, bool runRarely); unsigned fgGetNestingLevel(BasicBlock* block, unsigned* pFinallyNesting = nullptr); void fgPostImportationCleanup(); void fgRemoveStmt(BasicBlock* block, Statement* stmt DEBUGARG(bool isUnlink = false)); void fgUnlinkStmt(BasicBlock* block, Statement* stmt); bool fgCheckRemoveStmt(BasicBlock* block, Statement* stmt); void fgCreateLoopPreHeader(unsigned lnum); void fgUnreachableBlock(BasicBlock* block); void fgRemoveConditionalJump(BasicBlock* block); BasicBlock* fgLastBBInMainFunction(); BasicBlock* fgEndBBAfterMainFunction(); void fgUnlinkRange(BasicBlock* bBeg, BasicBlock* bEnd); void fgRemoveBlock(BasicBlock* block, bool unreachable); bool fgCanCompactBlocks(BasicBlock* block, BasicBlock* bNext); void fgCompactBlocks(BasicBlock* block, BasicBlock* bNext); void fgUpdateLoopsAfterCompacting(BasicBlock* block, BasicBlock* bNext); BasicBlock* fgConnectFallThrough(BasicBlock* bSrc, BasicBlock* bDst); bool fgRenumberBlocks(); bool fgExpandRarelyRunBlocks(); bool fgEhAllowsMoveBlock(BasicBlock* bBefore, BasicBlock* bAfter); void fgMoveBlocksAfter(BasicBlock* bStart, BasicBlock* bEnd, BasicBlock* insertAfterBlk); enum FG_RELOCATE_TYPE { FG_RELOCATE_TRY, // relocate the 'try' region FG_RELOCATE_HANDLER // relocate the handler region (including the filter if necessary) }; BasicBlock* fgRelocateEHRange(unsigned regionIndex, FG_RELOCATE_TYPE relocateType); #if defined(FEATURE_EH_FUNCLETS) #if defined(TARGET_ARM) void fgClearFinallyTargetBit(BasicBlock* block); #endif // defined(TARGET_ARM) bool fgIsIntraHandlerPred(BasicBlock* predBlock, BasicBlock* block); bool fgAnyIntraHandlerPreds(BasicBlock* block); void fgInsertFuncletPrologBlock(BasicBlock* block); void fgCreateFuncletPrologBlocks(); void fgCreateFunclets(); #else // !FEATURE_EH_FUNCLETS bool fgRelocateEHRegions(); #endif // !FEATURE_EH_FUNCLETS bool fgOptimizeUncondBranchToSimpleCond(BasicBlock* block, BasicBlock* target); bool fgBlockEndFavorsTailDuplication(BasicBlock* block, unsigned lclNum); bool fgBlockIsGoodTailDuplicationCandidate(BasicBlock* block, unsigned* lclNum); bool fgOptimizeEmptyBlock(BasicBlock* block); bool fgOptimizeBranchToEmptyUnconditional(BasicBlock* block, BasicBlock* bDest); bool fgOptimizeBranch(BasicBlock* bJump); bool fgOptimizeSwitchBranches(BasicBlock* block); bool fgOptimizeBranchToNext(BasicBlock* block, BasicBlock* bNext, BasicBlock* bPrev); bool fgOptimizeSwitchJumps(); #ifdef DEBUG void fgPrintEdgeWeights(); #endif void fgComputeBlockAndEdgeWeights(); weight_t fgComputeMissingBlockWeights(); void fgComputeCalledCount(weight_t returnWeight); void fgComputeEdgeWeights(); bool fgReorderBlocks(); PhaseStatus fgDetermineFirstColdBlock(); bool fgIsForwardBranch(BasicBlock* bJump, BasicBlock* bSrc = nullptr); bool fgUpdateFlowGraph(bool doTailDup = false); void fgFindOperOrder(); // method that returns if you should split here typedef bool(fgSplitPredicate)(GenTree* tree, GenTree* parent, fgWalkData* data); void fgSetBlockOrder(); void fgRemoveReturnBlock(BasicBlock* block); /* Helper code that has been factored out */ inline void fgConvertBBToThrowBB(BasicBlock* block); bool fgCastNeeded(GenTree* tree, var_types toType); GenTree* fgDoNormalizeOnStore(GenTree* tree); GenTree* fgMakeTmpArgNode(fgArgTabEntry* curArgTabEntry); // The following check for loops that don't execute calls bool fgLoopCallMarked; void fgLoopCallTest(BasicBlock* srcBB, BasicBlock* dstBB); void fgLoopCallMark(); void fgMarkLoopHead(BasicBlock* block); unsigned fgGetCodeEstimate(BasicBlock* block); #if DUMP_FLOWGRAPHS enum class PhasePosition { PrePhase, PostPhase }; const char* fgProcessEscapes(const char* nameIn, escapeMapping_t* map); static void fgDumpTree(FILE* fgxFile, GenTree* const tree); FILE* fgOpenFlowGraphFile(bool* wbDontClose, Phases phase, PhasePosition pos, LPCWSTR type); bool fgDumpFlowGraph(Phases phase, PhasePosition pos); #endif // DUMP_FLOWGRAPHS #ifdef DEBUG void fgDispDoms(); void fgDispReach(); void fgDispBBLiveness(BasicBlock* block); void fgDispBBLiveness(); void fgTableDispBasicBlock(BasicBlock* block, int ibcColWidth = 0); void fgDispBasicBlocks(BasicBlock* firstBlock, BasicBlock* lastBlock, bool dumpTrees); void fgDispBasicBlocks(bool dumpTrees = false); void fgDumpStmtTree(Statement* stmt, unsigned bbNum); void fgDumpBlock(BasicBlock* block); void fgDumpTrees(BasicBlock* firstBlock, BasicBlock* lastBlock); static fgWalkPreFn fgStress64RsltMulCB; void fgStress64RsltMul(); void fgDebugCheckUpdate(); void fgDebugCheckBBNumIncreasing(); void fgDebugCheckBBlist(bool checkBBNum = false, bool checkBBRefs = true); void fgDebugCheckBlockLinks(); void fgDebugCheckLinks(bool morphTrees = false); void fgDebugCheckStmtsList(BasicBlock* block, bool morphTrees); void fgDebugCheckNodeLinks(BasicBlock* block, Statement* stmt); void fgDebugCheckNodesUniqueness(); void fgDebugCheckLoopTable(); void fgDebugCheckFlags(GenTree* tree); void fgDebugCheckDispFlags(GenTree* tree, GenTreeFlags dispFlags, GenTreeDebugFlags debugFlags); void fgDebugCheckFlagsHelper(GenTree* tree, GenTreeFlags actualFlags, GenTreeFlags expectedFlags); void fgDebugCheckTryFinallyExits(); void fgDebugCheckProfileData(); bool fgDebugCheckIncomingProfileData(BasicBlock* block); bool fgDebugCheckOutgoingProfileData(BasicBlock* block); #endif // DEBUG static bool fgProfileWeightsEqual(weight_t weight1, weight_t weight2); static bool fgProfileWeightsConsistent(weight_t weight1, weight_t weight2); static GenTree* fgGetFirstNode(GenTree* tree); //--------------------- Walking the trees in the IR ----------------------- struct fgWalkData { Compiler* compiler; fgWalkPreFn* wtprVisitorFn; fgWalkPostFn* wtpoVisitorFn; void* pCallbackData; // user-provided data GenTree* parent; // parent of current node, provided to callback GenTreeStack* parentStack; // stack of parent nodes, if asked for bool wtprLclsOnly; // whether to only visit lclvar nodes #ifdef DEBUG bool printModified; // callback can use this #endif }; fgWalkResult fgWalkTreePre(GenTree** pTree, fgWalkPreFn* visitor, void* pCallBackData = nullptr, bool lclVarsOnly = false, bool computeStack = false); fgWalkResult fgWalkTree(GenTree** pTree, fgWalkPreFn* preVisitor, fgWalkPostFn* postVisitor, void* pCallBackData = nullptr); void fgWalkAllTreesPre(fgWalkPreFn* visitor, void* pCallBackData); //----- Postorder fgWalkResult fgWalkTreePost(GenTree** pTree, fgWalkPostFn* visitor, void* pCallBackData = nullptr, bool computeStack = false); // An fgWalkPreFn that looks for expressions that have inline throws in // minopts mode. Basically it looks for tress with gtOverflowEx() or // GTF_IND_RNGCHK. It returns WALK_ABORT if one is found. It // returns WALK_SKIP_SUBTREES if GTF_EXCEPT is not set (assumes flags // properly propagated to parent trees). It returns WALK_CONTINUE // otherwise. static fgWalkResult fgChkThrowCB(GenTree** pTree, Compiler::fgWalkData* data); static fgWalkResult fgChkLocAllocCB(GenTree** pTree, Compiler::fgWalkData* data); static fgWalkResult fgChkQmarkCB(GenTree** pTree, Compiler::fgWalkData* data); /************************************************************************** * PROTECTED *************************************************************************/ protected: friend class SsaBuilder; friend struct ValueNumberState; //--------------------- Detect the basic blocks --------------------------- BasicBlock** fgBBs; // Table of pointers to the BBs void fgInitBBLookup(); BasicBlock* fgLookupBB(unsigned addr); bool fgCanSwitchToOptimized(); void fgSwitchToOptimized(const char* reason); bool fgMayExplicitTailCall(); void fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, FixedBitVect* jumpTarget); void fgMarkBackwardJump(BasicBlock* startBlock, BasicBlock* endBlock); void fgLinkBasicBlocks(); unsigned fgMakeBasicBlocks(const BYTE* codeAddr, IL_OFFSET codeSize, FixedBitVect* jumpTarget); void fgCheckBasicBlockControlFlow(); void fgControlFlowPermitted(BasicBlock* blkSrc, BasicBlock* blkDest, bool IsLeave = false /* is the src a leave block */); bool fgFlowToFirstBlockOfInnerTry(BasicBlock* blkSrc, BasicBlock* blkDest, bool sibling); void fgObserveInlineConstants(OPCODE opcode, const FgStack& stack, bool isInlining); void fgAdjustForAddressExposedOrWrittenThis(); unsigned fgStressBBProf() { #ifdef DEBUG unsigned result = JitConfig.JitStressBBProf(); if (result == 0) { if (compStressCompile(STRESS_BB_PROFILE, 15)) { result = 1; } } return result; #else return 0; #endif } bool fgHaveProfileData(); bool fgGetProfileWeightForBasicBlock(IL_OFFSET offset, weight_t* weight); Instrumentor* fgCountInstrumentor; Instrumentor* fgClassInstrumentor; PhaseStatus fgPrepareToInstrumentMethod(); PhaseStatus fgInstrumentMethod(); PhaseStatus fgIncorporateProfileData(); void fgIncorporateBlockCounts(); void fgIncorporateEdgeCounts(); CORINFO_CLASS_HANDLE getRandomClass(ICorJitInfo::PgoInstrumentationSchema* schema, UINT32 countSchemaItems, BYTE* pInstrumentationData, int32_t ilOffset, CLRRandom* random); public: const char* fgPgoFailReason; bool fgPgoDisabled; ICorJitInfo::PgoSource fgPgoSource; ICorJitInfo::PgoInstrumentationSchema* fgPgoSchema; BYTE* fgPgoData; UINT32 fgPgoSchemaCount; HRESULT fgPgoQueryResult; UINT32 fgNumProfileRuns; UINT32 fgPgoBlockCounts; UINT32 fgPgoEdgeCounts; UINT32 fgPgoClassProfiles; unsigned fgPgoInlineePgo; unsigned fgPgoInlineeNoPgo; unsigned fgPgoInlineeNoPgoSingleBlock; void WalkSpanningTree(SpanningTreeVisitor* visitor); void fgSetProfileWeight(BasicBlock* block, weight_t weight); void fgApplyProfileScale(); bool fgHaveSufficientProfileData(); bool fgHaveTrustedProfileData(); // fgIsUsingProfileWeights - returns true if we have real profile data for this method // or if we have some fake profile data for the stress mode bool fgIsUsingProfileWeights() { return (fgHaveProfileData() || fgStressBBProf()); } // fgProfileRunsCount - returns total number of scenario runs for the profile data // or BB_UNITY_WEIGHT_UNSIGNED when we aren't using profile data. unsigned fgProfileRunsCount() { return fgIsUsingProfileWeights() ? fgNumProfileRuns : BB_UNITY_WEIGHT_UNSIGNED; } //-------- Insert a statement at the start or end of a basic block -------- #ifdef DEBUG public: static bool fgBlockContainsStatementBounded(BasicBlock* block, Statement* stmt, bool answerOnBoundExceeded = true); #endif public: Statement* fgNewStmtAtBeg(BasicBlock* block, GenTree* tree, const DebugInfo& di = DebugInfo()); void fgInsertStmtAtEnd(BasicBlock* block, Statement* stmt); Statement* fgNewStmtAtEnd(BasicBlock* block, GenTree* tree, const DebugInfo& di = DebugInfo()); Statement* fgNewStmtNearEnd(BasicBlock* block, GenTree* tree, const DebugInfo& di = DebugInfo()); private: void fgInsertStmtNearEnd(BasicBlock* block, Statement* stmt); void fgInsertStmtAtBeg(BasicBlock* block, Statement* stmt); void fgInsertStmtAfter(BasicBlock* block, Statement* insertionPoint, Statement* stmt); public: void fgInsertStmtBefore(BasicBlock* block, Statement* insertionPoint, Statement* stmt); private: Statement* fgInsertStmtListAfter(BasicBlock* block, Statement* stmtAfter, Statement* stmtList); // Create a new temporary variable to hold the result of *ppTree, // and transform the graph accordingly. GenTree* fgInsertCommaFormTemp(GenTree** ppTree, CORINFO_CLASS_HANDLE structType = nullptr); GenTree* fgMakeMultiUse(GenTree** ppTree); private: // Recognize a bitwise rotation pattern and convert into a GT_ROL or a GT_ROR node. GenTree* fgRecognizeAndMorphBitwiseRotation(GenTree* tree); bool fgOperIsBitwiseRotationRoot(genTreeOps oper); #if !defined(TARGET_64BIT) // Recognize and morph a long multiplication with 32 bit operands. GenTreeOp* fgRecognizeAndMorphLongMul(GenTreeOp* mul); GenTreeOp* fgMorphLongMul(GenTreeOp* mul); #endif //-------- Determine the order in which the trees will be evaluated ------- unsigned fgTreeSeqNum; GenTree* fgTreeSeqLst; GenTree* fgTreeSeqBeg; GenTree* fgSetTreeSeq(GenTree* tree, GenTree* prev = nullptr, bool isLIR = false); void fgSetTreeSeqHelper(GenTree* tree, bool isLIR); void fgSetTreeSeqFinish(GenTree* tree, bool isLIR); void fgSetStmtSeq(Statement* stmt); void fgSetBlockOrder(BasicBlock* block); //------------------------- Morphing -------------------------------------- unsigned fgPtrArgCntMax; public: //------------------------------------------------------------------------ // fgGetPtrArgCntMax: Return the maximum number of pointer-sized stack arguments that calls inside this method // can push on the stack. This value is calculated during morph. // // Return Value: // Returns fgPtrArgCntMax, that is a private field. // unsigned fgGetPtrArgCntMax() const { return fgPtrArgCntMax; } //------------------------------------------------------------------------ // fgSetPtrArgCntMax: Set the maximum number of pointer-sized stack arguments that calls inside this method // can push on the stack. This function is used during StackLevelSetter to fix incorrect morph calculations. // void fgSetPtrArgCntMax(unsigned argCntMax) { fgPtrArgCntMax = argCntMax; } bool compCanEncodePtrArgCntMax(); private: hashBv* fgOutgoingArgTemps; hashBv* fgCurrentlyInUseArgTemps; void fgSetRngChkTarget(GenTree* tree, bool delay = true); BasicBlock* fgSetRngChkTargetInner(SpecialCodeKind kind, bool delay); #if REARRANGE_ADDS void fgMoveOpsLeft(GenTree* tree); #endif bool fgIsCommaThrow(GenTree* tree, bool forFolding = false); bool fgIsThrow(GenTree* tree); bool fgInDifferentRegions(BasicBlock* blk1, BasicBlock* blk2); bool fgIsBlockCold(BasicBlock* block); GenTree* fgMorphCastIntoHelper(GenTree* tree, int helper, GenTree* oper); GenTree* fgMorphIntoHelperCall(GenTree* tree, int helper, GenTreeCall::Use* args, bool morphArgs = true); GenTree* fgMorphStackArgForVarArgs(unsigned lclNum, var_types varType, unsigned lclOffs); // A "MorphAddrContext" carries information from the surrounding context. If we are evaluating a byref address, // it is useful to know whether the address will be immediately dereferenced, or whether the address value will // be used, perhaps by passing it as an argument to a called method. This affects how null checking is done: // for sufficiently small offsets, we can rely on OS page protection to implicitly null-check addresses that we // know will be dereferenced. To know that reliance on implicit null checking is sound, we must further know that // all offsets between the top-level indirection and the bottom are constant, and that their sum is sufficiently // small; hence the other fields of MorphAddrContext. enum MorphAddrContextKind { MACK_Ind, MACK_Addr, }; struct MorphAddrContext { MorphAddrContextKind m_kind; bool m_allConstantOffsets; // Valid only for "m_kind == MACK_Ind". True iff all offsets between // top-level indirection and here have been constants. size_t m_totalOffset; // Valid only for "m_kind == MACK_Ind", and if "m_allConstantOffsets" is true. // In that case, is the sum of those constant offsets. MorphAddrContext(MorphAddrContextKind kind) : m_kind(kind), m_allConstantOffsets(true), m_totalOffset(0) { } }; // A MACK_CopyBlock context is immutable, so we can just make one of these and share it. static MorphAddrContext s_CopyBlockMAC; #ifdef FEATURE_SIMD GenTree* getSIMDStructFromField(GenTree* tree, CorInfoType* simdBaseJitTypeOut, unsigned* indexOut, unsigned* simdSizeOut, bool ignoreUsedInSIMDIntrinsic = false); GenTree* fgMorphFieldAssignToSimdSetElement(GenTree* tree); GenTree* fgMorphFieldToSimdGetElement(GenTree* tree); bool fgMorphCombineSIMDFieldAssignments(BasicBlock* block, Statement* stmt); void impMarkContiguousSIMDFieldAssignments(Statement* stmt); // fgPreviousCandidateSIMDFieldAsgStmt is only used for tracking previous simd field assignment // in function: Complier::impMarkContiguousSIMDFieldAssignments. Statement* fgPreviousCandidateSIMDFieldAsgStmt; #endif // FEATURE_SIMD GenTree* fgMorphArrayIndex(GenTree* tree); GenTree* fgMorphExpandCast(GenTreeCast* tree); GenTreeFieldList* fgMorphLclArgToFieldlist(GenTreeLclVarCommon* lcl); void fgInitArgInfo(GenTreeCall* call); GenTreeCall* fgMorphArgs(GenTreeCall* call); void fgMakeOutgoingStructArgCopy(GenTreeCall* call, GenTreeCall::Use* args, CORINFO_CLASS_HANDLE copyBlkClass); GenTree* fgMorphLocalVar(GenTree* tree, bool forceRemorph); public: bool fgAddrCouldBeNull(GenTree* addr); private: GenTree* fgMorphField(GenTree* tree, MorphAddrContext* mac); bool fgCanFastTailCall(GenTreeCall* call, const char** failReason); #if FEATURE_FASTTAILCALL bool fgCallHasMustCopyByrefParameter(GenTreeCall* callee); #endif bool fgCheckStmtAfterTailCall(); GenTree* fgMorphTailCallViaHelpers(GenTreeCall* call, CORINFO_TAILCALL_HELPERS& help); bool fgCanTailCallViaJitHelper(); void fgMorphTailCallViaJitHelper(GenTreeCall* call); GenTree* fgCreateCallDispatcherAndGetResult(GenTreeCall* origCall, CORINFO_METHOD_HANDLE callTargetStubHnd, CORINFO_METHOD_HANDLE dispatcherHnd); GenTree* getLookupTree(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_LOOKUP* pLookup, GenTreeFlags handleFlags, void* compileTimeHandle); GenTree* getRuntimeLookupTree(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_LOOKUP* pLookup, void* compileTimeHandle); GenTree* getVirtMethodPointerTree(GenTree* thisPtr, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_CALL_INFO* pCallInfo); GenTree* getTokenHandleTree(CORINFO_RESOLVED_TOKEN* pResolvedToken, bool parent); GenTree* fgMorphPotentialTailCall(GenTreeCall* call); GenTree* fgGetStubAddrArg(GenTreeCall* call); unsigned fgGetArgTabEntryParameterLclNum(GenTreeCall* call, fgArgTabEntry* argTabEntry); void fgMorphRecursiveFastTailCallIntoLoop(BasicBlock* block, GenTreeCall* recursiveTailCall); Statement* fgAssignRecursiveCallArgToCallerParam(GenTree* arg, fgArgTabEntry* argTabEntry, unsigned lclParamNum, BasicBlock* block, const DebugInfo& callDI, Statement* tmpAssignmentInsertionPoint, Statement* paramAssignmentInsertionPoint); GenTree* fgMorphCall(GenTreeCall* call); GenTree* fgExpandVirtualVtableCallTarget(GenTreeCall* call); void fgMorphCallInline(GenTreeCall* call, InlineResult* result); void fgMorphCallInlineHelper(GenTreeCall* call, InlineResult* result, InlineContext** createdContext); #if DEBUG void fgNoteNonInlineCandidate(Statement* stmt, GenTreeCall* call); static fgWalkPreFn fgFindNonInlineCandidate; #endif GenTree* fgOptimizeDelegateConstructor(GenTreeCall* call, CORINFO_CONTEXT_HANDLE* ExactContextHnd, CORINFO_RESOLVED_TOKEN* ldftnToken); GenTree* fgMorphLeaf(GenTree* tree); void fgAssignSetVarDef(GenTree* tree); GenTree* fgMorphOneAsgBlockOp(GenTree* tree); GenTree* fgMorphInitBlock(GenTree* tree); GenTree* fgMorphPromoteLocalInitBlock(GenTreeLclVar* destLclNode, GenTree* initVal, unsigned blockSize); GenTree* fgMorphGetStructAddr(GenTree** pTree, CORINFO_CLASS_HANDLE clsHnd, bool isRValue = false); GenTree* fgMorphBlockOperand(GenTree* tree, var_types asgType, unsigned blockWidth, bool isBlkReqd); GenTree* fgMorphCopyBlock(GenTree* tree); GenTree* fgMorphStoreDynBlock(GenTreeStoreDynBlk* tree); GenTree* fgMorphForRegisterFP(GenTree* tree); GenTree* fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac = nullptr); GenTree* fgOptimizeCast(GenTreeCast* cast); GenTree* fgOptimizeEqualityComparisonWithConst(GenTreeOp* cmp); GenTree* fgOptimizeRelationalComparisonWithConst(GenTreeOp* cmp); #ifdef FEATURE_HW_INTRINSICS GenTree* fgOptimizeHWIntrinsic(GenTreeHWIntrinsic* node); #endif GenTree* fgOptimizeCommutativeArithmetic(GenTreeOp* tree); GenTree* fgOptimizeRelationalComparisonWithCasts(GenTreeOp* cmp); GenTree* fgOptimizeAddition(GenTreeOp* add); GenTree* fgOptimizeMultiply(GenTreeOp* mul); GenTree* fgOptimizeBitwiseAnd(GenTreeOp* andOp); GenTree* fgPropagateCommaThrow(GenTree* parent, GenTreeOp* commaThrow, GenTreeFlags precedingSideEffects); GenTree* fgMorphRetInd(GenTreeUnOp* tree); GenTree* fgMorphModToSubMulDiv(GenTreeOp* tree); GenTree* fgMorphSmpOpOptional(GenTreeOp* tree); GenTree* fgMorphMultiOp(GenTreeMultiOp* multiOp); GenTree* fgMorphConst(GenTree* tree); bool fgMorphCanUseLclFldForCopy(unsigned lclNum1, unsigned lclNum2); GenTreeLclVar* fgMorphTryFoldObjAsLclVar(GenTreeObj* obj, bool destroyNodes = true); GenTreeOp* fgMorphCommutative(GenTreeOp* tree); GenTree* fgMorphCastedBitwiseOp(GenTreeOp* tree); GenTree* fgMorphReduceAddOps(GenTree* tree); public: GenTree* fgMorphTree(GenTree* tree, MorphAddrContext* mac = nullptr); private: void fgKillDependentAssertionsSingle(unsigned lclNum DEBUGARG(GenTree* tree)); void fgKillDependentAssertions(unsigned lclNum DEBUGARG(GenTree* tree)); void fgMorphTreeDone(GenTree* tree, GenTree* oldTree = nullptr DEBUGARG(int morphNum = 0)); Statement* fgMorphStmt; unsigned fgGetBigOffsetMorphingTemp(var_types type); // We cache one temp per type to be // used when morphing big offset. //----------------------- Liveness analysis ------------------------------- VARSET_TP fgCurUseSet; // vars used by block (before an assignment) VARSET_TP fgCurDefSet; // vars assigned by block (before a use) MemoryKindSet fgCurMemoryUse; // True iff the current basic block uses memory. MemoryKindSet fgCurMemoryDef; // True iff the current basic block modifies memory. MemoryKindSet fgCurMemoryHavoc; // True if the current basic block is known to set memory to a "havoc" value. bool byrefStatesMatchGcHeapStates; // True iff GcHeap and ByrefExposed memory have all the same def points. void fgMarkUseDef(GenTreeLclVarCommon* tree); void fgBeginScopeLife(VARSET_TP* inScope, VarScopeDsc* var); void fgEndScopeLife(VARSET_TP* inScope, VarScopeDsc* var); void fgMarkInScope(BasicBlock* block, VARSET_VALARG_TP inScope); void fgUnmarkInScope(BasicBlock* block, VARSET_VALARG_TP unmarkScope); void fgExtendDbgScopes(); void fgExtendDbgLifetimes(); #ifdef DEBUG void fgDispDebugScopes(); #endif // DEBUG //------------------------------------------------------------------------- // // The following keeps track of any code we've added for things like array // range checking or explicit calls to enable GC, and so on. // public: struct AddCodeDsc { AddCodeDsc* acdNext; BasicBlock* acdDstBlk; // block to which we jump unsigned acdData; SpecialCodeKind acdKind; // what kind of a special block is this? #if !FEATURE_FIXED_OUT_ARGS bool acdStkLvlInit; // has acdStkLvl value been already set? unsigned acdStkLvl; // stack level in stack slots. #endif // !FEATURE_FIXED_OUT_ARGS }; private: static unsigned acdHelper(SpecialCodeKind codeKind); AddCodeDsc* fgAddCodeList; bool fgAddCodeModf; bool fgRngChkThrowAdded; AddCodeDsc* fgExcptnTargetCache[SCK_COUNT]; BasicBlock* fgRngChkTarget(BasicBlock* block, SpecialCodeKind kind); BasicBlock* fgAddCodeRef(BasicBlock* srcBlk, unsigned refData, SpecialCodeKind kind); public: AddCodeDsc* fgFindExcptnTarget(SpecialCodeKind kind, unsigned refData); bool fgUseThrowHelperBlocks(); AddCodeDsc* fgGetAdditionalCodeDescriptors() { return fgAddCodeList; } private: bool fgIsCodeAdded(); bool fgIsThrowHlpBlk(BasicBlock* block); #if !FEATURE_FIXED_OUT_ARGS unsigned fgThrowHlpBlkStkLevel(BasicBlock* block); #endif // !FEATURE_FIXED_OUT_ARGS unsigned fgBigOffsetMorphingTemps[TYP_COUNT]; unsigned fgCheckInlineDepthAndRecursion(InlineInfo* inlineInfo); void fgInvokeInlineeCompiler(GenTreeCall* call, InlineResult* result, InlineContext** createdContext); void fgInsertInlineeBlocks(InlineInfo* pInlineInfo); Statement* fgInlinePrependStatements(InlineInfo* inlineInfo); void fgInlineAppendStatements(InlineInfo* inlineInfo, BasicBlock* block, Statement* stmt); #if FEATURE_MULTIREG_RET GenTree* fgGetStructAsStructPtr(GenTree* tree); GenTree* fgAssignStructInlineeToVar(GenTree* child, CORINFO_CLASS_HANDLE retClsHnd); void fgAttachStructInlineeToAsg(GenTree* tree, GenTree* child, CORINFO_CLASS_HANDLE retClsHnd); #endif // FEATURE_MULTIREG_RET static fgWalkPreFn fgUpdateInlineReturnExpressionPlaceHolder; static fgWalkPostFn fgLateDevirtualization; #ifdef DEBUG static fgWalkPreFn fgDebugCheckInlineCandidates; void CheckNoTransformableIndirectCallsRemain(); static fgWalkPreFn fgDebugCheckForTransformableIndirectCalls; #endif void fgPromoteStructs(); void fgMorphStructField(GenTree* tree, GenTree* parent); void fgMorphLocalField(GenTree* tree, GenTree* parent); // Reset the refCount for implicit byrefs. void fgResetImplicitByRefRefCount(); // Change implicit byrefs' types from struct to pointer, and for any that were // promoted, create new promoted struct temps. void fgRetypeImplicitByRefArgs(); // Rewrite appearances of implicit byrefs (manifest the implied additional level of indirection). bool fgMorphImplicitByRefArgs(GenTree* tree); GenTree* fgMorphImplicitByRefArgs(GenTree* tree, bool isAddr); // Clear up annotations for any struct promotion temps created for implicit byrefs. void fgMarkDemotedImplicitByRefArgs(); void fgMarkAddressExposedLocals(); void fgMarkAddressExposedLocals(Statement* stmt); PhaseStatus fgForwardSub(); bool fgForwardSubBlock(BasicBlock* block); bool fgForwardSubStatement(Statement* statement); static fgWalkPreFn fgUpdateSideEffectsPre; static fgWalkPostFn fgUpdateSideEffectsPost; // The given local variable, required to be a struct variable, is being assigned via // a "lclField", to make it masquerade as an integral type in the ABI. Make sure that // the variable is not enregistered, and is therefore not promoted independently. void fgLclFldAssign(unsigned lclNum); static fgWalkPreFn gtHasLocalsWithAddrOpCB; enum TypeProducerKind { TPK_Unknown = 0, // May not be a RuntimeType TPK_Handle = 1, // RuntimeType via handle TPK_GetType = 2, // RuntimeType via Object.get_Type() TPK_Null = 3, // Tree value is null TPK_Other = 4 // RuntimeType via other means }; TypeProducerKind gtGetTypeProducerKind(GenTree* tree); bool gtIsTypeHandleToRuntimeTypeHelper(GenTreeCall* call); bool gtIsTypeHandleToRuntimeTypeHandleHelper(GenTreeCall* call, CorInfoHelpFunc* pHelper = nullptr); bool gtIsActiveCSE_Candidate(GenTree* tree); bool fgIsBigOffset(size_t offset); bool fgNeedReturnSpillTemp(); /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX Optimizer XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ public: void optInit(); GenTree* optRemoveRangeCheck(GenTreeBoundsChk* check, GenTree* comma, Statement* stmt); GenTree* optRemoveStandaloneRangeCheck(GenTreeBoundsChk* check, Statement* stmt); void optRemoveCommaBasedRangeCheck(GenTree* comma, Statement* stmt); protected: // Do hoisting for all loops. void optHoistLoopCode(); // To represent sets of VN's that have already been hoisted in outer loops. typedef JitHashTable<ValueNum, JitSmallPrimitiveKeyFuncs<ValueNum>, bool> VNSet; struct LoopHoistContext { private: // The set of variables hoisted in the current loop (or nullptr if there are none). VNSet* m_pHoistedInCurLoop; public: // Value numbers of expressions that have been hoisted in parent loops in the loop nest. VNSet m_hoistedInParentLoops; // Value numbers of expressions that have been hoisted in the current (or most recent) loop in the nest. // Previous decisions on loop-invariance of value numbers in the current loop. VNSet m_curLoopVnInvariantCache; VNSet* GetHoistedInCurLoop(Compiler* comp) { if (m_pHoistedInCurLoop == nullptr) { m_pHoistedInCurLoop = new (comp->getAllocatorLoopHoist()) VNSet(comp->getAllocatorLoopHoist()); } return m_pHoistedInCurLoop; } VNSet* ExtractHoistedInCurLoop() { VNSet* res = m_pHoistedInCurLoop; m_pHoistedInCurLoop = nullptr; return res; } LoopHoistContext(Compiler* comp) : m_pHoistedInCurLoop(nullptr) , m_hoistedInParentLoops(comp->getAllocatorLoopHoist()) , m_curLoopVnInvariantCache(comp->getAllocatorLoopHoist()) { } }; // Do hoisting for loop "lnum" (an index into the optLoopTable), and all loops nested within it. // Tracks the expressions that have been hoisted by containing loops by temporarily recording their // value numbers in "m_hoistedInParentLoops". This set is not modified by the call. void optHoistLoopNest(unsigned lnum, LoopHoistContext* hoistCtxt); // Do hoisting for a particular loop ("lnum" is an index into the optLoopTable.) // Assumes that expressions have been hoisted in containing loops if their value numbers are in // "m_hoistedInParentLoops". // void optHoistThisLoop(unsigned lnum, LoopHoistContext* hoistCtxt); // Hoist all expressions in "blocks" that are invariant in loop "loopNum" (an index into the optLoopTable) // outside of that loop. Exempt expressions whose value number is in "m_hoistedInParentLoops"; add VN's of hoisted // expressions to "hoistInLoop". void optHoistLoopBlocks(unsigned loopNum, ArrayStack<BasicBlock*>* blocks, LoopHoistContext* hoistContext); // Return true if the tree looks profitable to hoist out of loop 'lnum'. bool optIsProfitableToHoistTree(GenTree* tree, unsigned lnum); // Performs the hoisting 'tree' into the PreHeader for loop 'lnum' void optHoistCandidate(GenTree* tree, BasicBlock* treeBb, unsigned lnum, LoopHoistContext* hoistCtxt); // Returns true iff the ValueNum "vn" represents a value that is loop-invariant in "lnum". // Constants and init values are always loop invariant. // VNPhi's connect VN's to the SSA definition, so we can know if the SSA def occurs in the loop. bool optVNIsLoopInvariant(ValueNum vn, unsigned lnum, VNSet* recordedVNs); // If "blk" is the entry block of a natural loop, returns true and sets "*pLnum" to the index of the loop // in the loop table. bool optBlockIsLoopEntry(BasicBlock* blk, unsigned* pLnum); // Records the set of "side effects" of all loops: fields (object instance and static) // written to, and SZ-array element type equivalence classes updated. void optComputeLoopSideEffects(); #ifdef DEBUG bool optAnyChildNotRemoved(unsigned loopNum); #endif // DEBUG // Mark a loop as removed. void optMarkLoopRemoved(unsigned loopNum); private: // Requires "lnum" to be the index of an outermost loop in the loop table. Traverses the body of that loop, // including all nested loops, and records the set of "side effects" of the loop: fields (object instance and // static) written to, and SZ-array element type equivalence classes updated. void optComputeLoopNestSideEffects(unsigned lnum); // Given a loop number 'lnum' mark it and any nested loops as having 'memoryHavoc' void optRecordLoopNestsMemoryHavoc(unsigned lnum, MemoryKindSet memoryHavoc); // Add the side effects of "blk" (which is required to be within a loop) to all loops of which it is a part. // Returns false if we encounter a block that is not marked as being inside a loop. // bool optComputeLoopSideEffectsOfBlock(BasicBlock* blk); // Hoist the expression "expr" out of loop "lnum". void optPerformHoistExpr(GenTree* expr, BasicBlock* exprBb, unsigned lnum); public: void optOptimizeBools(); public: PhaseStatus optInvertLoops(); // Invert loops so they're entered at top and tested at bottom. PhaseStatus optOptimizeLayout(); // Optimize the BasicBlock layout of the method PhaseStatus optSetBlockWeights(); PhaseStatus optFindLoopsPhase(); // Finds loops and records them in the loop table void optFindLoops(); PhaseStatus optCloneLoops(); void optCloneLoop(unsigned loopInd, LoopCloneContext* context); void optEnsureUniqueHead(unsigned loopInd, weight_t ambientWeight); PhaseStatus optUnrollLoops(); // Unrolls loops (needs to have cost info) void optRemoveRedundantZeroInits(); protected: // This enumeration describes what is killed by a call. enum callInterf { CALLINT_NONE, // no interference (most helpers) CALLINT_REF_INDIRS, // kills GC ref indirections (SETFIELD OBJ) CALLINT_SCL_INDIRS, // kills non GC ref indirections (SETFIELD non-OBJ) CALLINT_ALL_INDIRS, // kills both GC ref and non GC ref indirections (SETFIELD STRUCT) CALLINT_ALL, // kills everything (normal method call) }; enum class FieldKindForVN { SimpleStatic, WithBaseAddr }; public: // A "LoopDsc" describes a ("natural") loop. We (currently) require the body of a loop to be a contiguous (in // bbNext order) sequence of basic blocks. (At times, we may require the blocks in a loop to be "properly numbered" // in bbNext order; we use comparisons on the bbNum to decide order.) // The blocks that define the body are // top <= entry <= bottom // The "head" of the loop is a block outside the loop that has "entry" as a successor. We only support loops with a // single 'head' block. The meanings of these blocks are given in the definitions below. Also see the picture at // Compiler::optFindNaturalLoops(). struct LoopDsc { BasicBlock* lpHead; // HEAD of the loop (not part of the looping of the loop) -- has ENTRY as a successor. BasicBlock* lpTop; // loop TOP (the back edge from lpBottom reaches here). Lexically first block (in bbNext // order) reachable in this loop. BasicBlock* lpEntry; // the ENTRY in the loop (in most cases TOP or BOTTOM) BasicBlock* lpBottom; // loop BOTTOM (from here we have a back edge to the TOP) BasicBlock* lpExit; // if a single exit loop this is the EXIT (in most cases BOTTOM) callInterf lpAsgCall; // "callInterf" for calls in the loop ALLVARSET_TP lpAsgVars; // set of vars assigned within the loop (all vars, not just tracked) varRefKinds lpAsgInds : 8; // set of inds modified within the loop LoopFlags lpFlags; unsigned char lpExitCnt; // number of exits from the loop unsigned char lpParent; // The index of the most-nested loop that completely contains this one, // or else BasicBlock::NOT_IN_LOOP if no such loop exists. unsigned char lpChild; // The index of a nested loop, or else BasicBlock::NOT_IN_LOOP if no child exists. // (Actually, an "immediately" nested loop -- // no other child of this loop is a parent of lpChild.) unsigned char lpSibling; // The index of another loop that is an immediate child of lpParent, // or else BasicBlock::NOT_IN_LOOP. One can enumerate all the children of a loop // by following "lpChild" then "lpSibling" links. bool lpLoopHasMemoryHavoc[MemoryKindCount]; // The loop contains an operation that we assume has arbitrary // memory side effects. If this is set, the fields below // may not be accurate (since they become irrelevant.) VARSET_TP lpVarInOut; // The set of variables that are IN or OUT during the execution of this loop VARSET_TP lpVarUseDef; // The set of variables that are USE or DEF during the execution of this loop // The following counts are used for hoisting profitability checks. int lpHoistedExprCount; // The register count for the non-FP expressions from inside this loop that have been // hoisted int lpLoopVarCount; // The register count for the non-FP LclVars that are read/written inside this loop int lpVarInOutCount; // The register count for the non-FP LclVars that are alive inside or across this loop int lpHoistedFPExprCount; // The register count for the FP expressions from inside this loop that have been // hoisted int lpLoopVarFPCount; // The register count for the FP LclVars that are read/written inside this loop int lpVarInOutFPCount; // The register count for the FP LclVars that are alive inside or across this loop typedef JitHashTable<CORINFO_FIELD_HANDLE, JitPtrKeyFuncs<struct CORINFO_FIELD_STRUCT_>, FieldKindForVN> FieldHandleSet; FieldHandleSet* lpFieldsModified; // This has entries for all static field and object instance fields modified // in the loop. typedef JitHashTable<CORINFO_CLASS_HANDLE, JitPtrKeyFuncs<struct CORINFO_CLASS_STRUCT_>, bool> ClassHandleSet; ClassHandleSet* lpArrayElemTypesModified; // Bits set indicate the set of sz array element types such that // arrays of that type are modified // in the loop. // Adds the variable liveness information for 'blk' to 'this' LoopDsc void AddVariableLiveness(Compiler* comp, BasicBlock* blk); inline void AddModifiedField(Compiler* comp, CORINFO_FIELD_HANDLE fldHnd, FieldKindForVN fieldKind); // This doesn't *always* take a class handle -- it can also take primitive types, encoded as class handles // (shifted left, with a low-order bit set to distinguish.) // Use the {Encode/Decode}ElemType methods to construct/destruct these. inline void AddModifiedElemType(Compiler* comp, CORINFO_CLASS_HANDLE structHnd); /* The following values are set only for iterator loops, i.e. has the flag LPFLG_ITER set */ GenTree* lpIterTree; // The "i = i <op> const" tree unsigned lpIterVar() const; // iterator variable # int lpIterConst() const; // the constant with which the iterator is incremented genTreeOps lpIterOper() const; // the type of the operation on the iterator (ASG_ADD, ASG_SUB, etc.) void VERIFY_lpIterTree() const; var_types lpIterOperType() const; // For overflow instructions // Set to the block where we found the initialization for LPFLG_CONST_INIT or LPFLG_VAR_INIT loops. // Initially, this will be 'head', but 'head' might change if we insert a loop pre-header block. BasicBlock* lpInitBlock; union { int lpConstInit; // initial constant value of iterator // : Valid if LPFLG_CONST_INIT unsigned lpVarInit; // initial local var number to which we initialize the iterator // : Valid if LPFLG_VAR_INIT }; // The following is for LPFLG_ITER loops only (i.e. the loop condition is "i RELOP const or var") GenTree* lpTestTree; // pointer to the node containing the loop test genTreeOps lpTestOper() const; // the type of the comparison between the iterator and the limit (GT_LE, GT_GE, // etc.) void VERIFY_lpTestTree() const; bool lpIsReversed() const; // true if the iterator node is the second operand in the loop condition GenTree* lpIterator() const; // the iterator node in the loop test GenTree* lpLimit() const; // the limit node in the loop test // Limit constant value of iterator - loop condition is "i RELOP const" // : Valid if LPFLG_CONST_LIMIT int lpConstLimit() const; // The lclVar # in the loop condition ( "i RELOP lclVar" ) // : Valid if LPFLG_VAR_LIMIT unsigned lpVarLimit() const; // The array length in the loop condition ( "i RELOP arr.len" or "i RELOP arr[i][j].len" ) // : Valid if LPFLG_ARRLEN_LIMIT bool lpArrLenLimit(Compiler* comp, ArrIndex* index) const; // Returns "true" iff this is a "top entry" loop. bool lpIsTopEntry() const { if (lpHead->bbNext == lpEntry) { assert(lpHead->bbFallsThrough()); assert(lpTop == lpEntry); return true; } else { return false; } } // Returns "true" iff "*this" contains the blk. bool lpContains(BasicBlock* blk) const { return lpTop->bbNum <= blk->bbNum && blk->bbNum <= lpBottom->bbNum; } // Returns "true" iff "*this" (properly) contains the range [top, bottom] (allowing tops // to be equal, but requiring bottoms to be different.) bool lpContains(BasicBlock* top, BasicBlock* bottom) const { return lpTop->bbNum <= top->bbNum && bottom->bbNum < lpBottom->bbNum; } // Returns "true" iff "*this" (properly) contains "lp2" (allowing tops to be equal, but requiring // bottoms to be different.) bool lpContains(const LoopDsc& lp2) const { return lpContains(lp2.lpTop, lp2.lpBottom); } // Returns "true" iff "*this" is (properly) contained by the range [top, bottom] // (allowing tops to be equal, but requiring bottoms to be different.) bool lpContainedBy(BasicBlock* top, BasicBlock* bottom) const { return top->bbNum <= lpTop->bbNum && lpBottom->bbNum < bottom->bbNum; } // Returns "true" iff "*this" is (properly) contained by "lp2" // (allowing tops to be equal, but requiring bottoms to be different.) bool lpContainedBy(const LoopDsc& lp2) const { return lpContainedBy(lp2.lpTop, lp2.lpBottom); } // Returns "true" iff "*this" is disjoint from the range [top, bottom]. bool lpDisjoint(BasicBlock* top, BasicBlock* bottom) const { return bottom->bbNum < lpTop->bbNum || lpBottom->bbNum < top->bbNum; } // Returns "true" iff "*this" is disjoint from "lp2". bool lpDisjoint(const LoopDsc& lp2) const { return lpDisjoint(lp2.lpTop, lp2.lpBottom); } // Returns "true" iff the loop is well-formed (see code for defn). bool lpWellFormed() const { return lpTop->bbNum <= lpEntry->bbNum && lpEntry->bbNum <= lpBottom->bbNum && (lpHead->bbNum < lpTop->bbNum || lpHead->bbNum > lpBottom->bbNum); } #ifdef DEBUG void lpValidatePreHeader() const { // If this is called, we expect there to be a pre-header. assert(lpFlags & LPFLG_HAS_PREHEAD); // The pre-header must unconditionally enter the loop. assert(lpHead->GetUniqueSucc() == lpEntry); // The loop block must be marked as a pre-header. assert(lpHead->bbFlags & BBF_LOOP_PREHEADER); // The loop entry must have a single non-loop predecessor, which is the pre-header. // We can't assume here that the bbNum are properly ordered, so we can't do a simple lpContained() // check. So, we defer this check, which will be done by `fgDebugCheckLoopTable()`. } #endif // DEBUG // LoopBlocks: convenience method for enabling range-based `for` iteration over all the // blocks in a loop, e.g.: // for (BasicBlock* const block : loop->LoopBlocks()) ... // Currently, the loop blocks are expected to be in linear, lexical, `bbNext` order // from `lpTop` through `lpBottom`, inclusive. All blocks in this range are considered // to be part of the loop. // BasicBlockRangeList LoopBlocks() const { return BasicBlockRangeList(lpTop, lpBottom); } }; protected: bool fgMightHaveLoop(); // returns true if there are any back edges bool fgHasLoops; // True if this method has any loops, set in fgComputeReachability public: LoopDsc* optLoopTable; // loop descriptor table unsigned char optLoopCount; // number of tracked loops unsigned char loopAlignCandidates; // number of loops identified for alignment // Every time we rebuild the loop table, we increase the global "loop epoch". Any loop indices or // loop table pointers from the previous epoch are invalid. // TODO: validate this in some way? unsigned optCurLoopEpoch; void NewLoopEpoch() { ++optCurLoopEpoch; JITDUMP("New loop epoch %d\n", optCurLoopEpoch); } #ifdef DEBUG unsigned char loopsAligned; // number of loops actually aligned #endif // DEBUG bool optRecordLoop(BasicBlock* head, BasicBlock* top, BasicBlock* entry, BasicBlock* bottom, BasicBlock* exit, unsigned char exitCnt); void optClearLoopIterInfo(); #ifdef DEBUG void optPrintLoopInfo(unsigned lnum, bool printVerbose = false); void optPrintLoopInfo(const LoopDsc* loop, bool printVerbose = false); void optPrintLoopTable(); #endif protected: unsigned optCallCount; // number of calls made in the method unsigned optIndirectCallCount; // number of virtual, interface and indirect calls made in the method unsigned optNativeCallCount; // number of Pinvoke/Native calls made in the method unsigned optLoopsCloned; // number of loops cloned in the current method. #ifdef DEBUG void optCheckPreds(); #endif void optResetLoopInfo(); void optFindAndScaleGeneralLoopBlocks(); // Determine if there are any potential loops, and set BBF_LOOP_HEAD on potential loop heads. void optMarkLoopHeads(); void optScaleLoopBlocks(BasicBlock* begBlk, BasicBlock* endBlk); void optUnmarkLoopBlocks(BasicBlock* begBlk, BasicBlock* endBlk); void optUpdateLoopsBeforeRemoveBlock(BasicBlock* block, bool skipUnmarkLoop = false); bool optIsLoopTestEvalIntoTemp(Statement* testStmt, Statement** newTestStmt); unsigned optIsLoopIncrTree(GenTree* incr); bool optCheckIterInLoopTest(unsigned loopInd, GenTree* test, BasicBlock* from, BasicBlock* to, unsigned iterVar); bool optComputeIterInfo(GenTree* incr, BasicBlock* from, BasicBlock* to, unsigned* pIterVar); bool optPopulateInitInfo(unsigned loopInd, BasicBlock* initBlock, GenTree* init, unsigned iterVar); bool optExtractInitTestIncr( BasicBlock* head, BasicBlock* bottom, BasicBlock* exit, GenTree** ppInit, GenTree** ppTest, GenTree** ppIncr); void optFindNaturalLoops(); void optIdentifyLoopsForAlignment(); // Ensures that all the loops in the loop nest rooted at "loopInd" (an index into the loop table) are 'canonical' -- // each loop has a unique "top." Returns "true" iff the flowgraph has been modified. bool optCanonicalizeLoopNest(unsigned char loopInd); // Ensures that the loop "loopInd" (an index into the loop table) is 'canonical' -- it has a unique "top," // unshared with any other loop. Returns "true" iff the flowgraph has been modified bool optCanonicalizeLoop(unsigned char loopInd); // Requires "l1" to be a valid loop table index, and not "BasicBlock::NOT_IN_LOOP". // Requires "l2" to be a valid loop table index, or else "BasicBlock::NOT_IN_LOOP". // Returns true iff "l2" is not NOT_IN_LOOP, and "l1" contains "l2". // A loop contains itself. bool optLoopContains(unsigned l1, unsigned l2) const; // Updates the loop table by changing loop "loopInd", whose head is required // to be "from", to be "to". Also performs this transformation for any // loop nested in "loopInd" that shares the same head as "loopInd". void optUpdateLoopHead(unsigned loopInd, BasicBlock* from, BasicBlock* to); void optRedirectBlock(BasicBlock* blk, BlockToBlockMap* redirectMap, const bool updatePreds = false); // Marks the containsCall information to "lnum" and any parent loops. void AddContainsCallAllContainingLoops(unsigned lnum); // Adds the variable liveness information from 'blk' to "lnum" and any parent loops. void AddVariableLivenessAllContainingLoops(unsigned lnum, BasicBlock* blk); // Adds "fldHnd" to the set of modified fields of "lnum" and any parent loops. void AddModifiedFieldAllContainingLoops(unsigned lnum, CORINFO_FIELD_HANDLE fldHnd, FieldKindForVN fieldKind); // Adds "elemType" to the set of modified array element types of "lnum" and any parent loops. void AddModifiedElemTypeAllContainingLoops(unsigned lnum, CORINFO_CLASS_HANDLE elemType); // Requires that "from" and "to" have the same "bbJumpKind" (perhaps because "to" is a clone // of "from".) Copies the jump destination from "from" to "to". void optCopyBlkDest(BasicBlock* from, BasicBlock* to); // Returns true if 'block' is an entry block for any loop in 'optLoopTable' bool optIsLoopEntry(BasicBlock* block) const; // The depth of the loop described by "lnum" (an index into the loop table.) (0 == top level) unsigned optLoopDepth(unsigned lnum) { assert(lnum < optLoopCount); unsigned depth = 0; while ((lnum = optLoopTable[lnum].lpParent) != BasicBlock::NOT_IN_LOOP) { ++depth; } return depth; } // Struct used in optInvertWhileLoop to count interesting constructs to boost the profitability score. struct OptInvertCountTreeInfoType { int sharedStaticHelperCount; int arrayLengthCount; }; static fgWalkResult optInvertCountTreeInfo(GenTree** pTree, fgWalkData* data); bool optInvertWhileLoop(BasicBlock* block); private: static bool optIterSmallOverflow(int iterAtExit, var_types incrType); static bool optIterSmallUnderflow(int iterAtExit, var_types decrType); bool optComputeLoopRep(int constInit, int constLimit, int iterInc, genTreeOps iterOper, var_types iterType, genTreeOps testOper, bool unsignedTest, bool dupCond, unsigned* iterCount); static fgWalkPreFn optIsVarAssgCB; protected: bool optIsVarAssigned(BasicBlock* beg, BasicBlock* end, GenTree* skip, unsigned var); bool optIsVarAssgLoop(unsigned lnum, unsigned var); int optIsSetAssgLoop(unsigned lnum, ALLVARSET_VALARG_TP vars, varRefKinds inds = VR_NONE); bool optNarrowTree(GenTree* tree, var_types srct, var_types dstt, ValueNumPair vnpNarrow, bool doit); protected: // The following is the upper limit on how many expressions we'll keep track // of for the CSE analysis. // static const unsigned MAX_CSE_CNT = EXPSET_SZ; static const int MIN_CSE_COST = 2; // BitVec trait information only used by the optCSE_canSwap() method, for the CSE_defMask and CSE_useMask. // This BitVec uses one bit per CSE candidate BitVecTraits* cseMaskTraits; // one bit per CSE candidate // BitVec trait information for computing CSE availability using the CSE_DataFlow algorithm. // Two bits are allocated per CSE candidate to compute CSE availability // plus an extra bit to handle the initial unvisited case. // (See CSE_DataFlow::EndMerge for an explanation of why this is necessary.) // // The two bits per CSE candidate have the following meanings: // 11 - The CSE is available, and is also available when considering calls as killing availability. // 10 - The CSE is available, but is not available when considering calls as killing availability. // 00 - The CSE is not available // 01 - An illegal combination // BitVecTraits* cseLivenessTraits; //----------------------------------------------------------------------------------------------------------------- // getCSEnum2bit: Return the normalized index to use in the EXPSET_TP for the CSE with the given CSE index. // Each GenTree has a `gtCSEnum` field. Zero is reserved to mean this node is not a CSE, positive values indicate // CSE uses, and negative values indicate CSE defs. The caller must pass a non-zero positive value, as from // GET_CSE_INDEX(). // static unsigned genCSEnum2bit(unsigned CSEnum) { assert((CSEnum > 0) && (CSEnum <= MAX_CSE_CNT)); return CSEnum - 1; } //----------------------------------------------------------------------------------------------------------------- // getCSEAvailBit: Return the bit used by CSE dataflow sets (bbCseGen, etc.) for the availability bit for a CSE. // static unsigned getCSEAvailBit(unsigned CSEnum) { return genCSEnum2bit(CSEnum) * 2; } //----------------------------------------------------------------------------------------------------------------- // getCSEAvailCrossCallBit: Return the bit used by CSE dataflow sets (bbCseGen, etc.) for the availability bit // for a CSE considering calls as killing availability bit (see description above). // static unsigned getCSEAvailCrossCallBit(unsigned CSEnum) { return getCSEAvailBit(CSEnum) + 1; } void optPrintCSEDataFlowSet(EXPSET_VALARG_TP cseDataFlowSet, bool includeBits = true); EXPSET_TP cseCallKillsMask; // Computed once - A mask that is used to kill available CSEs at callsites /* Generic list of nodes - used by the CSE logic */ struct treeLst { treeLst* tlNext; GenTree* tlTree; }; struct treeStmtLst { treeStmtLst* tslNext; GenTree* tslTree; // tree node Statement* tslStmt; // statement containing the tree BasicBlock* tslBlock; // block containing the statement }; // The following logic keeps track of expressions via a simple hash table. struct CSEdsc { CSEdsc* csdNextInBucket; // used by the hash table size_t csdHashKey; // the orginal hashkey ssize_t csdConstDefValue; // When we CSE similar constants, this is the value that we use as the def ValueNum csdConstDefVN; // When we CSE similar constants, this is the ValueNumber that we use for the LclVar // assignment unsigned csdIndex; // 1..optCSECandidateCount bool csdIsSharedConst; // true if this CSE is a shared const bool csdLiveAcrossCall; unsigned short csdDefCount; // definition count unsigned short csdUseCount; // use count (excluding the implicit uses at defs) weight_t csdDefWtCnt; // weighted def count weight_t csdUseWtCnt; // weighted use count (excluding the implicit uses at defs) GenTree* csdTree; // treenode containing the 1st occurrence Statement* csdStmt; // stmt containing the 1st occurrence BasicBlock* csdBlock; // block containing the 1st occurrence treeStmtLst* csdTreeList; // list of matching tree nodes: head treeStmtLst* csdTreeLast; // list of matching tree nodes: tail // ToDo: This can be removed when gtGetStructHandleIfPresent stops guessing // and GT_IND nodes always have valid struct handle. // CORINFO_CLASS_HANDLE csdStructHnd; // The class handle, currently needed to create a SIMD LclVar in PerformCSE bool csdStructHndMismatch; ValueNum defExcSetPromise; // The exception set that is now required for all defs of this CSE. // This will be set to NoVN if we decide to abandon this CSE ValueNum defExcSetCurrent; // The set of exceptions we currently can use for CSE uses. ValueNum defConservNormVN; // if all def occurrences share the same conservative normal value // number, this will reflect it; otherwise, NoVN. // not used for shared const CSE's }; static const size_t s_optCSEhashSizeInitial; static const size_t s_optCSEhashGrowthFactor; static const size_t s_optCSEhashBucketSize; size_t optCSEhashSize; // The current size of hashtable size_t optCSEhashCount; // Number of entries in hashtable size_t optCSEhashMaxCountBeforeResize; // Number of entries before resize CSEdsc** optCSEhash; CSEdsc** optCSEtab; typedef JitHashTable<GenTree*, JitPtrKeyFuncs<GenTree>, GenTree*> NodeToNodeMap; NodeToNodeMap* optCseCheckedBoundMap; // Maps bound nodes to ancestor compares that should be // re-numbered with the bound to improve range check elimination // Given a compare, look for a cse candidate checked bound feeding it and add a map entry if found. void optCseUpdateCheckedBoundMap(GenTree* compare); void optCSEstop(); CSEdsc* optCSEfindDsc(unsigned index); bool optUnmarkCSE(GenTree* tree); // user defined callback data for the tree walk function optCSE_MaskHelper() struct optCSE_MaskData { EXPSET_TP CSE_defMask; EXPSET_TP CSE_useMask; }; // Treewalk helper for optCSE_DefMask and optCSE_UseMask static fgWalkPreFn optCSE_MaskHelper; // This function walks all the node for an given tree // and return the mask of CSE definitions and uses for the tree // void optCSE_GetMaskData(GenTree* tree, optCSE_MaskData* pMaskData); // Given a binary tree node return true if it is safe to swap the order of evaluation for op1 and op2. bool optCSE_canSwap(GenTree* firstNode, GenTree* secondNode); struct optCSEcostCmpEx { bool operator()(const CSEdsc* op1, const CSEdsc* op2); }; struct optCSEcostCmpSz { bool operator()(const CSEdsc* op1, const CSEdsc* op2); }; void optCleanupCSEs(); #ifdef DEBUG void optEnsureClearCSEInfo(); #endif // DEBUG static bool Is_Shared_Const_CSE(size_t key) { return ((key & TARGET_SIGN_BIT) != 0); } // returns the encoded key static size_t Encode_Shared_Const_CSE_Value(size_t key) { return TARGET_SIGN_BIT | (key >> CSE_CONST_SHARED_LOW_BITS); } // returns the orginal key static size_t Decode_Shared_Const_CSE_Value(size_t enckey) { assert(Is_Shared_Const_CSE(enckey)); return (enckey & ~TARGET_SIGN_BIT) << CSE_CONST_SHARED_LOW_BITS; } /************************************************************************** * Value Number based CSEs *************************************************************************/ // String to use for formatting CSE numbers. Note that this is the positive number, e.g., from GET_CSE_INDEX(). #define FMT_CSE "CSE #%02u" public: void optOptimizeValnumCSEs(); protected: void optValnumCSE_Init(); unsigned optValnumCSE_Index(GenTree* tree, Statement* stmt); bool optValnumCSE_Locate(); void optValnumCSE_InitDataFlow(); void optValnumCSE_DataFlow(); void optValnumCSE_Availablity(); void optValnumCSE_Heuristic(); bool optDoCSE; // True when we have found a duplicate CSE tree bool optValnumCSE_phase; // True when we are executing the optOptimizeValnumCSEs() phase unsigned optCSECandidateCount; // Count of CSE's candidates unsigned optCSEstart; // The first local variable number that is a CSE unsigned optCSEcount; // The total count of CSE's introduced. weight_t optCSEweight; // The weight of the current block when we are doing PerformCSE bool optIsCSEcandidate(GenTree* tree); // lclNumIsTrueCSE returns true if the LclVar was introduced by the CSE phase of the compiler // bool lclNumIsTrueCSE(unsigned lclNum) const { return ((optCSEcount > 0) && (lclNum >= optCSEstart) && (lclNum < optCSEstart + optCSEcount)); } // lclNumIsCSE returns true if the LclVar should be treated like a CSE with regards to constant prop. // bool lclNumIsCSE(unsigned lclNum) const { return lvaGetDesc(lclNum)->lvIsCSE; } #ifdef DEBUG bool optConfigDisableCSE(); bool optConfigDisableCSE2(); #endif void optOptimizeCSEs(); struct isVarAssgDsc { GenTree* ivaSkip; ALLVARSET_TP ivaMaskVal; // Set of variables assigned to. This is a set of all vars, not tracked vars. #ifdef DEBUG void* ivaSelf; #endif unsigned ivaVar; // Variable we are interested in, or -1 varRefKinds ivaMaskInd; // What kind of indirect assignments are there? callInterf ivaMaskCall; // What kind of calls are there? bool ivaMaskIncomplete; // Variables not representable in ivaMaskVal were assigned to. }; static callInterf optCallInterf(GenTreeCall* call); public: // VN based copy propagation. // In DEBUG builds, we'd like to know the tree that the SSA definition was pushed for. // While for ordinary SSA defs it will be available (as an ASG) in the SSA descriptor, // for locals which will use "definitions from uses", it will not be, so we store it // in this class instead. class CopyPropSsaDef { LclSsaVarDsc* m_ssaDef; #ifdef DEBUG GenTree* m_defNode; #endif public: CopyPropSsaDef(LclSsaVarDsc* ssaDef, GenTree* defNode) : m_ssaDef(ssaDef) #ifdef DEBUG , m_defNode(defNode) #endif { } LclSsaVarDsc* GetSsaDef() const { return m_ssaDef; } #ifdef DEBUG GenTree* GetDefNode() const { return m_defNode; } #endif }; typedef ArrayStack<CopyPropSsaDef> CopyPropSsaDefStack; typedef JitHashTable<unsigned, JitSmallPrimitiveKeyFuncs<unsigned>, CopyPropSsaDefStack*> LclNumToLiveDefsMap; // Copy propagation functions. void optCopyProp(Statement* stmt, GenTreeLclVarCommon* tree, unsigned lclNum, LclNumToLiveDefsMap* curSsaName); void optBlockCopyPropPopStacks(BasicBlock* block, LclNumToLiveDefsMap* curSsaName); void optBlockCopyProp(BasicBlock* block, LclNumToLiveDefsMap* curSsaName); void optCopyPropPushDef(GenTreeOp* asg, GenTreeLclVarCommon* lclNode, unsigned lclNum, LclNumToLiveDefsMap* curSsaName); unsigned optIsSsaLocal(GenTreeLclVarCommon* lclNode); int optCopyProp_LclVarScore(const LclVarDsc* lclVarDsc, const LclVarDsc* copyVarDsc, bool preferOp2); void optVnCopyProp(); INDEBUG(void optDumpCopyPropStack(LclNumToLiveDefsMap* curSsaName)); /************************************************************************** * Early value propagation *************************************************************************/ struct SSAName { unsigned m_lvNum; unsigned m_ssaNum; SSAName(unsigned lvNum, unsigned ssaNum) : m_lvNum(lvNum), m_ssaNum(ssaNum) { } static unsigned GetHashCode(SSAName ssaNm) { return (ssaNm.m_lvNum << 16) | (ssaNm.m_ssaNum); } static bool Equals(SSAName ssaNm1, SSAName ssaNm2) { return (ssaNm1.m_lvNum == ssaNm2.m_lvNum) && (ssaNm1.m_ssaNum == ssaNm2.m_ssaNum); } }; #define OMF_HAS_NEWARRAY 0x00000001 // Method contains 'new' of an array #define OMF_HAS_NEWOBJ 0x00000002 // Method contains 'new' of an object type. #define OMF_HAS_ARRAYREF 0x00000004 // Method contains array element loads or stores. #define OMF_HAS_NULLCHECK 0x00000008 // Method contains null check. #define OMF_HAS_FATPOINTER 0x00000010 // Method contains call, that needs fat pointer transformation. #define OMF_HAS_OBJSTACKALLOC 0x00000020 // Method contains an object allocated on the stack. #define OMF_HAS_GUARDEDDEVIRT 0x00000040 // Method contains guarded devirtualization candidate #define OMF_HAS_EXPRUNTIMELOOKUP 0x00000080 // Method contains a runtime lookup to an expandable dictionary. #define OMF_HAS_PATCHPOINT 0x00000100 // Method contains patchpoints #define OMF_NEEDS_GCPOLLS 0x00000200 // Method needs GC polls #define OMF_HAS_FROZEN_STRING 0x00000400 // Method has a frozen string (REF constant int), currently only on CoreRT. #define OMF_HAS_PARTIAL_COMPILATION_PATCHPOINT 0x00000800 // Method contains partial compilation patchpoints #define OMF_HAS_TAILCALL_SUCCESSOR 0x00001000 // Method has potential tail call in a non BBJ_RETURN block bool doesMethodHaveFatPointer() { return (optMethodFlags & OMF_HAS_FATPOINTER) != 0; } void setMethodHasFatPointer() { optMethodFlags |= OMF_HAS_FATPOINTER; } void clearMethodHasFatPointer() { optMethodFlags &= ~OMF_HAS_FATPOINTER; } void addFatPointerCandidate(GenTreeCall* call); bool doesMethodHaveFrozenString() const { return (optMethodFlags & OMF_HAS_FROZEN_STRING) != 0; } void setMethodHasFrozenString() { optMethodFlags |= OMF_HAS_FROZEN_STRING; } bool doesMethodHaveGuardedDevirtualization() const { return (optMethodFlags & OMF_HAS_GUARDEDDEVIRT) != 0; } void setMethodHasGuardedDevirtualization() { optMethodFlags |= OMF_HAS_GUARDEDDEVIRT; } void clearMethodHasGuardedDevirtualization() { optMethodFlags &= ~OMF_HAS_GUARDEDDEVIRT; } void considerGuardedDevirtualization(GenTreeCall* call, IL_OFFSET ilOffset, bool isInterface, CORINFO_METHOD_HANDLE baseMethod, CORINFO_CLASS_HANDLE baseClass, CORINFO_CONTEXT_HANDLE* pContextHandle DEBUGARG(CORINFO_CLASS_HANDLE objClass) DEBUGARG(const char* objClassName)); void addGuardedDevirtualizationCandidate(GenTreeCall* call, CORINFO_METHOD_HANDLE methodHandle, CORINFO_CLASS_HANDLE classHandle, unsigned methodAttr, unsigned classAttr, unsigned likelihood); bool doesMethodHaveExpRuntimeLookup() { return (optMethodFlags & OMF_HAS_EXPRUNTIMELOOKUP) != 0; } void setMethodHasExpRuntimeLookup() { optMethodFlags |= OMF_HAS_EXPRUNTIMELOOKUP; } void clearMethodHasExpRuntimeLookup() { optMethodFlags &= ~OMF_HAS_EXPRUNTIMELOOKUP; } void addExpRuntimeLookupCandidate(GenTreeCall* call); bool doesMethodHavePatchpoints() { return (optMethodFlags & OMF_HAS_PATCHPOINT) != 0; } void setMethodHasPatchpoint() { optMethodFlags |= OMF_HAS_PATCHPOINT; } bool doesMethodHavePartialCompilationPatchpoints() { return (optMethodFlags & OMF_HAS_PARTIAL_COMPILATION_PATCHPOINT) != 0; } void setMethodHasPartialCompilationPatchpoint() { optMethodFlags |= OMF_HAS_PARTIAL_COMPILATION_PATCHPOINT; } unsigned optMethodFlags; bool doesMethodHaveNoReturnCalls() { return optNoReturnCallCount > 0; } void setMethodHasNoReturnCalls() { optNoReturnCallCount++; } unsigned optNoReturnCallCount; // Recursion bound controls how far we can go backwards tracking for a SSA value. // No throughput diff was found with backward walk bound between 3-8. static const int optEarlyPropRecurBound = 5; enum class optPropKind { OPK_INVALID, OPK_ARRAYLEN, OPK_NULLCHECK }; typedef JitHashTable<unsigned, JitSmallPrimitiveKeyFuncs<unsigned>, GenTree*> LocalNumberToNullCheckTreeMap; GenTree* getArrayLengthFromAllocation(GenTree* tree DEBUGARG(BasicBlock* block)); GenTree* optPropGetValueRec(unsigned lclNum, unsigned ssaNum, optPropKind valueKind, int walkDepth); GenTree* optPropGetValue(unsigned lclNum, unsigned ssaNum, optPropKind valueKind); GenTree* optEarlyPropRewriteTree(GenTree* tree, LocalNumberToNullCheckTreeMap* nullCheckMap); bool optDoEarlyPropForBlock(BasicBlock* block); bool optDoEarlyPropForFunc(); void optEarlyProp(); void optFoldNullCheck(GenTree* tree, LocalNumberToNullCheckTreeMap* nullCheckMap); GenTree* optFindNullCheckToFold(GenTree* tree, LocalNumberToNullCheckTreeMap* nullCheckMap); bool optIsNullCheckFoldingLegal(GenTree* tree, GenTree* nullCheckTree, GenTree** nullCheckParent, Statement** nullCheckStmt); bool optCanMoveNullCheckPastTree(GenTree* tree, unsigned nullCheckLclNum, bool isInsideTry, bool checkSideEffectSummary); #if DEBUG void optCheckFlagsAreSet(unsigned methodFlag, const char* methodFlagStr, unsigned bbFlag, const char* bbFlagStr, GenTree* tree, BasicBlock* basicBlock); #endif // Redundant branch opts // PhaseStatus optRedundantBranches(); bool optRedundantRelop(BasicBlock* const block); bool optRedundantBranch(BasicBlock* const block); bool optJumpThread(BasicBlock* const block, BasicBlock* const domBlock, bool domIsSameRelop); bool optReachable(BasicBlock* const fromBlock, BasicBlock* const toBlock, BasicBlock* const excludedBlock); /************************************************************************** * Value/Assertion propagation *************************************************************************/ public: // Data structures for assertion prop BitVecTraits* apTraits; ASSERT_TP apFull; enum optAssertionKind { OAK_INVALID, OAK_EQUAL, OAK_NOT_EQUAL, OAK_SUBRANGE, OAK_NO_THROW, OAK_COUNT }; enum optOp1Kind { O1K_INVALID, O1K_LCLVAR, O1K_ARR_BND, O1K_BOUND_OPER_BND, O1K_BOUND_LOOP_BND, O1K_CONSTANT_LOOP_BND, O1K_CONSTANT_LOOP_BND_UN, O1K_EXACT_TYPE, O1K_SUBTYPE, O1K_VALUE_NUMBER, O1K_COUNT }; enum optOp2Kind { O2K_INVALID, O2K_LCLVAR_COPY, O2K_IND_CNS_INT, O2K_CONST_INT, O2K_CONST_LONG, O2K_CONST_DOUBLE, O2K_ZEROOBJ, O2K_SUBRANGE, O2K_COUNT }; struct AssertionDsc { optAssertionKind assertionKind; struct SsaVar { unsigned lclNum; // assigned to or property of this local var number unsigned ssaNum; }; struct ArrBnd { ValueNum vnIdx; ValueNum vnLen; }; struct AssertionDscOp1 { optOp1Kind kind; // a normal LclVar, or Exact-type or Subtype ValueNum vn; union { SsaVar lcl; ArrBnd bnd; }; } op1; struct AssertionDscOp2 { optOp2Kind kind; // a const or copy assignment ValueNum vn; struct IntVal { ssize_t iconVal; // integer #if !defined(HOST_64BIT) unsigned padding; // unused; ensures iconFlags does not overlap lconVal #endif GenTreeFlags iconFlags; // gtFlags }; union { struct { SsaVar lcl; FieldSeqNode* zeroOffsetFieldSeq; }; IntVal u1; __int64 lconVal; double dconVal; IntegralRange u2; }; } op2; bool IsCheckedBoundArithBound() { return ((assertionKind == OAK_EQUAL || assertionKind == OAK_NOT_EQUAL) && op1.kind == O1K_BOUND_OPER_BND); } bool IsCheckedBoundBound() { return ((assertionKind == OAK_EQUAL || assertionKind == OAK_NOT_EQUAL) && op1.kind == O1K_BOUND_LOOP_BND); } bool IsConstantBound() { return ((assertionKind == OAK_EQUAL || assertionKind == OAK_NOT_EQUAL) && (op1.kind == O1K_CONSTANT_LOOP_BND)); } bool IsConstantBoundUnsigned() { return ((assertionKind == OAK_EQUAL || assertionKind == OAK_NOT_EQUAL) && (op1.kind == O1K_CONSTANT_LOOP_BND_UN)); } bool IsBoundsCheckNoThrow() { return ((assertionKind == OAK_NO_THROW) && (op1.kind == O1K_ARR_BND)); } bool IsCopyAssertion() { return ((assertionKind == OAK_EQUAL) && (op1.kind == O1K_LCLVAR) && (op2.kind == O2K_LCLVAR_COPY)); } bool IsConstantInt32Assertion() { return ((assertionKind == OAK_EQUAL) || (assertionKind == OAK_NOT_EQUAL)) && (op2.kind == O2K_CONST_INT); } static bool SameKind(AssertionDsc* a1, AssertionDsc* a2) { return a1->assertionKind == a2->assertionKind && a1->op1.kind == a2->op1.kind && a1->op2.kind == a2->op2.kind; } static bool ComplementaryKind(optAssertionKind kind, optAssertionKind kind2) { if (kind == OAK_EQUAL) { return kind2 == OAK_NOT_EQUAL; } else if (kind == OAK_NOT_EQUAL) { return kind2 == OAK_EQUAL; } return false; } bool HasSameOp1(AssertionDsc* that, bool vnBased) { if (op1.kind != that->op1.kind) { return false; } else if (op1.kind == O1K_ARR_BND) { assert(vnBased); return (op1.bnd.vnIdx == that->op1.bnd.vnIdx) && (op1.bnd.vnLen == that->op1.bnd.vnLen); } else { return ((vnBased && (op1.vn == that->op1.vn)) || (!vnBased && (op1.lcl.lclNum == that->op1.lcl.lclNum))); } } bool HasSameOp2(AssertionDsc* that, bool vnBased) { if (op2.kind != that->op2.kind) { return false; } switch (op2.kind) { case O2K_IND_CNS_INT: case O2K_CONST_INT: return ((op2.u1.iconVal == that->op2.u1.iconVal) && (op2.u1.iconFlags == that->op2.u1.iconFlags)); case O2K_CONST_LONG: return (op2.lconVal == that->op2.lconVal); case O2K_CONST_DOUBLE: // exact match because of positive and negative zero. return (memcmp(&op2.dconVal, &that->op2.dconVal, sizeof(double)) == 0); case O2K_ZEROOBJ: return true; case O2K_LCLVAR_COPY: return (op2.lcl.lclNum == that->op2.lcl.lclNum) && (!vnBased || op2.lcl.ssaNum == that->op2.lcl.ssaNum) && (op2.zeroOffsetFieldSeq == that->op2.zeroOffsetFieldSeq); case O2K_SUBRANGE: return op2.u2.Equals(that->op2.u2); case O2K_INVALID: // we will return false break; default: assert(!"Unexpected value for op2.kind in AssertionDsc."); break; } return false; } bool Complementary(AssertionDsc* that, bool vnBased) { return ComplementaryKind(assertionKind, that->assertionKind) && HasSameOp1(that, vnBased) && HasSameOp2(that, vnBased); } bool Equals(AssertionDsc* that, bool vnBased) { if (assertionKind != that->assertionKind) { return false; } else if (assertionKind == OAK_NO_THROW) { assert(op2.kind == O2K_INVALID); return HasSameOp1(that, vnBased); } else { return HasSameOp1(that, vnBased) && HasSameOp2(that, vnBased); } } }; protected: static fgWalkPreFn optAddCopiesCallback; static fgWalkPreFn optVNAssertionPropCurStmtVisitor; unsigned optAddCopyLclNum; GenTree* optAddCopyAsgnNode; bool optLocalAssertionProp; // indicates that we are performing local assertion prop bool optAssertionPropagated; // set to true if we modified the trees bool optAssertionPropagatedCurrentStmt; #ifdef DEBUG GenTree* optAssertionPropCurrentTree; #endif AssertionIndex* optComplementaryAssertionMap; JitExpandArray<ASSERT_TP>* optAssertionDep; // table that holds dependent assertions (assertions // using the value of a local var) for each local var AssertionDsc* optAssertionTabPrivate; // table that holds info about value assignments AssertionIndex optAssertionCount; // total number of assertions in the assertion table AssertionIndex optMaxAssertionCount; public: void optVnNonNullPropCurStmt(BasicBlock* block, Statement* stmt, GenTree* tree); fgWalkResult optVNConstantPropCurStmt(BasicBlock* block, Statement* stmt, GenTree* tree); GenTree* optVNConstantPropOnJTrue(BasicBlock* block, GenTree* test); GenTree* optVNConstantPropOnTree(BasicBlock* block, GenTree* tree); GenTree* optExtractSideEffListFromConst(GenTree* tree); AssertionIndex GetAssertionCount() { return optAssertionCount; } ASSERT_TP* bbJtrueAssertionOut; typedef JitHashTable<ValueNum, JitSmallPrimitiveKeyFuncs<ValueNum>, ASSERT_TP> ValueNumToAssertsMap; ValueNumToAssertsMap* optValueNumToAsserts; // Assertion prop helpers. ASSERT_TP& GetAssertionDep(unsigned lclNum); AssertionDsc* optGetAssertion(AssertionIndex assertIndex); void optAssertionInit(bool isLocalProp); void optAssertionTraitsInit(AssertionIndex assertionCount); void optAssertionReset(AssertionIndex limit); void optAssertionRemove(AssertionIndex index); // Assertion prop data flow functions. void optAssertionPropMain(); Statement* optVNAssertionPropCurStmt(BasicBlock* block, Statement* stmt); bool optIsTreeKnownIntValue(bool vnBased, GenTree* tree, ssize_t* pConstant, GenTreeFlags* pIconFlags); ASSERT_TP* optInitAssertionDataflowFlags(); ASSERT_TP* optComputeAssertionGen(); // Assertion Gen functions. void optAssertionGen(GenTree* tree); AssertionIndex optAssertionGenCast(GenTreeCast* cast); AssertionIndex optAssertionGenPhiDefn(GenTree* tree); AssertionInfo optCreateJTrueBoundsAssertion(GenTree* tree); AssertionInfo optAssertionGenJtrue(GenTree* tree); AssertionIndex optCreateJtrueAssertions(GenTree* op1, GenTree* op2, Compiler::optAssertionKind assertionKind, bool helperCallArgs = false); AssertionIndex optFindComplementary(AssertionIndex assertionIndex); void optMapComplementary(AssertionIndex assertionIndex, AssertionIndex index); // Assertion creation functions. AssertionIndex optCreateAssertion(GenTree* op1, GenTree* op2, optAssertionKind assertionKind, bool helperCallArgs = false); AssertionIndex optFinalizeCreatingAssertion(AssertionDsc* assertion); bool optTryExtractSubrangeAssertion(GenTree* source, IntegralRange* pRange); void optCreateComplementaryAssertion(AssertionIndex assertionIndex, GenTree* op1, GenTree* op2, bool helperCallArgs = false); bool optAssertionVnInvolvesNan(AssertionDsc* assertion); AssertionIndex optAddAssertion(AssertionDsc* assertion); void optAddVnAssertionMapping(ValueNum vn, AssertionIndex index); #ifdef DEBUG void optPrintVnAssertionMapping(); #endif ASSERT_TP optGetVnMappedAssertions(ValueNum vn); // Used for respective assertion propagations. AssertionIndex optAssertionIsSubrange(GenTree* tree, IntegralRange range, ASSERT_VALARG_TP assertions); AssertionIndex optAssertionIsSubtype(GenTree* tree, GenTree* methodTableArg, ASSERT_VALARG_TP assertions); AssertionIndex optAssertionIsNonNullInternal(GenTree* op, ASSERT_VALARG_TP assertions DEBUGARG(bool* pVnBased)); bool optAssertionIsNonNull(GenTree* op, ASSERT_VALARG_TP assertions DEBUGARG(bool* pVnBased) DEBUGARG(AssertionIndex* pIndex)); AssertionIndex optGlobalAssertionIsEqualOrNotEqual(ASSERT_VALARG_TP assertions, GenTree* op1, GenTree* op2); AssertionIndex optGlobalAssertionIsEqualOrNotEqualZero(ASSERT_VALARG_TP assertions, GenTree* op1); AssertionIndex optLocalAssertionIsEqualOrNotEqual( optOp1Kind op1Kind, unsigned lclNum, optOp2Kind op2Kind, ssize_t cnsVal, ASSERT_VALARG_TP assertions); // Assertion prop for lcl var functions. bool optAssertionProp_LclVarTypeCheck(GenTree* tree, LclVarDsc* lclVarDsc, LclVarDsc* copyVarDsc); GenTree* optCopyAssertionProp(AssertionDsc* curAssertion, GenTreeLclVarCommon* tree, Statement* stmt DEBUGARG(AssertionIndex index)); GenTree* optConstantAssertionProp(AssertionDsc* curAssertion, GenTreeLclVarCommon* tree, Statement* stmt DEBUGARG(AssertionIndex index)); bool optZeroObjAssertionProp(GenTree* tree, ASSERT_VALARG_TP assertions); // Assertion propagation functions. GenTree* optAssertionProp(ASSERT_VALARG_TP assertions, GenTree* tree, Statement* stmt, BasicBlock* block); GenTree* optAssertionProp_LclVar(ASSERT_VALARG_TP assertions, GenTreeLclVarCommon* tree, Statement* stmt); GenTree* optAssertionProp_Asg(ASSERT_VALARG_TP assertions, GenTreeOp* asg, Statement* stmt); GenTree* optAssertionProp_Return(ASSERT_VALARG_TP assertions, GenTreeUnOp* ret, Statement* stmt); GenTree* optAssertionProp_Ind(ASSERT_VALARG_TP assertions, GenTree* tree, Statement* stmt); GenTree* optAssertionProp_Cast(ASSERT_VALARG_TP assertions, GenTreeCast* cast, Statement* stmt); GenTree* optAssertionProp_Call(ASSERT_VALARG_TP assertions, GenTreeCall* call, Statement* stmt); GenTree* optAssertionProp_RelOp(ASSERT_VALARG_TP assertions, GenTree* tree, Statement* stmt); GenTree* optAssertionProp_Comma(ASSERT_VALARG_TP assertions, GenTree* tree, Statement* stmt); GenTree* optAssertionProp_BndsChk(ASSERT_VALARG_TP assertions, GenTree* tree, Statement* stmt); GenTree* optAssertionPropGlobal_RelOp(ASSERT_VALARG_TP assertions, GenTree* tree, Statement* stmt); GenTree* optAssertionPropLocal_RelOp(ASSERT_VALARG_TP assertions, GenTree* tree, Statement* stmt); GenTree* optAssertionProp_Update(GenTree* newTree, GenTree* tree, Statement* stmt); GenTree* optNonNullAssertionProp_Call(ASSERT_VALARG_TP assertions, GenTreeCall* call); // Implied assertion functions. void optImpliedAssertions(AssertionIndex assertionIndex, ASSERT_TP& activeAssertions); void optImpliedByTypeOfAssertions(ASSERT_TP& activeAssertions); void optImpliedByCopyAssertion(AssertionDsc* copyAssertion, AssertionDsc* depAssertion, ASSERT_TP& result); void optImpliedByConstAssertion(AssertionDsc* curAssertion, ASSERT_TP& result); #ifdef DEBUG void optPrintAssertion(AssertionDsc* newAssertion, AssertionIndex assertionIndex = 0); void optPrintAssertionIndex(AssertionIndex index); void optPrintAssertionIndices(ASSERT_TP assertions); void optDebugCheckAssertion(AssertionDsc* assertion); void optDebugCheckAssertions(AssertionIndex AssertionIndex); #endif static void optDumpAssertionIndices(const char* header, ASSERT_TP assertions, const char* footer = nullptr); static void optDumpAssertionIndices(ASSERT_TP assertions, const char* footer = nullptr); void optAddCopies(); /************************************************************************** * Range checks *************************************************************************/ public: struct LoopCloneVisitorInfo { LoopCloneContext* context; unsigned loopNum; Statement* stmt; LoopCloneVisitorInfo(LoopCloneContext* context, unsigned loopNum, Statement* stmt) : context(context), loopNum(loopNum), stmt(nullptr) { } }; bool optIsStackLocalInvariant(unsigned loopNum, unsigned lclNum); bool optExtractArrIndex(GenTree* tree, ArrIndex* result, unsigned lhsNum); bool optReconstructArrIndex(GenTree* tree, ArrIndex* result, unsigned lhsNum); bool optIdentifyLoopOptInfo(unsigned loopNum, LoopCloneContext* context); static fgWalkPreFn optCanOptimizeByLoopCloningVisitor; fgWalkResult optCanOptimizeByLoopCloning(GenTree* tree, LoopCloneVisitorInfo* info); bool optObtainLoopCloningOpts(LoopCloneContext* context); bool optIsLoopClonable(unsigned loopInd); bool optLoopCloningEnabled(); #ifdef DEBUG void optDebugLogLoopCloning(BasicBlock* block, Statement* insertBefore); #endif void optPerformStaticOptimizations(unsigned loopNum, LoopCloneContext* context DEBUGARG(bool fastPath)); bool optComputeDerefConditions(unsigned loopNum, LoopCloneContext* context); bool optDeriveLoopCloningConditions(unsigned loopNum, LoopCloneContext* context); BasicBlock* optInsertLoopChoiceConditions(LoopCloneContext* context, unsigned loopNum, BasicBlock* slowHead, BasicBlock* insertAfter); protected: ssize_t optGetArrayRefScaleAndIndex(GenTree* mul, GenTree** pIndex DEBUGARG(bool bRngChk)); bool optReachWithoutCall(BasicBlock* srcBB, BasicBlock* dstBB); protected: bool optLoopsMarked; /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX RegAlloc XX XX XX XX Does the register allocation and puts the remaining lclVars on the stack XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ public: regNumber raUpdateRegStateForArg(RegState* regState, LclVarDsc* argDsc); void raMarkStkVars(); #if FEATURE_PARTIAL_SIMD_CALLEE_SAVE #if defined(TARGET_AMD64) static bool varTypeNeedsPartialCalleeSave(var_types type) { assert(type != TYP_STRUCT); return (type == TYP_SIMD32); } #elif defined(TARGET_ARM64) static bool varTypeNeedsPartialCalleeSave(var_types type) { assert(type != TYP_STRUCT); // ARM64 ABI FP Callee save registers only require Callee to save lower 8 Bytes // For SIMD types longer than 8 bytes Caller is responsible for saving and restoring Upper bytes. return ((type == TYP_SIMD16) || (type == TYP_SIMD12)); } #else // !defined(TARGET_AMD64) && !defined(TARGET_ARM64) #error("Unknown target architecture for FEATURE_SIMD") #endif // !defined(TARGET_AMD64) && !defined(TARGET_ARM64) #endif // FEATURE_PARTIAL_SIMD_CALLEE_SAVE protected: // Some things are used by both LSRA and regpredict allocators. FrameType rpFrameType; bool rpMustCreateEBPCalled; // Set to true after we have called rpMustCreateEBPFrame once bool rpMustCreateEBPFrame(INDEBUG(const char** wbReason)); private: Lowering* m_pLowering; // Lowering; needed to Lower IR that's added or modified after Lowering. LinearScanInterface* m_pLinearScan; // Linear Scan allocator /* raIsVarargsStackArg is called by raMaskStkVars and by lvaComputeRefCounts. It identifies the special case where a varargs function has a parameter passed on the stack, other than the special varargs handle. Such parameters require special treatment, because they cannot be tracked by the GC (their offsets in the stack are not known at compile time). */ bool raIsVarargsStackArg(unsigned lclNum) { #ifdef TARGET_X86 LclVarDsc* varDsc = lvaGetDesc(lclNum); assert(varDsc->lvIsParam); return (info.compIsVarArgs && !varDsc->lvIsRegArg && (lclNum != lvaVarargsHandleArg)); #else // TARGET_X86 return false; #endif // TARGET_X86 } /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX EEInterface XX XX XX XX Get to the class and method info from the Execution Engine given XX XX tokens for the class and method XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ public: // Get handles void eeGetCallInfo(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_RESOLVED_TOKEN* pConstrainedToken, CORINFO_CALLINFO_FLAGS flags, CORINFO_CALL_INFO* pResult); void eeGetFieldInfo(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_ACCESS_FLAGS flags, CORINFO_FIELD_INFO* pResult); // Get the flags bool eeIsValueClass(CORINFO_CLASS_HANDLE clsHnd); bool eeIsIntrinsic(CORINFO_METHOD_HANDLE ftn); bool eeIsFieldStatic(CORINFO_FIELD_HANDLE fldHnd); var_types eeGetFieldType(CORINFO_FIELD_HANDLE fldHnd, CORINFO_CLASS_HANDLE* pStructHnd = nullptr); #if defined(DEBUG) || defined(FEATURE_JIT_METHOD_PERF) || defined(FEATURE_SIMD) || defined(TRACK_LSRA_STATS) const char* eeGetMethodName(CORINFO_METHOD_HANDLE hnd, const char** className); const char* eeGetMethodFullName(CORINFO_METHOD_HANDLE hnd); unsigned compMethodHash(CORINFO_METHOD_HANDLE methodHandle); bool eeIsNativeMethod(CORINFO_METHOD_HANDLE method); CORINFO_METHOD_HANDLE eeGetMethodHandleForNative(CORINFO_METHOD_HANDLE method); #endif var_types eeGetArgType(CORINFO_ARG_LIST_HANDLE list, CORINFO_SIG_INFO* sig); var_types eeGetArgType(CORINFO_ARG_LIST_HANDLE list, CORINFO_SIG_INFO* sig, bool* isPinned); CORINFO_CLASS_HANDLE eeGetArgClass(CORINFO_SIG_INFO* sig, CORINFO_ARG_LIST_HANDLE list); CORINFO_CLASS_HANDLE eeGetClassFromContext(CORINFO_CONTEXT_HANDLE context); unsigned eeGetArgSize(CORINFO_ARG_LIST_HANDLE list, CORINFO_SIG_INFO* sig); static unsigned eeGetArgAlignment(var_types type, bool isFloatHfa); // VOM info, method sigs void eeGetSig(unsigned sigTok, CORINFO_MODULE_HANDLE scope, CORINFO_CONTEXT_HANDLE context, CORINFO_SIG_INFO* retSig); void eeGetCallSiteSig(unsigned sigTok, CORINFO_MODULE_HANDLE scope, CORINFO_CONTEXT_HANDLE context, CORINFO_SIG_INFO* retSig); void eeGetMethodSig(CORINFO_METHOD_HANDLE methHnd, CORINFO_SIG_INFO* retSig, CORINFO_CLASS_HANDLE owner = nullptr); // Method entry-points, instrs CORINFO_METHOD_HANDLE eeMarkNativeTarget(CORINFO_METHOD_HANDLE method); CORINFO_EE_INFO eeInfo; bool eeInfoInitialized; CORINFO_EE_INFO* eeGetEEInfo(); // Gets the offset of a SDArray's first element static unsigned eeGetArrayDataOffset(); // Get the offset of a MDArray's first element static unsigned eeGetMDArrayDataOffset(unsigned rank); // Get the offset of a MDArray's dimension length for a given dimension. static unsigned eeGetMDArrayLengthOffset(unsigned rank, unsigned dimension); // Get the offset of a MDArray's lower bound for a given dimension. static unsigned eeGetMDArrayLowerBoundOffset(unsigned rank, unsigned dimension); GenTree* eeGetPInvokeCookie(CORINFO_SIG_INFO* szMetaSig); // Returns the page size for the target machine as reported by the EE. target_size_t eeGetPageSize() { return (target_size_t)eeGetEEInfo()->osPageSize; } //------------------------------------------------------------------------ // VirtualStubParam: virtual stub dispatch extra parameter (slot address). // // It represents Abi and target specific registers for the parameter. // class VirtualStubParamInfo { public: VirtualStubParamInfo(bool isCoreRTABI) { #if defined(TARGET_X86) reg = REG_EAX; regMask = RBM_EAX; #elif defined(TARGET_AMD64) if (isCoreRTABI) { reg = REG_R10; regMask = RBM_R10; } else { reg = REG_R11; regMask = RBM_R11; } #elif defined(TARGET_ARM) if (isCoreRTABI) { reg = REG_R12; regMask = RBM_R12; } else { reg = REG_R4; regMask = RBM_R4; } #elif defined(TARGET_ARM64) reg = REG_R11; regMask = RBM_R11; #else #error Unsupported or unset target architecture #endif } regNumber GetReg() const { return reg; } _regMask_enum GetRegMask() const { return regMask; } private: regNumber reg; _regMask_enum regMask; }; VirtualStubParamInfo* virtualStubParamInfo; bool IsTargetAbi(CORINFO_RUNTIME_ABI abi) { return eeGetEEInfo()->targetAbi == abi; } bool generateCFIUnwindCodes() { #if defined(FEATURE_CFI_SUPPORT) return TargetOS::IsUnix && IsTargetAbi(CORINFO_CORERT_ABI); #else return false; #endif } // Debugging support - Line number info void eeGetStmtOffsets(); unsigned eeBoundariesCount; ICorDebugInfo::OffsetMapping* eeBoundaries; // Boundaries to report to the EE void eeSetLIcount(unsigned count); void eeSetLIinfo(unsigned which, UNATIVE_OFFSET offs, IPmappingDscKind kind, const ILLocation& loc); void eeSetLIdone(); #ifdef DEBUG static void eeDispILOffs(IL_OFFSET offs); static void eeDispSourceMappingOffs(uint32_t offs); static void eeDispLineInfo(const ICorDebugInfo::OffsetMapping* line); void eeDispLineInfos(); #endif // DEBUG // Debugging support - Local var info void eeGetVars(); unsigned eeVarsCount; struct VarResultInfo { UNATIVE_OFFSET startOffset; UNATIVE_OFFSET endOffset; DWORD varNumber; CodeGenInterface::siVarLoc loc; } * eeVars; void eeSetLVcount(unsigned count); void eeSetLVinfo(unsigned which, UNATIVE_OFFSET startOffs, UNATIVE_OFFSET length, unsigned varNum, const CodeGenInterface::siVarLoc& loc); void eeSetLVdone(); #ifdef DEBUG void eeDispVar(ICorDebugInfo::NativeVarInfo* var); void eeDispVars(CORINFO_METHOD_HANDLE ftn, ULONG32 cVars, ICorDebugInfo::NativeVarInfo* vars); #endif // DEBUG // ICorJitInfo wrappers void eeReserveUnwindInfo(bool isFunclet, bool isColdCode, ULONG unwindSize); void eeAllocUnwindInfo(BYTE* pHotCode, BYTE* pColdCode, ULONG startOffset, ULONG endOffset, ULONG unwindSize, BYTE* pUnwindBlock, CorJitFuncKind funcKind); void eeSetEHcount(unsigned cEH); void eeSetEHinfo(unsigned EHnumber, const CORINFO_EH_CLAUSE* clause); WORD eeGetRelocTypeHint(void* target); // ICorStaticInfo wrapper functions bool eeTryResolveToken(CORINFO_RESOLVED_TOKEN* resolvedToken); #if defined(UNIX_AMD64_ABI) #ifdef DEBUG static void dumpSystemVClassificationType(SystemVClassificationType ct); #endif // DEBUG void eeGetSystemVAmd64PassStructInRegisterDescriptor( /*IN*/ CORINFO_CLASS_HANDLE structHnd, /*OUT*/ SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR* structPassInRegDescPtr); #endif // UNIX_AMD64_ABI template <typename ParamType> bool eeRunWithErrorTrap(void (*function)(ParamType*), ParamType* param) { return eeRunWithErrorTrapImp(reinterpret_cast<void (*)(void*)>(function), reinterpret_cast<void*>(param)); } bool eeRunWithErrorTrapImp(void (*function)(void*), void* param); template <typename ParamType> bool eeRunWithSPMIErrorTrap(void (*function)(ParamType*), ParamType* param) { return eeRunWithSPMIErrorTrapImp(reinterpret_cast<void (*)(void*)>(function), reinterpret_cast<void*>(param)); } bool eeRunWithSPMIErrorTrapImp(void (*function)(void*), void* param); // Utility functions const char* eeGetFieldName(CORINFO_FIELD_HANDLE fieldHnd, const char** classNamePtr = nullptr); #if defined(DEBUG) const WCHAR* eeGetCPString(size_t stringHandle); #endif const char* eeGetClassName(CORINFO_CLASS_HANDLE clsHnd); static CORINFO_METHOD_HANDLE eeFindHelper(unsigned helper); static CorInfoHelpFunc eeGetHelperNum(CORINFO_METHOD_HANDLE method); static bool IsSharedStaticHelper(GenTree* tree); static bool IsGcSafePoint(GenTreeCall* call); static CORINFO_FIELD_HANDLE eeFindJitDataOffs(unsigned jitDataOffs); // returns true/false if 'field' is a Jit Data offset static bool eeIsJitDataOffs(CORINFO_FIELD_HANDLE field); // returns a number < 0 if 'field' is not a Jit Data offset, otherwise the data offset (limited to 2GB) static int eeGetJitDataOffs(CORINFO_FIELD_HANDLE field); /*****************************************************************************/ /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX CodeGenerator XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ public: CodeGenInterface* codeGen; // Record the instr offset mapping to the generated code jitstd::list<IPmappingDsc> genIPmappings; #ifdef DEBUG jitstd::list<PreciseIPMapping> genPreciseIPmappings; #endif // Managed RetVal - A side hash table meant to record the mapping from a // GT_CALL node to its debug info. This info is used to emit sequence points // that can be used by debugger to determine the native offset at which the // managed RetVal will be available. // // In fact we can store debug info in a GT_CALL node. This was ruled out in // favor of a side table for two reasons: 1) We need debug info for only those // GT_CALL nodes (created during importation) that correspond to an IL call and // whose return type is other than TYP_VOID. 2) GT_CALL node is a frequently used // structure and IL offset is needed only when generating debuggable code. Therefore // it is desirable to avoid memory size penalty in retail scenarios. typedef JitHashTable<GenTree*, JitPtrKeyFuncs<GenTree>, DebugInfo> CallSiteDebugInfoTable; CallSiteDebugInfoTable* genCallSite2DebugInfoMap; unsigned genReturnLocal; // Local number for the return value when applicable. BasicBlock* genReturnBB; // jumped to when not optimizing for speed. // The following properties are part of CodeGenContext. Getters are provided here for // convenience and backward compatibility, but the properties can only be set by invoking // the setter on CodeGenContext directly. emitter* GetEmitter() const { return codeGen->GetEmitter(); } bool isFramePointerUsed() const { return codeGen->isFramePointerUsed(); } bool GetInterruptible() { return codeGen->GetInterruptible(); } void SetInterruptible(bool value) { codeGen->SetInterruptible(value); } #if DOUBLE_ALIGN const bool genDoubleAlign() { return codeGen->doDoubleAlign(); } DWORD getCanDoubleAlign(); bool shouldDoubleAlign(unsigned refCntStk, unsigned refCntReg, weight_t refCntWtdReg, unsigned refCntStkParam, weight_t refCntWtdStkDbl); #endif // DOUBLE_ALIGN bool IsFullPtrRegMapRequired() { return codeGen->IsFullPtrRegMapRequired(); } void SetFullPtrRegMapRequired(bool value) { codeGen->SetFullPtrRegMapRequired(value); } // Things that MAY belong either in CodeGen or CodeGenContext #if defined(FEATURE_EH_FUNCLETS) FuncInfoDsc* compFuncInfos; unsigned short compCurrFuncIdx; unsigned short compFuncInfoCount; unsigned short compFuncCount() { assert(fgFuncletsCreated); return compFuncInfoCount; } #else // !FEATURE_EH_FUNCLETS // This is a no-op when there are no funclets! void genUpdateCurrentFunclet(BasicBlock* block) { return; } FuncInfoDsc compFuncInfoRoot; static const unsigned compCurrFuncIdx = 0; unsigned short compFuncCount() { return 1; } #endif // !FEATURE_EH_FUNCLETS FuncInfoDsc* funCurrentFunc(); void funSetCurrentFunc(unsigned funcIdx); FuncInfoDsc* funGetFunc(unsigned funcIdx); unsigned int funGetFuncIdx(BasicBlock* block); // LIVENESS VARSET_TP compCurLife; // current live variables GenTree* compCurLifeTree; // node after which compCurLife has been computed // Compare the given "newLife" with last set of live variables and update // codeGen "gcInfo", siScopes, "regSet" with the new variable's homes/liveness. template <bool ForCodeGen> void compChangeLife(VARSET_VALARG_TP newLife); // Update the GC's masks, register's masks and reports change on variable's homes given a set of // current live variables if changes have happened since "compCurLife". template <bool ForCodeGen> inline void compUpdateLife(VARSET_VALARG_TP newLife); // Gets a register mask that represent the kill set for a helper call since // not all JIT Helper calls follow the standard ABI on the target architecture. regMaskTP compHelperCallKillSet(CorInfoHelpFunc helper); #ifdef TARGET_ARM // Requires that "varDsc" be a promoted struct local variable being passed as an argument, beginning at // "firstArgRegNum", which is assumed to have already been aligned to the register alignment restriction of the // struct type. Adds bits to "*pArgSkippedRegMask" for any argument registers *not* used in passing "varDsc" -- // i.e., internal "holes" caused by internal alignment constraints. For example, if the struct contained an int and // a double, and we at R0 (on ARM), then R1 would be skipped, and the bit for R1 would be added to the mask. void fgAddSkippedRegsInPromotedStructArg(LclVarDsc* varDsc, unsigned firstArgRegNum, regMaskTP* pArgSkippedRegMask); #endif // TARGET_ARM // If "tree" is a indirection (GT_IND, or GT_OBJ) whose arg is an ADDR, whose arg is a LCL_VAR, return that LCL_VAR // node, else NULL. static GenTreeLclVar* fgIsIndirOfAddrOfLocal(GenTree* tree); // This map is indexed by GT_OBJ nodes that are address of promoted struct variables, which // have been annotated with the GTF_VAR_DEATH flag. If such a node is *not* mapped in this // table, one may assume that all the (tracked) field vars die at this GT_OBJ. Otherwise, // the node maps to a pointer to a VARSET_TP, containing set bits for each of the tracked field // vars of the promoted struct local that go dead at the given node (the set bits are the bits // for the tracked var indices of the field vars, as in a live var set). // // The map is allocated on demand so all map operations should use one of the following three // wrapper methods. NodeToVarsetPtrMap* m_promotedStructDeathVars; NodeToVarsetPtrMap* GetPromotedStructDeathVars() { if (m_promotedStructDeathVars == nullptr) { m_promotedStructDeathVars = new (getAllocator()) NodeToVarsetPtrMap(getAllocator()); } return m_promotedStructDeathVars; } void ClearPromotedStructDeathVars() { if (m_promotedStructDeathVars != nullptr) { m_promotedStructDeathVars->RemoveAll(); } } bool LookupPromotedStructDeathVars(GenTree* tree, VARSET_TP** bits) { *bits = nullptr; bool result = false; if (m_promotedStructDeathVars != nullptr) { result = m_promotedStructDeathVars->Lookup(tree, bits); } return result; } /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX UnwindInfo XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ #if !defined(__GNUC__) #pragma region Unwind information #endif public: // // Infrastructure functions: start/stop/reserve/emit. // void unwindBegProlog(); void unwindEndProlog(); void unwindBegEpilog(); void unwindEndEpilog(); void unwindReserve(); void unwindEmit(void* pHotCode, void* pColdCode); // // Specific unwind information functions: called by code generation to indicate a particular // prolog or epilog unwindable instruction has been generated. // void unwindPush(regNumber reg); void unwindAllocStack(unsigned size); void unwindSetFrameReg(regNumber reg, unsigned offset); void unwindSaveReg(regNumber reg, unsigned offset); #if defined(TARGET_ARM) void unwindPushMaskInt(regMaskTP mask); void unwindPushMaskFloat(regMaskTP mask); void unwindPopMaskInt(regMaskTP mask); void unwindPopMaskFloat(regMaskTP mask); void unwindBranch16(); // The epilog terminates with a 16-bit branch (e.g., "bx lr") void unwindNop(unsigned codeSizeInBytes); // Generate unwind NOP code. 'codeSizeInBytes' is 2 or 4 bytes. Only // called via unwindPadding(). void unwindPadding(); // Generate a sequence of unwind NOP codes representing instructions between the last // instruction and the current location. #endif // TARGET_ARM #if defined(TARGET_ARM64) void unwindNop(); void unwindPadding(); // Generate a sequence of unwind NOP codes representing instructions between the last // instruction and the current location. void unwindSaveReg(regNumber reg, int offset); // str reg, [sp, #offset] void unwindSaveRegPreindexed(regNumber reg, int offset); // str reg, [sp, #offset]! void unwindSaveRegPair(regNumber reg1, regNumber reg2, int offset); // stp reg1, reg2, [sp, #offset] void unwindSaveRegPairPreindexed(regNumber reg1, regNumber reg2, int offset); // stp reg1, reg2, [sp, #offset]! void unwindSaveNext(); // unwind code: save_next void unwindReturn(regNumber reg); // ret lr #endif // defined(TARGET_ARM64) // // Private "helper" functions for the unwind implementation. // private: #if defined(FEATURE_EH_FUNCLETS) void unwindGetFuncLocations(FuncInfoDsc* func, bool getHotSectionData, /* OUT */ emitLocation** ppStartLoc, /* OUT */ emitLocation** ppEndLoc); #endif // FEATURE_EH_FUNCLETS void unwindReserveFunc(FuncInfoDsc* func); void unwindEmitFunc(FuncInfoDsc* func, void* pHotCode, void* pColdCode); #if defined(TARGET_AMD64) || (defined(TARGET_X86) && defined(FEATURE_EH_FUNCLETS)) void unwindReserveFuncHelper(FuncInfoDsc* func, bool isHotCode); void unwindEmitFuncHelper(FuncInfoDsc* func, void* pHotCode, void* pColdCode, bool isHotCode); #endif // TARGET_AMD64 || (TARGET_X86 && FEATURE_EH_FUNCLETS) UNATIVE_OFFSET unwindGetCurrentOffset(FuncInfoDsc* func); #if defined(TARGET_AMD64) void unwindBegPrologWindows(); void unwindPushWindows(regNumber reg); void unwindAllocStackWindows(unsigned size); void unwindSetFrameRegWindows(regNumber reg, unsigned offset); void unwindSaveRegWindows(regNumber reg, unsigned offset); #ifdef UNIX_AMD64_ABI void unwindSaveRegCFI(regNumber reg, unsigned offset); #endif // UNIX_AMD64_ABI #elif defined(TARGET_ARM) void unwindPushPopMaskInt(regMaskTP mask, bool useOpsize16); void unwindPushPopMaskFloat(regMaskTP mask); #endif // TARGET_ARM #if defined(FEATURE_CFI_SUPPORT) short mapRegNumToDwarfReg(regNumber reg); void createCfiCode(FuncInfoDsc* func, UNATIVE_OFFSET codeOffset, UCHAR opcode, short dwarfReg, INT offset = 0); void unwindPushPopCFI(regNumber reg); void unwindBegPrologCFI(); void unwindPushPopMaskCFI(regMaskTP regMask, bool isFloat); void unwindAllocStackCFI(unsigned size); void unwindSetFrameRegCFI(regNumber reg, unsigned offset); void unwindEmitFuncCFI(FuncInfoDsc* func, void* pHotCode, void* pColdCode); #ifdef DEBUG void DumpCfiInfo(bool isHotCode, UNATIVE_OFFSET startOffset, UNATIVE_OFFSET endOffset, DWORD cfiCodeBytes, const CFI_CODE* const pCfiCode); #endif #endif // FEATURE_CFI_SUPPORT #if !defined(__GNUC__) #pragma endregion // Note: region is NOT under !defined(__GNUC__) #endif /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX SIMD XX XX XX XX Info about SIMD types, methods and the SIMD assembly (i.e. the assembly XX XX that contains the distinguished, well-known SIMD type definitions). XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ bool IsBaselineSimdIsaSupported() { #ifdef FEATURE_SIMD #if defined(TARGET_XARCH) CORINFO_InstructionSet minimumIsa = InstructionSet_SSE2; #elif defined(TARGET_ARM64) CORINFO_InstructionSet minimumIsa = InstructionSet_AdvSimd; #else #error Unsupported platform #endif // !TARGET_XARCH && !TARGET_ARM64 return compOpportunisticallyDependsOn(minimumIsa); #else return false; #endif } #if defined(DEBUG) bool IsBaselineSimdIsaSupportedDebugOnly() { #ifdef FEATURE_SIMD #if defined(TARGET_XARCH) CORINFO_InstructionSet minimumIsa = InstructionSet_SSE2; #elif defined(TARGET_ARM64) CORINFO_InstructionSet minimumIsa = InstructionSet_AdvSimd; #else #error Unsupported platform #endif // !TARGET_XARCH && !TARGET_ARM64 return compIsaSupportedDebugOnly(minimumIsa); #else return false; #endif // FEATURE_SIMD } #endif // DEBUG // Get highest available level for SIMD codegen SIMDLevel getSIMDSupportLevel() { #if defined(TARGET_XARCH) if (compOpportunisticallyDependsOn(InstructionSet_AVX2)) { return SIMD_AVX2_Supported; } if (compOpportunisticallyDependsOn(InstructionSet_SSE42)) { return SIMD_SSE4_Supported; } // min bar is SSE2 return SIMD_SSE2_Supported; #else assert(!"Available instruction set(s) for SIMD codegen is not defined for target arch"); unreached(); return SIMD_Not_Supported; #endif } bool isIntrinsicType(CORINFO_CLASS_HANDLE clsHnd) { return info.compCompHnd->isIntrinsicType(clsHnd); } const char* getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName) { return info.compCompHnd->getClassNameFromMetadata(cls, namespaceName); } CORINFO_CLASS_HANDLE getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index) { return info.compCompHnd->getTypeInstantiationArgument(cls, index); } #ifdef FEATURE_SIMD // Should we support SIMD intrinsics? bool featureSIMD; // Should we recognize SIMD types? // We always do this on ARM64 to support HVA types. bool supportSIMDTypes() { #ifdef TARGET_ARM64 return true; #else return featureSIMD; #endif } // Have we identified any SIMD types? // This is currently used by struct promotion to avoid getting type information for a struct // field to see if it is a SIMD type, if we haven't seen any SIMD types or operations in // the method. bool _usesSIMDTypes; bool usesSIMDTypes() { return _usesSIMDTypes; } void setUsesSIMDTypes(bool value) { _usesSIMDTypes = value; } // This is a temp lclVar allocated on the stack as TYP_SIMD. It is used to implement intrinsics // that require indexed access to the individual fields of the vector, which is not well supported // by the hardware. It is allocated when/if such situations are encountered during Lowering. unsigned lvaSIMDInitTempVarNum; struct SIMDHandlesCache { // SIMD Types CORINFO_CLASS_HANDLE SIMDFloatHandle; CORINFO_CLASS_HANDLE SIMDDoubleHandle; CORINFO_CLASS_HANDLE SIMDIntHandle; CORINFO_CLASS_HANDLE SIMDUShortHandle; CORINFO_CLASS_HANDLE SIMDUByteHandle; CORINFO_CLASS_HANDLE SIMDShortHandle; CORINFO_CLASS_HANDLE SIMDByteHandle; CORINFO_CLASS_HANDLE SIMDLongHandle; CORINFO_CLASS_HANDLE SIMDUIntHandle; CORINFO_CLASS_HANDLE SIMDULongHandle; CORINFO_CLASS_HANDLE SIMDNIntHandle; CORINFO_CLASS_HANDLE SIMDNUIntHandle; CORINFO_CLASS_HANDLE SIMDVector2Handle; CORINFO_CLASS_HANDLE SIMDVector3Handle; CORINFO_CLASS_HANDLE SIMDVector4Handle; CORINFO_CLASS_HANDLE SIMDVectorHandle; #ifdef FEATURE_HW_INTRINSICS #if defined(TARGET_ARM64) CORINFO_CLASS_HANDLE Vector64FloatHandle; CORINFO_CLASS_HANDLE Vector64DoubleHandle; CORINFO_CLASS_HANDLE Vector64IntHandle; CORINFO_CLASS_HANDLE Vector64UShortHandle; CORINFO_CLASS_HANDLE Vector64UByteHandle; CORINFO_CLASS_HANDLE Vector64ShortHandle; CORINFO_CLASS_HANDLE Vector64ByteHandle; CORINFO_CLASS_HANDLE Vector64LongHandle; CORINFO_CLASS_HANDLE Vector64UIntHandle; CORINFO_CLASS_HANDLE Vector64ULongHandle; CORINFO_CLASS_HANDLE Vector64NIntHandle; CORINFO_CLASS_HANDLE Vector64NUIntHandle; #endif // defined(TARGET_ARM64) CORINFO_CLASS_HANDLE Vector128FloatHandle; CORINFO_CLASS_HANDLE Vector128DoubleHandle; CORINFO_CLASS_HANDLE Vector128IntHandle; CORINFO_CLASS_HANDLE Vector128UShortHandle; CORINFO_CLASS_HANDLE Vector128UByteHandle; CORINFO_CLASS_HANDLE Vector128ShortHandle; CORINFO_CLASS_HANDLE Vector128ByteHandle; CORINFO_CLASS_HANDLE Vector128LongHandle; CORINFO_CLASS_HANDLE Vector128UIntHandle; CORINFO_CLASS_HANDLE Vector128ULongHandle; CORINFO_CLASS_HANDLE Vector128NIntHandle; CORINFO_CLASS_HANDLE Vector128NUIntHandle; #if defined(TARGET_XARCH) CORINFO_CLASS_HANDLE Vector256FloatHandle; CORINFO_CLASS_HANDLE Vector256DoubleHandle; CORINFO_CLASS_HANDLE Vector256IntHandle; CORINFO_CLASS_HANDLE Vector256UShortHandle; CORINFO_CLASS_HANDLE Vector256UByteHandle; CORINFO_CLASS_HANDLE Vector256ShortHandle; CORINFO_CLASS_HANDLE Vector256ByteHandle; CORINFO_CLASS_HANDLE Vector256LongHandle; CORINFO_CLASS_HANDLE Vector256UIntHandle; CORINFO_CLASS_HANDLE Vector256ULongHandle; CORINFO_CLASS_HANDLE Vector256NIntHandle; CORINFO_CLASS_HANDLE Vector256NUIntHandle; #endif // defined(TARGET_XARCH) #endif // FEATURE_HW_INTRINSICS SIMDHandlesCache() { memset(this, 0, sizeof(*this)); } }; SIMDHandlesCache* m_simdHandleCache; // Get an appropriate "zero" for the given type and class handle. GenTree* gtGetSIMDZero(var_types simdType, CorInfoType simdBaseJitType, CORINFO_CLASS_HANDLE simdHandle); // Get the handle for a SIMD type. CORINFO_CLASS_HANDLE gtGetStructHandleForSIMD(var_types simdType, CorInfoType simdBaseJitType) { if (m_simdHandleCache == nullptr) { // This may happen if the JIT generates SIMD node on its own, without importing them. // Otherwise getBaseJitTypeAndSizeOfSIMDType should have created the cache. return NO_CLASS_HANDLE; } if (simdBaseJitType == CORINFO_TYPE_FLOAT) { switch (simdType) { case TYP_SIMD8: return m_simdHandleCache->SIMDVector2Handle; case TYP_SIMD12: return m_simdHandleCache->SIMDVector3Handle; case TYP_SIMD16: if ((getSIMDVectorType() == TYP_SIMD32) || (m_simdHandleCache->SIMDVector4Handle != NO_CLASS_HANDLE)) { return m_simdHandleCache->SIMDVector4Handle; } break; case TYP_SIMD32: break; default: unreached(); } } assert(emitTypeSize(simdType) <= largestEnregisterableStructSize()); switch (simdBaseJitType) { case CORINFO_TYPE_FLOAT: return m_simdHandleCache->SIMDFloatHandle; case CORINFO_TYPE_DOUBLE: return m_simdHandleCache->SIMDDoubleHandle; case CORINFO_TYPE_INT: return m_simdHandleCache->SIMDIntHandle; case CORINFO_TYPE_USHORT: return m_simdHandleCache->SIMDUShortHandle; case CORINFO_TYPE_UBYTE: return m_simdHandleCache->SIMDUByteHandle; case CORINFO_TYPE_SHORT: return m_simdHandleCache->SIMDShortHandle; case CORINFO_TYPE_BYTE: return m_simdHandleCache->SIMDByteHandle; case CORINFO_TYPE_LONG: return m_simdHandleCache->SIMDLongHandle; case CORINFO_TYPE_UINT: return m_simdHandleCache->SIMDUIntHandle; case CORINFO_TYPE_ULONG: return m_simdHandleCache->SIMDULongHandle; case CORINFO_TYPE_NATIVEINT: return m_simdHandleCache->SIMDNIntHandle; case CORINFO_TYPE_NATIVEUINT: return m_simdHandleCache->SIMDNUIntHandle; default: assert(!"Didn't find a class handle for simdType"); } return NO_CLASS_HANDLE; } // Returns true if this is a SIMD type that should be considered an opaque // vector type (i.e. do not analyze or promote its fields). // Note that all but the fixed vector types are opaque, even though they may // actually be declared as having fields. bool isOpaqueSIMDType(CORINFO_CLASS_HANDLE structHandle) const { return ((m_simdHandleCache != nullptr) && (structHandle != m_simdHandleCache->SIMDVector2Handle) && (structHandle != m_simdHandleCache->SIMDVector3Handle) && (structHandle != m_simdHandleCache->SIMDVector4Handle)); } // Returns true if the tree corresponds to a TYP_SIMD lcl var. // Note that both SIMD vector args and locals are mared as lvSIMDType = true, but // type of an arg node is TYP_BYREF and a local node is TYP_SIMD or TYP_STRUCT. bool isSIMDTypeLocal(GenTree* tree) { return tree->OperIsLocal() && lvaGetDesc(tree->AsLclVarCommon())->lvSIMDType; } // Returns true if the lclVar is an opaque SIMD type. bool isOpaqueSIMDLclVar(const LclVarDsc* varDsc) const { if (!varDsc->lvSIMDType) { return false; } return isOpaqueSIMDType(varDsc->GetStructHnd()); } static bool isRelOpSIMDIntrinsic(SIMDIntrinsicID intrinsicId) { return (intrinsicId == SIMDIntrinsicEqual); } // Returns base JIT type of a TYP_SIMD local. // Returns CORINFO_TYPE_UNDEF if the local is not TYP_SIMD. CorInfoType getBaseJitTypeOfSIMDLocal(GenTree* tree) { if (isSIMDTypeLocal(tree)) { return lvaGetDesc(tree->AsLclVarCommon())->GetSimdBaseJitType(); } return CORINFO_TYPE_UNDEF; } bool isSIMDClass(CORINFO_CLASS_HANDLE clsHnd) { if (isIntrinsicType(clsHnd)) { const char* namespaceName = nullptr; (void)getClassNameFromMetadata(clsHnd, &namespaceName); return strcmp(namespaceName, "System.Numerics") == 0; } return false; } bool isSIMDClass(typeInfo* pTypeInfo) { return pTypeInfo->IsStruct() && isSIMDClass(pTypeInfo->GetClassHandleForValueClass()); } bool isHWSIMDClass(CORINFO_CLASS_HANDLE clsHnd) { #ifdef FEATURE_HW_INTRINSICS if (isIntrinsicType(clsHnd)) { const char* namespaceName = nullptr; (void)getClassNameFromMetadata(clsHnd, &namespaceName); return strcmp(namespaceName, "System.Runtime.Intrinsics") == 0; } #endif // FEATURE_HW_INTRINSICS return false; } bool isHWSIMDClass(typeInfo* pTypeInfo) { #ifdef FEATURE_HW_INTRINSICS return pTypeInfo->IsStruct() && isHWSIMDClass(pTypeInfo->GetClassHandleForValueClass()); #else return false; #endif } bool isSIMDorHWSIMDClass(CORINFO_CLASS_HANDLE clsHnd) { return isSIMDClass(clsHnd) || isHWSIMDClass(clsHnd); } bool isSIMDorHWSIMDClass(typeInfo* pTypeInfo) { return isSIMDClass(pTypeInfo) || isHWSIMDClass(pTypeInfo); } // Get the base (element) type and size in bytes for a SIMD type. Returns CORINFO_TYPE_UNDEF // if it is not a SIMD type or is an unsupported base JIT type. CorInfoType getBaseJitTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeHnd, unsigned* sizeBytes = nullptr); CorInfoType getBaseJitTypeOfSIMDType(CORINFO_CLASS_HANDLE typeHnd) { return getBaseJitTypeAndSizeOfSIMDType(typeHnd, nullptr); } // Get SIMD Intrinsic info given the method handle. // Also sets typeHnd, argCount, baseType and sizeBytes out params. const SIMDIntrinsicInfo* getSIMDIntrinsicInfo(CORINFO_CLASS_HANDLE* typeHnd, CORINFO_METHOD_HANDLE methodHnd, CORINFO_SIG_INFO* sig, bool isNewObj, unsigned* argCount, CorInfoType* simdBaseJitType, unsigned* sizeBytes); // Pops and returns GenTree node from importers type stack. // Normalizes TYP_STRUCT value in case of GT_CALL, GT_RET_EXPR and arg nodes. GenTree* impSIMDPopStack(var_types type, bool expectAddr = false, CORINFO_CLASS_HANDLE structType = nullptr); // Transforms operands and returns the SIMD intrinsic to be applied on // transformed operands to obtain given relop result. SIMDIntrinsicID impSIMDRelOp(SIMDIntrinsicID relOpIntrinsicId, CORINFO_CLASS_HANDLE typeHnd, unsigned simdVectorSize, CorInfoType* inOutBaseJitType, GenTree** op1, GenTree** op2); #if defined(TARGET_XARCH) // Transforms operands and returns the SIMD intrinsic to be applied on // transformed operands to obtain == comparison result. SIMDIntrinsicID impSIMDLongRelOpEqual(CORINFO_CLASS_HANDLE typeHnd, unsigned simdVectorSize, GenTree** op1, GenTree** op2); #endif // defined(TARGET_XARCH) void setLclRelatedToSIMDIntrinsic(GenTree* tree); bool areFieldsContiguous(GenTree* op1, GenTree* op2); bool areLocalFieldsContiguous(GenTreeLclFld* first, GenTreeLclFld* second); bool areArrayElementsContiguous(GenTree* op1, GenTree* op2); bool areArgumentsContiguous(GenTree* op1, GenTree* op2); GenTree* createAddressNodeForSIMDInit(GenTree* tree, unsigned simdSize); // check methodHnd to see if it is a SIMD method that is expanded as an intrinsic in the JIT. GenTree* impSIMDIntrinsic(OPCODE opcode, GenTree* newobjThis, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig, unsigned methodFlags, int memberRef); GenTree* getOp1ForConstructor(OPCODE opcode, GenTree* newobjThis, CORINFO_CLASS_HANDLE clsHnd); // Whether SIMD vector occupies part of SIMD register. // SSE2: vector2f/3f are considered sub register SIMD types. // AVX: vector2f, 3f and 4f are all considered sub register SIMD types. bool isSubRegisterSIMDType(GenTreeSIMD* simdNode) { unsigned vectorRegisterByteLength; #if defined(TARGET_XARCH) // Calling the getSIMDVectorRegisterByteLength api causes the size of Vector<T> to be recorded // with the AOT compiler, so that it cannot change from aot compilation time to runtime // This api does not require such fixing as it merely pertains to the size of the simd type // relative to the Vector<T> size as used at compile time. (So detecting a vector length of 16 here // does not preclude the code from being used on a machine with a larger vector length.) if (getSIMDSupportLevel() < SIMD_AVX2_Supported) { vectorRegisterByteLength = 16; } else { vectorRegisterByteLength = 32; } #else vectorRegisterByteLength = getSIMDVectorRegisterByteLength(); #endif return (simdNode->GetSimdSize() < vectorRegisterByteLength); } // Get the type for the hardware SIMD vector. // This is the maximum SIMD type supported for this target. var_types getSIMDVectorType() { #if defined(TARGET_XARCH) if (getSIMDSupportLevel() == SIMD_AVX2_Supported) { return TYP_SIMD32; } else { // Verify and record that AVX2 isn't supported compVerifyInstructionSetUnusable(InstructionSet_AVX2); assert(getSIMDSupportLevel() >= SIMD_SSE2_Supported); return TYP_SIMD16; } #elif defined(TARGET_ARM64) return TYP_SIMD16; #else assert(!"getSIMDVectorType() unimplemented on target arch"); unreached(); #endif } // Get the size of the SIMD type in bytes int getSIMDTypeSizeInBytes(CORINFO_CLASS_HANDLE typeHnd) { unsigned sizeBytes = 0; (void)getBaseJitTypeAndSizeOfSIMDType(typeHnd, &sizeBytes); return sizeBytes; } // Get the the number of elements of baseType of SIMD vector given by its size and baseType static int getSIMDVectorLength(unsigned simdSize, var_types baseType); // Get the the number of elements of baseType of SIMD vector given by its type handle int getSIMDVectorLength(CORINFO_CLASS_HANDLE typeHnd); // Get preferred alignment of SIMD type. int getSIMDTypeAlignment(var_types simdType); // Get the number of bytes in a System.Numeric.Vector<T> for the current compilation. // Note - cannot be used for System.Runtime.Intrinsic unsigned getSIMDVectorRegisterByteLength() { #if defined(TARGET_XARCH) if (getSIMDSupportLevel() == SIMD_AVX2_Supported) { return YMM_REGSIZE_BYTES; } else { // Verify and record that AVX2 isn't supported compVerifyInstructionSetUnusable(InstructionSet_AVX2); assert(getSIMDSupportLevel() >= SIMD_SSE2_Supported); return XMM_REGSIZE_BYTES; } #elif defined(TARGET_ARM64) return FP_REGSIZE_BYTES; #else assert(!"getSIMDVectorRegisterByteLength() unimplemented on target arch"); unreached(); #endif } // The minimum and maximum possible number of bytes in a SIMD vector. // maxSIMDStructBytes // The minimum SIMD size supported by System.Numeric.Vectors or System.Runtime.Intrinsic // SSE: 16-byte Vector<T> and Vector128<T> // AVX: 32-byte Vector256<T> (Vector<T> is 16-byte) // AVX2: 32-byte Vector<T> and Vector256<T> unsigned int maxSIMDStructBytes() { #if defined(FEATURE_HW_INTRINSICS) && defined(TARGET_XARCH) if (compOpportunisticallyDependsOn(InstructionSet_AVX)) { return YMM_REGSIZE_BYTES; } else { // Verify and record that AVX2 isn't supported compVerifyInstructionSetUnusable(InstructionSet_AVX2); assert(getSIMDSupportLevel() >= SIMD_SSE2_Supported); return XMM_REGSIZE_BYTES; } #else return getSIMDVectorRegisterByteLength(); #endif } unsigned int minSIMDStructBytes() { return emitTypeSize(TYP_SIMD8); } public: // Returns the codegen type for a given SIMD size. static var_types getSIMDTypeForSize(unsigned size) { var_types simdType = TYP_UNDEF; if (size == 8) { simdType = TYP_SIMD8; } else if (size == 12) { simdType = TYP_SIMD12; } else if (size == 16) { simdType = TYP_SIMD16; } else if (size == 32) { simdType = TYP_SIMD32; } else { noway_assert(!"Unexpected size for SIMD type"); } return simdType; } private: unsigned getSIMDInitTempVarNum(var_types simdType); #else // !FEATURE_SIMD bool isOpaqueSIMDLclVar(LclVarDsc* varDsc) { return false; } #endif // FEATURE_SIMD public: //------------------------------------------------------------------------ // largestEnregisterableStruct: The size in bytes of the largest struct that can be enregistered. // // Notes: It is not guaranteed that the struct of this size or smaller WILL be a // candidate for enregistration. unsigned largestEnregisterableStructSize() { #ifdef FEATURE_SIMD #if defined(FEATURE_HW_INTRINSICS) && defined(TARGET_XARCH) if (opts.IsReadyToRun()) { // Return constant instead of maxSIMDStructBytes, as maxSIMDStructBytes performs // checks that are effected by the current level of instruction set support would // otherwise cause the highest level of instruction set support to be reported to crossgen2. // and this api is only ever used as an optimization or assert, so no reporting should // ever happen. return YMM_REGSIZE_BYTES; } #endif // defined(FEATURE_HW_INTRINSICS) && defined(TARGET_XARCH) unsigned vectorRegSize = maxSIMDStructBytes(); assert(vectorRegSize >= TARGET_POINTER_SIZE); return vectorRegSize; #else // !FEATURE_SIMD return TARGET_POINTER_SIZE; #endif // !FEATURE_SIMD } // Use to determine if a struct *might* be a SIMD type. As this function only takes a size, many // structs will fit the criteria. bool structSizeMightRepresentSIMDType(size_t structSize) { #ifdef FEATURE_SIMD // Do not use maxSIMDStructBytes as that api in R2R on X86 and X64 may notify the JIT // about the size of a struct under the assumption that the struct size needs to be recorded. // By using largestEnregisterableStructSize here, the detail of whether or not Vector256<T> is // enregistered or not will not be messaged to the R2R compiler. return (structSize >= minSIMDStructBytes()) && (structSize <= largestEnregisterableStructSize()); #else return false; #endif // FEATURE_SIMD } #ifdef FEATURE_SIMD static bool vnEncodesResultTypeForSIMDIntrinsic(SIMDIntrinsicID intrinsicId); #endif // !FEATURE_SIMD #ifdef FEATURE_HW_INTRINSICS static bool vnEncodesResultTypeForHWIntrinsic(NamedIntrinsic hwIntrinsicID); #endif // FEATURE_HW_INTRINSICS private: // These routines need not be enclosed under FEATURE_SIMD since lvIsSIMDType() // is defined for both FEATURE_SIMD and !FEATURE_SIMD apropriately. The use // of this routines also avoids the need of #ifdef FEATURE_SIMD specific code. // Is this var is of type simd struct? bool lclVarIsSIMDType(unsigned varNum) { return lvaGetDesc(varNum)->lvIsSIMDType(); } // Is this Local node a SIMD local? bool lclVarIsSIMDType(GenTreeLclVarCommon* lclVarTree) { return lclVarIsSIMDType(lclVarTree->GetLclNum()); } // Returns true if the TYP_SIMD locals on stack are aligned at their // preferred byte boundary specified by getSIMDTypeAlignment(). // // As per the Intel manual, the preferred alignment for AVX vectors is // 32-bytes. It is not clear whether additional stack space used in // aligning stack is worth the benefit and for now will use 16-byte // alignment for AVX 256-bit vectors with unaligned load/stores to/from // memory. On x86, the stack frame is aligned to 4 bytes. We need to extend // existing support for double (8-byte) alignment to 16 or 32 byte // alignment for frames with local SIMD vars, if that is determined to be // profitable. // // On Amd64 and SysV, RSP+8 is aligned on entry to the function (before // prolog has run). This means that in RBP-based frames RBP will be 16-byte // aligned. For RSP-based frames these are only sometimes aligned, depending // on the frame size. // bool isSIMDTypeLocalAligned(unsigned varNum) { #if defined(FEATURE_SIMD) && ALIGN_SIMD_TYPES if (lclVarIsSIMDType(varNum) && lvaTable[varNum].lvType != TYP_BYREF) { // TODO-Cleanup: Can't this use the lvExactSize on the varDsc? int alignment = getSIMDTypeAlignment(lvaTable[varNum].lvType); if (alignment <= STACK_ALIGN) { bool rbpBased; int off = lvaFrameAddress(varNum, &rbpBased); // On SysV and Winx64 ABIs RSP+8 will be 16-byte aligned at the // first instruction of a function. If our frame is RBP based // then RBP will always be 16 bytes aligned, so we can simply // check the offset. if (rbpBased) { return (off % alignment) == 0; } // For RSP-based frame the alignment of RSP depends on our // locals. rsp+8 is aligned on entry and we just subtract frame // size so it is not hard to compute. Note that the compiler // tries hard to make sure the frame size means RSP will be // 16-byte aligned, but for leaf functions without locals (i.e. // frameSize = 0) it will not be. int frameSize = codeGen->genTotalFrameSize(); return ((8 - frameSize + off) % alignment) == 0; } } #endif // FEATURE_SIMD return false; } #ifdef DEBUG // Answer the question: Is a particular ISA supported? // Use this api when asking the question so that future // ISA questions can be asked correctly or when asserting // support/nonsupport for an instruction set bool compIsaSupportedDebugOnly(CORINFO_InstructionSet isa) const { #if defined(TARGET_XARCH) || defined(TARGET_ARM64) return (opts.compSupportsISA & (1ULL << isa)) != 0; #else return false; #endif } #endif // DEBUG bool notifyInstructionSetUsage(CORINFO_InstructionSet isa, bool supported) const; // Answer the question: Is a particular ISA allowed to be used implicitly by optimizations? // The result of this api call will exactly match the target machine // on which the function is executed (except for CoreLib, where there are special rules) bool compExactlyDependsOn(CORINFO_InstructionSet isa) const { #if defined(TARGET_XARCH) || defined(TARGET_ARM64) uint64_t isaBit = (1ULL << isa); if ((opts.compSupportsISAReported & isaBit) == 0) { if (notifyInstructionSetUsage(isa, (opts.compSupportsISA & isaBit) != 0)) ((Compiler*)this)->opts.compSupportsISAExactly |= isaBit; ((Compiler*)this)->opts.compSupportsISAReported |= isaBit; } return (opts.compSupportsISAExactly & isaBit) != 0; #else return false; #endif } // Ensure that code will not execute if an instruction set is usable. Call only // if the instruction set has previously reported as unusable, but when // that that status has not yet been recorded to the AOT compiler void compVerifyInstructionSetUnusable(CORINFO_InstructionSet isa) { // use compExactlyDependsOn to capture are record the use of the isa bool isaUsable = compExactlyDependsOn(isa); // Assert that the is unusable. If true, this function should never be called. assert(!isaUsable); } // Answer the question: Is a particular ISA allowed to be used implicitly by optimizations? // The result of this api call will match the target machine if the result is true // If the result is false, then the target machine may have support for the instruction bool compOpportunisticallyDependsOn(CORINFO_InstructionSet isa) const { if ((opts.compSupportsISA & (1ULL << isa)) != 0) { return compExactlyDependsOn(isa); } else { return false; } } // Answer the question: Is a particular ISA supported for explicit hardware intrinsics? bool compHWIntrinsicDependsOn(CORINFO_InstructionSet isa) const { // Report intent to use the ISA to the EE compExactlyDependsOn(isa); return ((opts.compSupportsISA & (1ULL << isa)) != 0); } bool canUseVexEncoding() const { #ifdef TARGET_XARCH return compOpportunisticallyDependsOn(InstructionSet_AVX); #else return false; #endif } /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX Compiler XX XX XX XX Generic info about the compilation and the method being compiled. XX XX It is responsible for driving the other phases. XX XX It is also responsible for all the memory management. XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ public: Compiler* InlineeCompiler; // The Compiler instance for the inlinee InlineResult* compInlineResult; // The result of importing the inlinee method. bool compDoAggressiveInlining; // If true, mark every method as CORINFO_FLG_FORCEINLINE bool compJmpOpUsed; // Does the method do a JMP bool compLongUsed; // Does the method use TYP_LONG bool compFloatingPointUsed; // Does the method use TYP_FLOAT or TYP_DOUBLE bool compTailCallUsed; // Does the method do a tailcall bool compTailPrefixSeen; // Does the method IL have tail. prefix bool compLocallocSeen; // Does the method IL have localloc opcode bool compLocallocUsed; // Does the method use localloc. bool compLocallocOptimized; // Does the method have an optimized localloc bool compQmarkUsed; // Does the method use GT_QMARK/GT_COLON bool compQmarkRationalized; // Is it allowed to use a GT_QMARK/GT_COLON node. bool compUnsafeCastUsed; // Does the method use LDIND/STIND to cast between scalar/refernce types bool compHasBackwardJump; // Does the method (or some inlinee) have a lexically backwards jump? bool compHasBackwardJumpInHandler; // Does the method have a lexically backwards jump in a handler? bool compSwitchedToOptimized; // Codegen initially was Tier0 but jit switched to FullOpts bool compSwitchedToMinOpts; // Codegen initially was Tier1/FullOpts but jit switched to MinOpts bool compSuppressedZeroInit; // There are vars with lvSuppressedZeroInit set // NOTE: These values are only reliable after // the importing is completely finished. #ifdef DEBUG // State information - which phases have completed? // These are kept together for easy discoverability bool bRangeAllowStress; bool compCodeGenDone; int64_t compNumStatementLinksTraversed; // # of links traversed while doing debug checks bool fgNormalizeEHDone; // Has the flowgraph EH normalization phase been done? size_t compSizeEstimate; // The estimated size of the method as per `gtSetEvalOrder`. size_t compCycleEstimate; // The estimated cycle count of the method as per `gtSetEvalOrder` #endif // DEBUG bool fgLocalVarLivenessDone; // Note that this one is used outside of debug. bool fgLocalVarLivenessChanged; bool compLSRADone; bool compRationalIRForm; bool compUsesThrowHelper; // There is a call to a THROW_HELPER for the compiled method. bool compGeneratingProlog; bool compGeneratingEpilog; bool compNeedsGSSecurityCookie; // There is an unsafe buffer (or localloc) on the stack. // Insert cookie on frame and code to check the cookie, like VC++ -GS. bool compGSReorderStackLayout; // There is an unsafe buffer on the stack, reorder locals and make local // copies of susceptible parameters to avoid buffer overrun attacks through locals/params bool getNeedsGSSecurityCookie() const { return compNeedsGSSecurityCookie; } void setNeedsGSSecurityCookie() { compNeedsGSSecurityCookie = true; } FrameLayoutState lvaDoneFrameLayout; // The highest frame layout state that we've completed. During // frame layout calculations, this is the level we are currently // computing. //---------------------------- JITing options ----------------------------- enum codeOptimize { BLENDED_CODE, SMALL_CODE, FAST_CODE, COUNT_OPT_CODE }; struct Options { JitFlags* jitFlags; // all flags passed from the EE // The instruction sets that the compiler is allowed to emit. uint64_t compSupportsISA; // The instruction sets that were reported to the VM as being used by the current method. Subset of // compSupportsISA. uint64_t compSupportsISAReported; // The instruction sets that the compiler is allowed to take advantage of implicitly during optimizations. // Subset of compSupportsISA. // The instruction sets available in compSupportsISA and not available in compSupportsISAExactly can be only // used via explicit hardware intrinsics. uint64_t compSupportsISAExactly; void setSupportedISAs(CORINFO_InstructionSetFlags isas) { compSupportsISA = isas.GetFlagsRaw(); } unsigned compFlags; // method attributes unsigned instrCount; unsigned lvRefCount; codeOptimize compCodeOpt; // what type of code optimizations bool compUseCMOV; // optimize maximally and/or favor speed over size? #define DEFAULT_MIN_OPTS_CODE_SIZE 60000 #define DEFAULT_MIN_OPTS_INSTR_COUNT 20000 #define DEFAULT_MIN_OPTS_BB_COUNT 2000 #define DEFAULT_MIN_OPTS_LV_NUM_COUNT 2000 #define DEFAULT_MIN_OPTS_LV_REF_COUNT 8000 // Maximun number of locals before turning off the inlining #define MAX_LV_NUM_COUNT_FOR_INLINING 512 bool compMinOpts; bool compMinOptsIsSet; #ifdef DEBUG mutable bool compMinOptsIsUsed; bool MinOpts() const { assert(compMinOptsIsSet); compMinOptsIsUsed = true; return compMinOpts; } bool IsMinOptsSet() const { return compMinOptsIsSet; } #else // !DEBUG bool MinOpts() const { return compMinOpts; } bool IsMinOptsSet() const { return compMinOptsIsSet; } #endif // !DEBUG bool OptimizationDisabled() const { return MinOpts() || compDbgCode; } bool OptimizationEnabled() const { return !OptimizationDisabled(); } void SetMinOpts(bool val) { assert(!compMinOptsIsUsed); assert(!compMinOptsIsSet || (compMinOpts == val)); compMinOpts = val; compMinOptsIsSet = true; } // true if the CLFLG_* for an optimization is set. bool OptEnabled(unsigned optFlag) const { return !!(compFlags & optFlag); } #ifdef FEATURE_READYTORUN bool IsReadyToRun() const { return jitFlags->IsSet(JitFlags::JIT_FLAG_READYTORUN); } #else bool IsReadyToRun() const { return false; } #endif // Check if the compilation is control-flow guard enabled. bool IsCFGEnabled() const { #if defined(TARGET_ARM64) || defined(TARGET_AMD64) // On these platforms we assume the register that the target is // passed in is preserved by the validator and take care to get the // target from the register for the call (even in debug mode). static_assert_no_msg((RBM_VALIDATE_INDIRECT_CALL_TRASH & (1 << REG_VALIDATE_INDIRECT_CALL_ADDR)) == 0); if (JitConfig.JitForceControlFlowGuard()) return true; return jitFlags->IsSet(JitFlags::JIT_FLAG_ENABLE_CFG); #else // The remaining platforms are not supported and would require some // work to support. // // ARM32: // The ARM32 validator does not preserve any volatile registers // which means we have to take special care to allocate and use a // callee-saved register (reloading the target from memory is a // security issue). // // x86: // On x86 some VSD calls disassemble the call site and expect an // indirect call which is fundamentally incompatible with CFG. // This would require a different way to pass this information // through. // return false; #endif } #ifdef FEATURE_ON_STACK_REPLACEMENT bool IsOSR() const { return jitFlags->IsSet(JitFlags::JIT_FLAG_OSR); } #else bool IsOSR() const { return false; } #endif // true if we should use the PINVOKE_{BEGIN,END} helpers instead of generating // PInvoke transitions inline. Normally used by R2R, but also used when generating a reverse pinvoke frame, as // the current logic for frame setup initializes and pushes // the InlinedCallFrame before performing the Reverse PInvoke transition, which is invalid (as frames cannot // safely be pushed/popped while the thread is in a preemptive state.). bool ShouldUsePInvokeHelpers() { return jitFlags->IsSet(JitFlags::JIT_FLAG_USE_PINVOKE_HELPERS) || jitFlags->IsSet(JitFlags::JIT_FLAG_REVERSE_PINVOKE); } // true if we should use insert the REVERSE_PINVOKE_{ENTER,EXIT} helpers in the method // prolog/epilog bool IsReversePInvoke() { return jitFlags->IsSet(JitFlags::JIT_FLAG_REVERSE_PINVOKE); } bool compScopeInfo; // Generate the LocalVar info ? bool compDbgCode; // Generate debugger-friendly code? bool compDbgInfo; // Gather debugging info? bool compDbgEnC; #ifdef PROFILING_SUPPORTED bool compNoPInvokeInlineCB; #else static const bool compNoPInvokeInlineCB; #endif #ifdef DEBUG bool compGcChecks; // Check arguments and return values to ensure they are sane #endif #if defined(DEBUG) && defined(TARGET_XARCH) bool compStackCheckOnRet; // Check stack pointer on return to ensure it is correct. #endif // defined(DEBUG) && defined(TARGET_XARCH) #if defined(DEBUG) && defined(TARGET_X86) bool compStackCheckOnCall; // Check stack pointer after call to ensure it is correct. Only for x86. #endif // defined(DEBUG) && defined(TARGET_X86) bool compReloc; // Generate relocs for pointers in code, true for all ngen/prejit codegen #ifdef DEBUG #if defined(TARGET_XARCH) bool compEnablePCRelAddr; // Whether absolute addr be encoded as PC-rel offset by RyuJIT where possible #endif #endif // DEBUG #ifdef UNIX_AMD64_ABI // This flag is indicating if there is a need to align the frame. // On AMD64-Windows, if there are calls, 4 slots for the outgoing ars are allocated, except for // FastTailCall. This slots makes the frame size non-zero, so alignment logic will be called. // On AMD64-Unix, there are no such slots. There is a possibility to have calls in the method with frame size of // 0. The frame alignment logic won't kick in. This flags takes care of the AMD64-Unix case by remembering that // there are calls and making sure the frame alignment logic is executed. bool compNeedToAlignFrame; #endif // UNIX_AMD64_ABI bool compProcedureSplitting; // Separate cold code from hot code bool genFPorder; // Preserve FP order (operations are non-commutative) bool genFPopt; // Can we do frame-pointer-omission optimization? bool altJit; // True if we are an altjit and are compiling this method #ifdef OPT_CONFIG bool optRepeat; // Repeat optimizer phases k times #endif #ifdef DEBUG bool compProcedureSplittingEH; // Separate cold code from hot code for functions with EH bool dspCode; // Display native code generated bool dspEHTable; // Display the EH table reported to the VM bool dspDebugInfo; // Display the Debug info reported to the VM bool dspInstrs; // Display the IL instructions intermixed with the native code output bool dspLines; // Display source-code lines intermixed with native code output bool dmpHex; // Display raw bytes in hex of native code output bool varNames; // Display variables names in native code output bool disAsm; // Display native code as it is generated bool disAsmSpilled; // Display native code when any register spilling occurs bool disasmWithGC; // Display GC info interleaved with disassembly. bool disDiffable; // Makes the Disassembly code 'diff-able' bool disAddr; // Display process address next to each instruction in disassembly code bool disAlignment; // Display alignment boundaries in disassembly code bool disAsm2; // Display native code after it is generated using external disassembler bool dspOrder; // Display names of each of the methods that we ngen/jit bool dspUnwind; // Display the unwind info output bool dspDiffable; // Makes the Jit Dump 'diff-able' (currently uses same COMPlus_* flag as disDiffable) bool compLongAddress; // Force using large pseudo instructions for long address // (IF_LARGEJMP/IF_LARGEADR/IF_LARGLDC) bool dspGCtbls; // Display the GC tables #endif bool compExpandCallsEarly; // True if we should expand virtual call targets early for this method // Default numbers used to perform loop alignment. All the numbers are choosen // based on experimenting with various benchmarks. // Default minimum loop block weight required to enable loop alignment. #define DEFAULT_ALIGN_LOOP_MIN_BLOCK_WEIGHT 4 // By default a loop will be aligned at 32B address boundary to get better // performance as per architecture manuals. #define DEFAULT_ALIGN_LOOP_BOUNDARY 0x20 // For non-adaptive loop alignment, by default, only align a loop whose size is // at most 3 times the alignment block size. If the loop is bigger than that, it is most // likely complicated enough that loop alignment will not impact performance. #define DEFAULT_MAX_LOOPSIZE_FOR_ALIGN DEFAULT_ALIGN_LOOP_BOUNDARY * 3 #ifdef DEBUG // Loop alignment variables // If set, for non-adaptive alignment, ensure loop jmps are not on or cross alignment boundary. bool compJitAlignLoopForJcc; #endif // For non-adaptive alignment, minimum loop size (in bytes) for which alignment will be done. unsigned short compJitAlignLoopMaxCodeSize; // Minimum weight needed for the first block of a loop to make it a candidate for alignment. unsigned short compJitAlignLoopMinBlockWeight; // For non-adaptive alignment, address boundary (power of 2) at which loop alignment should // be done. By default, 32B. unsigned short compJitAlignLoopBoundary; // Padding limit to align a loop. unsigned short compJitAlignPaddingLimit; // If set, perform adaptive loop alignment that limits number of padding based on loop size. bool compJitAlignLoopAdaptive; // If set, tries to hide alignment instructions behind unconditional jumps. bool compJitHideAlignBehindJmp; #ifdef LATE_DISASM bool doLateDisasm; // Run the late disassembler #endif // LATE_DISASM #if DUMP_GC_TABLES && !defined(DEBUG) #pragma message("NOTE: this non-debug build has GC ptr table dumping always enabled!") static const bool dspGCtbls = true; #endif #ifdef PROFILING_SUPPORTED // Whether to emit Enter/Leave/TailCall hooks using a dummy stub (DummyProfilerELTStub()). // This option helps make the JIT behave as if it is running under a profiler. bool compJitELTHookEnabled; #endif // PROFILING_SUPPORTED #if FEATURE_TAILCALL_OPT // Whether opportunistic or implicit tail call optimization is enabled. bool compTailCallOpt; // Whether optimization of transforming a recursive tail call into a loop is enabled. bool compTailCallLoopOpt; #endif #if FEATURE_FASTTAILCALL // Whether fast tail calls are allowed. bool compFastTailCalls; #endif // FEATURE_FASTTAILCALL #if defined(TARGET_ARM64) // Decision about whether to save FP/LR registers with callee-saved registers (see // COMPlus_JitSaveFpLrWithCalleSavedRegisters). int compJitSaveFpLrWithCalleeSavedRegisters; #endif // defined(TARGET_ARM64) #ifdef CONFIGURABLE_ARM_ABI bool compUseSoftFP = false; #else #ifdef ARM_SOFTFP static const bool compUseSoftFP = true; #else // !ARM_SOFTFP static const bool compUseSoftFP = false; #endif // ARM_SOFTFP #endif // CONFIGURABLE_ARM_ABI } opts; static bool s_pAltJitExcludeAssembliesListInitialized; static AssemblyNamesList2* s_pAltJitExcludeAssembliesList; #ifdef DEBUG static bool s_pJitDisasmIncludeAssembliesListInitialized; static AssemblyNamesList2* s_pJitDisasmIncludeAssembliesList; static bool s_pJitFunctionFileInitialized; static MethodSet* s_pJitMethodSet; #endif // DEBUG #ifdef DEBUG // silence warning of cast to greater size. It is easier to silence than construct code the compiler is happy with, and // it is safe in this case #pragma warning(push) #pragma warning(disable : 4312) template <typename T> T dspPtr(T p) { return (p == ZERO) ? ZERO : (opts.dspDiffable ? T(0xD1FFAB1E) : p); } template <typename T> T dspOffset(T o) { return (o == ZERO) ? ZERO : (opts.dspDiffable ? T(0xD1FFAB1E) : o); } #pragma warning(pop) static int dspTreeID(GenTree* tree) { return tree->gtTreeID; } static void printStmtID(Statement* stmt) { assert(stmt != nullptr); printf(FMT_STMT, stmt->GetID()); } static void printTreeID(GenTree* tree) { if (tree == nullptr) { printf("[------]"); } else { printf("[%06d]", dspTreeID(tree)); } } const char* pgoSourceToString(ICorJitInfo::PgoSource p); const char* devirtualizationDetailToString(CORINFO_DEVIRTUALIZATION_DETAIL detail); #endif // DEBUG // clang-format off #define STRESS_MODES \ \ STRESS_MODE(NONE) \ \ /* "Variations" stress areas which we try to mix up with each other. */ \ /* These should not be exhaustively used as they might */ \ /* hide/trivialize other areas */ \ \ STRESS_MODE(REGS) \ STRESS_MODE(DBL_ALN) \ STRESS_MODE(LCL_FLDS) \ STRESS_MODE(UNROLL_LOOPS) \ STRESS_MODE(MAKE_CSE) \ STRESS_MODE(LEGACY_INLINE) \ STRESS_MODE(CLONE_EXPR) \ STRESS_MODE(USE_CMOV) \ STRESS_MODE(FOLD) \ STRESS_MODE(MERGED_RETURNS) \ STRESS_MODE(BB_PROFILE) \ STRESS_MODE(OPT_BOOLS_GC) \ STRESS_MODE(REMORPH_TREES) \ STRESS_MODE(64RSLT_MUL) \ STRESS_MODE(DO_WHILE_LOOPS) \ STRESS_MODE(MIN_OPTS) \ STRESS_MODE(REVERSE_FLAG) /* Will set GTF_REVERSE_OPS whenever we can */ \ STRESS_MODE(REVERSE_COMMA) /* Will reverse commas created with gtNewCommaNode */ \ STRESS_MODE(TAILCALL) /* Will make the call as a tailcall whenever legal */ \ STRESS_MODE(CATCH_ARG) /* Will spill catch arg */ \ STRESS_MODE(UNSAFE_BUFFER_CHECKS) \ STRESS_MODE(NULL_OBJECT_CHECK) \ STRESS_MODE(PINVOKE_RESTORE_ESP) \ STRESS_MODE(RANDOM_INLINE) \ STRESS_MODE(SWITCH_CMP_BR_EXPANSION) \ STRESS_MODE(GENERIC_VARN) \ STRESS_MODE(PROFILER_CALLBACKS) /* Will generate profiler hooks for ELT callbacks */ \ STRESS_MODE(BYREF_PROMOTION) /* Change undoPromotion decisions for byrefs */ \ STRESS_MODE(PROMOTE_FEWER_STRUCTS)/* Don't promote some structs that can be promoted */ \ STRESS_MODE(VN_BUDGET)/* Randomize the VN budget */ \ \ /* After COUNT_VARN, stress level 2 does all of these all the time */ \ \ STRESS_MODE(COUNT_VARN) \ \ /* "Check" stress areas that can be exhaustively used if we */ \ /* dont care about performance at all */ \ \ STRESS_MODE(FORCE_INLINE) /* Treat every method as AggressiveInlining */ \ STRESS_MODE(CHK_FLOW_UPDATE) \ STRESS_MODE(EMITTER) \ STRESS_MODE(CHK_REIMPORT) \ STRESS_MODE(FLATFP) \ STRESS_MODE(GENERIC_CHECK) \ STRESS_MODE(COUNT) enum compStressArea { #define STRESS_MODE(mode) STRESS_##mode, STRESS_MODES #undef STRESS_MODE }; // clang-format on #ifdef DEBUG static const LPCWSTR s_compStressModeNames[STRESS_COUNT + 1]; BYTE compActiveStressModes[STRESS_COUNT]; #endif // DEBUG #define MAX_STRESS_WEIGHT 100 bool compStressCompile(compStressArea stressArea, unsigned weightPercentage); bool compStressCompileHelper(compStressArea stressArea, unsigned weightPercentage); #ifdef DEBUG bool compInlineStress() { return compStressCompile(STRESS_LEGACY_INLINE, 50); } bool compRandomInlineStress() { return compStressCompile(STRESS_RANDOM_INLINE, 50); } bool compPromoteFewerStructs(unsigned lclNum); #endif // DEBUG bool compTailCallStress() { #ifdef DEBUG // Do not stress tailcalls in IL stubs as the runtime creates several IL // stubs to implement the tailcall mechanism, which would then // recursively create more IL stubs. return !opts.jitFlags->IsSet(JitFlags::JIT_FLAG_IL_STUB) && (JitConfig.TailcallStress() != 0 || compStressCompile(STRESS_TAILCALL, 5)); #else return false; #endif } const char* compGetTieringName(bool wantShortName = false) const; const char* compGetStressMessage() const; codeOptimize compCodeOpt() const { #if 0 // Switching between size & speed has measurable throughput impact // (3.5% on NGen CoreLib when measured). It used to be enabled for // DEBUG, but should generate identical code between CHK & RET builds, // so that's not acceptable. // TODO-Throughput: Figure out what to do about size vs. speed & throughput. // Investigate the cause of the throughput regression. return opts.compCodeOpt; #else return BLENDED_CODE; #endif } //--------------------- Info about the procedure -------------------------- struct Info { COMP_HANDLE compCompHnd; CORINFO_MODULE_HANDLE compScopeHnd; CORINFO_CLASS_HANDLE compClassHnd; CORINFO_METHOD_HANDLE compMethodHnd; CORINFO_METHOD_INFO* compMethodInfo; bool hasCircularClassConstraints; bool hasCircularMethodConstraints; #if defined(DEBUG) || defined(LATE_DISASM) || DUMP_FLOWGRAPHS const char* compMethodName; const char* compClassName; const char* compFullName; double compPerfScore; int compMethodSuperPMIIndex; // useful when debugging under SuperPMI #endif // defined(DEBUG) || defined(LATE_DISASM) || DUMP_FLOWGRAPHS #if defined(DEBUG) || defined(INLINE_DATA) // Method hash is logically const, but computed // on first demand. mutable unsigned compMethodHashPrivate; unsigned compMethodHash() const; #endif // defined(DEBUG) || defined(INLINE_DATA) #ifdef PSEUDORANDOM_NOP_INSERTION // things for pseudorandom nop insertion unsigned compChecksum; CLRRandom compRNG; #endif // The following holds the FLG_xxxx flags for the method we're compiling. unsigned compFlags; // The following holds the class attributes for the method we're compiling. unsigned compClassAttr; const BYTE* compCode; IL_OFFSET compILCodeSize; // The IL code size IL_OFFSET compILImportSize; // Estimated amount of IL actually imported IL_OFFSET compILEntry; // The IL entry point (normally 0) PatchpointInfo* compPatchpointInfo; // Patchpoint data for OSR (normally nullptr) UNATIVE_OFFSET compNativeCodeSize; // The native code size, after instructions are issued. This // is less than (compTotalHotCodeSize + compTotalColdCodeSize) only if: // (1) the code is not hot/cold split, and we issued less code than we expected, or // (2) the code is hot/cold split, and we issued less code than we expected // in the cold section (the hot section will always be padded out to compTotalHotCodeSize). bool compIsStatic : 1; // Is the method static (no 'this' pointer)? bool compIsVarArgs : 1; // Does the method have varargs parameters? bool compInitMem : 1; // Is the CORINFO_OPT_INIT_LOCALS bit set in the method info options? bool compProfilerCallback : 1; // JIT inserted a profiler Enter callback bool compPublishStubParam : 1; // EAX captured in prolog will be available through an intrinsic bool compHasNextCallRetAddr : 1; // The NextCallReturnAddress intrinsic is used. var_types compRetType; // Return type of the method as declared in IL var_types compRetNativeType; // Normalized return type as per target arch ABI unsigned compILargsCount; // Number of arguments (incl. implicit but not hidden) unsigned compArgsCount; // Number of arguments (incl. implicit and hidden) #if FEATURE_FASTTAILCALL unsigned compArgStackSize; // Incoming argument stack size in bytes #endif // FEATURE_FASTTAILCALL unsigned compRetBuffArg; // position of hidden return param var (0, 1) (BAD_VAR_NUM means not present); int compTypeCtxtArg; // position of hidden param for type context for generic code (CORINFO_CALLCONV_PARAMTYPE) unsigned compThisArg; // position of implicit this pointer param (not to be confused with lvaArg0Var) unsigned compILlocalsCount; // Number of vars : args + locals (incl. implicit but not hidden) unsigned compLocalsCount; // Number of vars : args + locals (incl. implicit and hidden) unsigned compMaxStack; UNATIVE_OFFSET compTotalHotCodeSize; // Total number of bytes of Hot Code in the method UNATIVE_OFFSET compTotalColdCodeSize; // Total number of bytes of Cold Code in the method unsigned compUnmanagedCallCountWithGCTransition; // count of unmanaged calls with GC transition. CorInfoCallConvExtension compCallConv; // The entry-point calling convention for this method. unsigned compLvFrameListRoot; // lclNum for the Frame root unsigned compXcptnsCount; // Number of exception-handling clauses read in the method's IL. // You should generally use compHndBBtabCount instead: it is the // current number of EH clauses (after additions like synchronized // methods and funclets, and removals like unreachable code deletion). Target::ArgOrder compArgOrder; bool compMatchedVM; // true if the VM is "matched": either the JIT is a cross-compiler // and the VM expects that, or the JIT is a "self-host" compiler // (e.g., x86 hosted targeting x86) and the VM expects that. /* The following holds IL scope information about local variables. */ unsigned compVarScopesCount; VarScopeDsc* compVarScopes; /* The following holds information about instr offsets for * which we need to report IP-mappings */ IL_OFFSET* compStmtOffsets; // sorted unsigned compStmtOffsetsCount; ICorDebugInfo::BoundaryTypes compStmtOffsetsImplicit; #define CPU_X86 0x0100 // The generic X86 CPU #define CPU_X86_PENTIUM_4 0x0110 #define CPU_X64 0x0200 // The generic x64 CPU #define CPU_AMD_X64 0x0210 // AMD x64 CPU #define CPU_INTEL_X64 0x0240 // Intel x64 CPU #define CPU_ARM 0x0300 // The generic ARM CPU #define CPU_ARM64 0x0400 // The generic ARM64 CPU unsigned genCPU; // What CPU are we running on // Number of class profile probes in this method unsigned compClassProbeCount; } info; // Returns true if the method being compiled returns a non-void and non-struct value. // Note that lvaInitTypeRef() normalizes compRetNativeType for struct returns in a // single register as per target arch ABI (e.g on Amd64 Windows structs of size 1, 2, // 4 or 8 gets normalized to TYP_BYTE/TYP_SHORT/TYP_INT/TYP_LONG; On Arm HFA structs). // Methods returning such structs are considered to return non-struct return value and // this method returns true in that case. bool compMethodReturnsNativeScalarType() { return (info.compRetType != TYP_VOID) && !varTypeIsStruct(info.compRetNativeType); } // Returns true if the method being compiled returns RetBuf addr as its return value bool compMethodReturnsRetBufAddr() { // There are cases where implicit RetBuf argument should be explicitly returned in a register. // In such cases the return type is changed to TYP_BYREF and appropriate IR is generated. // These cases are: CLANG_FORMAT_COMMENT_ANCHOR; #ifdef TARGET_AMD64 // 1. on x64 Windows and Unix the address of RetBuf needs to be returned by // methods with hidden RetBufArg in RAX. In such case GT_RETURN is of TYP_BYREF, // returning the address of RetBuf. return (info.compRetBuffArg != BAD_VAR_NUM); #else // TARGET_AMD64 #ifdef PROFILING_SUPPORTED // 2. Profiler Leave callback expects the address of retbuf as return value for // methods with hidden RetBuf argument. impReturnInstruction() when profiler // callbacks are needed creates GT_RETURN(TYP_BYREF, op1 = Addr of RetBuf) for // methods with hidden RetBufArg. if (compIsProfilerHookNeeded()) { return (info.compRetBuffArg != BAD_VAR_NUM); } #endif // 3. Windows ARM64 native instance calling convention requires the address of RetBuff // to be returned in x0. CLANG_FORMAT_COMMENT_ANCHOR; #if defined(TARGET_ARM64) if (TargetOS::IsWindows) { auto callConv = info.compCallConv; if (callConvIsInstanceMethodCallConv(callConv)) { return (info.compRetBuffArg != BAD_VAR_NUM); } } #endif // TARGET_ARM64 // 4. x86 unmanaged calling conventions require the address of RetBuff to be returned in eax. CLANG_FORMAT_COMMENT_ANCHOR; #if defined(TARGET_X86) if (info.compCallConv != CorInfoCallConvExtension::Managed) { return (info.compRetBuffArg != BAD_VAR_NUM); } #endif return false; #endif // TARGET_AMD64 } // Returns true if the method returns a value in more than one return register // TODO-ARM-Bug: Deal with multi-register genReturnLocaled structs? // TODO-ARM64: Does this apply for ARM64 too? bool compMethodReturnsMultiRegRetType() { #if FEATURE_MULTIREG_RET #if defined(TARGET_X86) // On x86, 64-bit longs and structs are returned in multiple registers return varTypeIsLong(info.compRetNativeType) || (varTypeIsStruct(info.compRetNativeType) && (info.compRetBuffArg == BAD_VAR_NUM)); #else // targets: X64-UNIX, ARM64 or ARM32 // On all other targets that support multireg return values: // Methods returning a struct in multiple registers have a return value of TYP_STRUCT. // Such method's compRetNativeType is TYP_STRUCT without a hidden RetBufArg return varTypeIsStruct(info.compRetNativeType) && (info.compRetBuffArg == BAD_VAR_NUM); #endif // TARGET_XXX #else // not FEATURE_MULTIREG_RET // For this architecture there are no multireg returns return false; #endif // FEATURE_MULTIREG_RET } bool compEnregLocals() { return ((opts.compFlags & CLFLG_REGVAR) != 0); } bool compEnregStructLocals() { return (JitConfig.JitEnregStructLocals() != 0); } bool compObjectStackAllocation() { return (JitConfig.JitObjectStackAllocation() != 0); } // Returns true if the method returns a value in more than one return register, // it should replace/be merged with compMethodReturnsMultiRegRetType when #36868 is fixed. // The difference from original `compMethodReturnsMultiRegRetType` is in ARM64 SIMD* handling, // this method correctly returns false for it (it is passed as HVA), when the original returns true. bool compMethodReturnsMultiRegRegTypeAlternate() { #if FEATURE_MULTIREG_RET #if defined(TARGET_X86) // On x86, 64-bit longs and structs are returned in multiple registers return varTypeIsLong(info.compRetNativeType) || (varTypeIsStruct(info.compRetNativeType) && (info.compRetBuffArg == BAD_VAR_NUM)); #else // targets: X64-UNIX, ARM64 or ARM32 #if defined(TARGET_ARM64) // TYP_SIMD* are returned in one register. if (varTypeIsSIMD(info.compRetNativeType)) { return false; } #endif // On all other targets that support multireg return values: // Methods returning a struct in multiple registers have a return value of TYP_STRUCT. // Such method's compRetNativeType is TYP_STRUCT without a hidden RetBufArg return varTypeIsStruct(info.compRetNativeType) && (info.compRetBuffArg == BAD_VAR_NUM); #endif // TARGET_XXX #else // not FEATURE_MULTIREG_RET // For this architecture there are no multireg returns return false; #endif // FEATURE_MULTIREG_RET } // Returns true if the method being compiled returns a value bool compMethodHasRetVal() { return compMethodReturnsNativeScalarType() || compMethodReturnsRetBufAddr() || compMethodReturnsMultiRegRetType(); } // Returns true if the method requires a PInvoke prolog and epilog bool compMethodRequiresPInvokeFrame() { return (info.compUnmanagedCallCountWithGCTransition > 0); } // Returns true if address-exposed user variables should be poisoned with a recognizable value bool compShouldPoisonFrame() { #ifdef FEATURE_ON_STACK_REPLACEMENT if (opts.IsOSR()) return false; #endif return !info.compInitMem && opts.compDbgCode; } // Returns true if the jit supports having patchpoints in this method. // Optionally, get the reason why not. bool compCanHavePatchpoints(const char** reason = nullptr); #if defined(DEBUG) void compDispLocalVars(); #endif // DEBUG private: class ClassLayoutTable* m_classLayoutTable; class ClassLayoutTable* typCreateClassLayoutTable(); class ClassLayoutTable* typGetClassLayoutTable(); public: // Get the layout having the specified layout number. ClassLayout* typGetLayoutByNum(unsigned layoutNum); // Get the layout number of the specified layout. unsigned typGetLayoutNum(ClassLayout* layout); // Get the layout having the specified size but no class handle. ClassLayout* typGetBlkLayout(unsigned blockSize); // Get the number of a layout having the specified size but no class handle. unsigned typGetBlkLayoutNum(unsigned blockSize); // Get the layout for the specified class handle. ClassLayout* typGetObjLayout(CORINFO_CLASS_HANDLE classHandle); // Get the number of a layout for the specified class handle. unsigned typGetObjLayoutNum(CORINFO_CLASS_HANDLE classHandle); //-------------------------- Global Compiler Data ------------------------------------ #ifdef DEBUG private: static LONG s_compMethodsCount; // to produce unique label names #endif public: #ifdef DEBUG LONG compMethodID; unsigned compGenTreeID; unsigned compStatementID; unsigned compBasicBlockID; #endif BasicBlock* compCurBB; // the current basic block in process Statement* compCurStmt; // the current statement in process GenTree* compCurTree; // the current tree in process // The following is used to create the 'method JIT info' block. size_t compInfoBlkSize; BYTE* compInfoBlkAddr; EHblkDsc* compHndBBtab; // array of EH data unsigned compHndBBtabCount; // element count of used elements in EH data array unsigned compHndBBtabAllocCount; // element count of allocated elements in EH data array #if defined(TARGET_X86) //------------------------------------------------------------------------- // Tracking of region covered by the monitor in synchronized methods void* syncStartEmitCookie; // the emitter cookie for first instruction after the call to MON_ENTER void* syncEndEmitCookie; // the emitter cookie for first instruction after the call to MON_EXIT #endif // !TARGET_X86 Phases mostRecentlyActivePhase; // the most recently active phase PhaseChecks activePhaseChecks; // the currently active phase checks //------------------------------------------------------------------------- // The following keeps track of how many bytes of local frame space we've // grabbed so far in the current function, and how many argument bytes we // need to pop when we return. // unsigned compLclFrameSize; // secObject+lclBlk+locals+temps // Count of callee-saved regs we pushed in the prolog. // Does not include EBP for isFramePointerUsed() and double-aligned frames. // In case of Amd64 this doesn't include float regs saved on stack. unsigned compCalleeRegsPushed; #if defined(TARGET_XARCH) // Mask of callee saved float regs on stack. regMaskTP compCalleeFPRegsSavedMask; #endif #ifdef TARGET_AMD64 // Quirk for VS debug-launch scenario to work: // Bytes of padding between save-reg area and locals. #define VSQUIRK_STACK_PAD (2 * REGSIZE_BYTES) unsigned compVSQuirkStackPaddingNeeded; #endif unsigned compArgSize; // total size of arguments in bytes (including register args (lvIsRegArg)) unsigned compMapILargNum(unsigned ILargNum); // map accounting for hidden args unsigned compMapILvarNum(unsigned ILvarNum); // map accounting for hidden args unsigned compMap2ILvarNum(unsigned varNum) const; // map accounting for hidden args #if defined(TARGET_ARM64) struct FrameInfo { // Frame type (1-5) int frameType; // Distance from established (method body) SP to base of callee save area int calleeSaveSpOffset; // Amount to subtract from SP before saving (prolog) OR // to add to SP after restoring (epilog) callee saves int calleeSaveSpDelta; // Distance from established SP to where caller's FP was saved int offsetSpToSavedFp; } compFrameInfo; #endif //------------------------------------------------------------------------- static void compStartup(); // One-time initialization static void compShutdown(); // One-time finalization void compInit(ArenaAllocator* pAlloc, CORINFO_METHOD_HANDLE methodHnd, COMP_HANDLE compHnd, CORINFO_METHOD_INFO* methodInfo, InlineInfo* inlineInfo); void compDone(); static void compDisplayStaticSizes(FILE* fout); //------------ Some utility functions -------------- void* compGetHelperFtn(CorInfoHelpFunc ftnNum, /* IN */ void** ppIndirection); /* OUT */ // Several JIT/EE interface functions return a CorInfoType, and also return a // class handle as an out parameter if the type is a value class. Returns the // size of the type these describe. unsigned compGetTypeSize(CorInfoType cit, CORINFO_CLASS_HANDLE clsHnd); // Returns true if the method being compiled has a return buffer. bool compHasRetBuffArg(); #ifdef DEBUG // Components used by the compiler may write unit test suites, and // have them run within this method. They will be run only once per process, and only // in debug. (Perhaps should be under the control of a COMPlus_ flag.) // These should fail by asserting. void compDoComponentUnitTestsOnce(); #endif // DEBUG int compCompile(CORINFO_MODULE_HANDLE classPtr, void** methodCodePtr, uint32_t* methodCodeSize, JitFlags* compileFlags); void compCompileFinish(); int compCompileHelper(CORINFO_MODULE_HANDLE classPtr, COMP_HANDLE compHnd, CORINFO_METHOD_INFO* methodInfo, void** methodCodePtr, uint32_t* methodCodeSize, JitFlags* compileFlag); ArenaAllocator* compGetArenaAllocator(); void generatePatchpointInfo(); #if MEASURE_MEM_ALLOC static bool s_dspMemStats; // Display per-phase memory statistics for every function #endif // MEASURE_MEM_ALLOC #if LOOP_HOIST_STATS unsigned m_loopsConsidered; bool m_curLoopHasHoistedExpression; unsigned m_loopsWithHoistedExpressions; unsigned m_totalHoistedExpressions; void AddLoopHoistStats(); void PrintPerMethodLoopHoistStats(); static CritSecObject s_loopHoistStatsLock; // This lock protects the data structures below. static unsigned s_loopsConsidered; static unsigned s_loopsWithHoistedExpressions; static unsigned s_totalHoistedExpressions; static void PrintAggregateLoopHoistStats(FILE* f); #endif // LOOP_HOIST_STATS #if TRACK_ENREG_STATS class EnregisterStats { private: unsigned m_totalNumberOfVars; unsigned m_totalNumberOfStructVars; unsigned m_totalNumberOfEnregVars; unsigned m_totalNumberOfStructEnregVars; unsigned m_addrExposed; unsigned m_VMNeedsStackAddr; unsigned m_localField; unsigned m_blockOp; unsigned m_dontEnregStructs; unsigned m_notRegSizeStruct; unsigned m_structArg; unsigned m_lclAddrNode; unsigned m_castTakesAddr; unsigned m_storeBlkSrc; unsigned m_oneAsgRetyping; unsigned m_swizzleArg; unsigned m_blockOpRet; unsigned m_returnSpCheck; unsigned m_simdUserForcesDep; unsigned m_liveInOutHndlr; unsigned m_depField; unsigned m_noRegVars; unsigned m_minOptsGC; #ifdef JIT32_GCENCODER unsigned m_PinningRef; #endif // JIT32_GCENCODER #if !defined(TARGET_64BIT) unsigned m_longParamField; #endif // !TARGET_64BIT unsigned m_parentExposed; unsigned m_tooConservative; unsigned m_escapeAddress; unsigned m_osrExposed; unsigned m_stressLclFld; unsigned m_copyFldByFld; unsigned m_dispatchRetBuf; unsigned m_wideIndir; public: void RecordLocal(const LclVarDsc* varDsc); void Dump(FILE* fout) const; }; static EnregisterStats s_enregisterStats; #endif // TRACK_ENREG_STATS bool compIsForImportOnly(); bool compIsForInlining() const; bool compDonotInline(); #ifdef DEBUG // Get the default fill char value we randomize this value when JitStress is enabled. static unsigned char compGetJitDefaultFill(Compiler* comp); const char* compLocalVarName(unsigned varNum, unsigned offs); VarName compVarName(regNumber reg, bool isFloatReg = false); const char* compRegVarName(regNumber reg, bool displayVar = false, bool isFloatReg = false); const char* compRegNameForSize(regNumber reg, size_t size); const char* compFPregVarName(unsigned fpReg, bool displayVar = false); void compDspSrcLinesByNativeIP(UNATIVE_OFFSET curIP); void compDspSrcLinesByLineNum(unsigned line, bool seek = false); #endif // DEBUG //------------------------------------------------------------------------- struct VarScopeListNode { VarScopeDsc* data; VarScopeListNode* next; static VarScopeListNode* Create(VarScopeDsc* value, CompAllocator alloc) { VarScopeListNode* node = new (alloc) VarScopeListNode; node->data = value; node->next = nullptr; return node; } }; struct VarScopeMapInfo { VarScopeListNode* head; VarScopeListNode* tail; static VarScopeMapInfo* Create(VarScopeListNode* node, CompAllocator alloc) { VarScopeMapInfo* info = new (alloc) VarScopeMapInfo; info->head = node; info->tail = node; return info; } }; // Max value of scope count for which we would use linear search; for larger values we would use hashtable lookup. static const unsigned MAX_LINEAR_FIND_LCL_SCOPELIST = 32; typedef JitHashTable<unsigned, JitSmallPrimitiveKeyFuncs<unsigned>, VarScopeMapInfo*> VarNumToScopeDscMap; // Map to keep variables' scope indexed by varNum containing it's scope dscs at the index. VarNumToScopeDscMap* compVarScopeMap; VarScopeDsc* compFindLocalVar(unsigned varNum, unsigned lifeBeg, unsigned lifeEnd); VarScopeDsc* compFindLocalVar(unsigned varNum, unsigned offs); VarScopeDsc* compFindLocalVarLinear(unsigned varNum, unsigned offs); void compInitVarScopeMap(); VarScopeDsc** compEnterScopeList; // List has the offsets where variables // enter scope, sorted by instr offset unsigned compNextEnterScope; VarScopeDsc** compExitScopeList; // List has the offsets where variables // go out of scope, sorted by instr offset unsigned compNextExitScope; void compInitScopeLists(); void compResetScopeLists(); VarScopeDsc* compGetNextEnterScope(unsigned offs, bool scan = false); VarScopeDsc* compGetNextExitScope(unsigned offs, bool scan = false); void compProcessScopesUntil(unsigned offset, VARSET_TP* inScope, void (Compiler::*enterScopeFn)(VARSET_TP* inScope, VarScopeDsc*), void (Compiler::*exitScopeFn)(VARSET_TP* inScope, VarScopeDsc*)); #ifdef DEBUG void compDispScopeLists(); #endif // DEBUG bool compIsProfilerHookNeeded(); //------------------------------------------------------------------------- /* Statistical Data Gathering */ void compJitStats(); // call this function and enable // various ifdef's below for statistical data #if CALL_ARG_STATS void compCallArgStats(); static void compDispCallArgStats(FILE* fout); #endif //------------------------------------------------------------------------- protected: #ifdef DEBUG bool skipMethod(); #endif ArenaAllocator* compArenaAllocator; public: void compFunctionTraceStart(); void compFunctionTraceEnd(void* methodCodePtr, ULONG methodCodeSize, bool isNYI); protected: size_t compMaxUncheckedOffsetForNullObject; void compInitOptions(JitFlags* compileFlags); void compSetProcessor(); void compInitDebuggingInfo(); void compSetOptimizationLevel(); #ifdef TARGET_ARMARCH bool compRsvdRegCheck(FrameLayoutState curState); #endif void compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFlags* compileFlags); // Clear annotations produced during optimizations; to be used between iterations when repeating opts. void ResetOptAnnotations(); // Regenerate loop descriptors; to be used between iterations when repeating opts. void RecomputeLoopInfo(); #ifdef PROFILING_SUPPORTED // Data required for generating profiler Enter/Leave/TailCall hooks bool compProfilerHookNeeded; // Whether profiler Enter/Leave/TailCall hook needs to be generated for the method void* compProfilerMethHnd; // Profiler handle of the method being compiled. Passed as param to ELT callbacks bool compProfilerMethHndIndirected; // Whether compProfilerHandle is pointer to the handle or is an actual handle #endif public: // Assumes called as part of process shutdown; does any compiler-specific work associated with that. static void ProcessShutdownWork(ICorStaticInfo* statInfo); CompAllocator getAllocator(CompMemKind cmk = CMK_Generic) { return CompAllocator(compArenaAllocator, cmk); } CompAllocator getAllocatorGC() { return getAllocator(CMK_GC); } CompAllocator getAllocatorLoopHoist() { return getAllocator(CMK_LoopHoist); } #ifdef DEBUG CompAllocator getAllocatorDebugOnly() { return getAllocator(CMK_DebugOnly); } #endif // DEBUG /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX typeInfo XX XX XX XX Checks for type compatibility and merges types XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ public: // Returns true if child is equal to or a subtype of parent for merge purposes // This support is necessary to suport attributes that are not described in // for example, signatures. For example, the permanent home byref (byref that // points to the gc heap), isn't a property of method signatures, therefore, // it is safe to have mismatches here (that tiCompatibleWith will not flag), // but when deciding if we need to reimport a block, we need to take these // in account bool tiMergeCompatibleWith(const typeInfo& pChild, const typeInfo& pParent, bool normalisedForStack) const; // Returns true if child is equal to or a subtype of parent. // normalisedForStack indicates that both types are normalised for the stack bool tiCompatibleWith(const typeInfo& pChild, const typeInfo& pParent, bool normalisedForStack) const; // Merges pDest and pSrc. Returns false if merge is undefined. // *pDest is modified to represent the merged type. Sets "*changed" to true // if this changes "*pDest". bool tiMergeToCommonParent(typeInfo* pDest, const typeInfo* pSrc, bool* changed) const; /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX IL verification stuff XX XX XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ public: // The following is used to track liveness of local variables, initialization // of valueclass constructors, and type safe use of IL instructions. // dynamic state info needed for verification EntryState verCurrentState; // this ptr of object type .ctors are considered intited only after // the base class ctor is called, or an alternate ctor is called. // An uninited this ptr can be used to access fields, but cannot // be used to call a member function. bool verTrackObjCtorInitState; void verInitBBEntryState(BasicBlock* block, EntryState* currentState); // Requires that "tis" is not TIS_Bottom -- it's a definite init/uninit state. void verSetThisInit(BasicBlock* block, ThisInitState tis); void verInitCurrentState(); void verResetCurrentState(BasicBlock* block, EntryState* currentState); // Merges the current verification state into the entry state of "block", return false if that merge fails, // TRUE if it succeeds. Further sets "*changed" to true if this changes the entry state of "block". bool verMergeEntryStates(BasicBlock* block, bool* changed); void verConvertBBToThrowVerificationException(BasicBlock* block DEBUGARG(bool logMsg)); void verHandleVerificationFailure(BasicBlock* block DEBUGARG(bool logMsg)); typeInfo verMakeTypeInfo(CORINFO_CLASS_HANDLE clsHnd, bool bashStructToRef = false); // converts from jit type representation to typeInfo typeInfo verMakeTypeInfo(CorInfoType ciType, CORINFO_CLASS_HANDLE clsHnd); // converts from jit type representation to typeInfo bool verIsSDArray(const typeInfo& ti); typeInfo verGetArrayElemType(const typeInfo& ti); typeInfo verParseArgSigToTypeInfo(CORINFO_SIG_INFO* sig, CORINFO_ARG_LIST_HANDLE args); bool verIsByRefLike(const typeInfo& ti); bool verIsSafeToReturnByRef(const typeInfo& ti); // generic type variables range over types that satisfy IsBoxable bool verIsBoxable(const typeInfo& ti); void DECLSPEC_NORETURN verRaiseVerifyException(INDEBUG(const char* reason) DEBUGARG(const char* file) DEBUGARG(unsigned line)); void verRaiseVerifyExceptionIfNeeded(INDEBUG(const char* reason) DEBUGARG(const char* file) DEBUGARG(unsigned line)); bool verCheckTailCallConstraint(OPCODE opcode, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken, // Is this a "constrained." call // on a type parameter? bool speculative // If true, won't throw if verificatoin fails. Instead it will // return false to the caller. // If false, it will throw. ); bool verIsBoxedValueType(const typeInfo& ti); void verVerifyCall(OPCODE opcode, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken, bool tailCall, bool readonlyCall, // is this a "readonly." call? const BYTE* delegateCreateStart, const BYTE* codeAddr, CORINFO_CALL_INFO* callInfo DEBUGARG(const char* methodName)); bool verCheckDelegateCreation(const BYTE* delegateCreateStart, const BYTE* codeAddr, mdMemberRef& targetMemberRef); typeInfo verVerifySTIND(const typeInfo& ptr, const typeInfo& value, const typeInfo& instrType); typeInfo verVerifyLDIND(const typeInfo& ptr, const typeInfo& instrType); void verVerifyField(CORINFO_RESOLVED_TOKEN* pResolvedToken, const CORINFO_FIELD_INFO& fieldInfo, const typeInfo* tiThis, bool mutator, bool allowPlainStructAsThis = false); void verVerifyCond(const typeInfo& tiOp1, const typeInfo& tiOp2, unsigned opcode); void verVerifyThisPtrInitialised(); bool verIsCallToInitThisPtr(CORINFO_CLASS_HANDLE context, CORINFO_CLASS_HANDLE target); #ifdef DEBUG // One line log function. Default level is 0. Increasing it gives you // more log information // levels are currently unused: #define JITDUMP(level,...) (); void JitLogEE(unsigned level, const char* fmt, ...); bool compDebugBreak; bool compJitHaltMethod(); #endif /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX GS Security checks for unsafe buffers XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ public: struct ShadowParamVarInfo { FixedBitVect* assignGroup; // the closure set of variables whose values depend on each other unsigned shadowCopy; // Lcl var num, if not valid set to BAD_VAR_NUM static bool mayNeedShadowCopy(LclVarDsc* varDsc) { #if defined(TARGET_AMD64) // GS cookie logic to create shadow slots, create trees to copy reg args to shadow // slots and update all trees to refer to shadow slots is done immediately after // fgMorph(). Lsra could potentially mark a param as DoNotEnregister after JIT determines // not to shadow a parameter. Also, LSRA could potentially spill a param which is passed // in register. Therefore, conservatively all params may need a shadow copy. Note that // GS cookie logic further checks whether the param is a ptr or an unsafe buffer before // creating a shadow slot even though this routine returns true. // // TODO-AMD64-CQ: Revisit this conservative approach as it could create more shadow slots than // required. There are two cases under which a reg arg could potentially be used from its // home location: // a) LSRA marks it as DoNotEnregister (see LinearScan::identifyCandidates()) // b) LSRA spills it // // Possible solution to address case (a) // - The conditions under which LSRA marks a varDsc as DoNotEnregister could be checked // in this routine. Note that live out of exception handler is something we may not be // able to do it here since GS cookie logic is invoked ahead of liveness computation. // Therefore, for methods with exception handling and need GS cookie check we might have // to take conservative approach. // // Possible solution to address case (b) // - Whenver a parameter passed in an argument register needs to be spilled by LSRA, we // create a new spill temp if the method needs GS cookie check. return varDsc->lvIsParam; #else // !defined(TARGET_AMD64) return varDsc->lvIsParam && !varDsc->lvIsRegArg; #endif } #ifdef DEBUG void Print() { printf("assignGroup [%p]; shadowCopy: [%d];\n", assignGroup, shadowCopy); } #endif }; GSCookie* gsGlobalSecurityCookieAddr; // Address of global cookie for unsafe buffer checks GSCookie gsGlobalSecurityCookieVal; // Value of global cookie if addr is NULL ShadowParamVarInfo* gsShadowVarInfo; // Table used by shadow param analysis code void gsGSChecksInitCookie(); // Grabs cookie variable void gsCopyShadowParams(); // Identify vulnerable params and create dhadow copies bool gsFindVulnerableParams(); // Shadow param analysis code void gsParamsToShadows(); // Insert copy code and replave param uses by shadow static fgWalkPreFn gsMarkPtrsAndAssignGroups; // Shadow param analysis tree-walk static fgWalkPreFn gsReplaceShadowParams; // Shadow param replacement tree-walk #define DEFAULT_MAX_INLINE_SIZE 100 // Methods with > DEFAULT_MAX_INLINE_SIZE IL bytes will never be inlined. // This can be overwritten by setting complus_JITInlineSize env variable. #define DEFAULT_MAX_INLINE_DEPTH 20 // Methods at more than this level deep will not be inlined #define DEFAULT_MAX_LOCALLOC_TO_LOCAL_SIZE 32 // fixed locallocs of this size or smaller will convert to local buffers private: #ifdef FEATURE_JIT_METHOD_PERF JitTimer* pCompJitTimer; // Timer data structure (by phases) for current compilation. static CompTimeSummaryInfo s_compJitTimerSummary; // Summary of the Timer information for the whole run. static LPCWSTR JitTimeLogCsv(); // Retrieve the file name for CSV from ConfigDWORD. static LPCWSTR compJitTimeLogFilename; // If a log file for JIT time is desired, filename to write it to. #endif void BeginPhase(Phases phase); // Indicate the start of the given phase. void EndPhase(Phases phase); // Indicate the end of the given phase. #if MEASURE_CLRAPI_CALLS // Thin wrappers that call into JitTimer (if present). inline void CLRApiCallEnter(unsigned apix); inline void CLRApiCallLeave(unsigned apix); public: inline void CLR_API_Enter(API_ICorJitInfo_Names ename); inline void CLR_API_Leave(API_ICorJitInfo_Names ename); private: #endif #if defined(DEBUG) || defined(INLINE_DATA) // These variables are associated with maintaining SQM data about compile time. unsigned __int64 m_compCyclesAtEndOfInlining; // The thread-virtualized cycle count at the end of the inlining phase // in the current compilation. unsigned __int64 m_compCycles; // Net cycle count for current compilation DWORD m_compTickCountAtEndOfInlining; // The result of GetTickCount() (# ms since some epoch marker) at the end of // the inlining phase in the current compilation. #endif // defined(DEBUG) || defined(INLINE_DATA) // Records the SQM-relevant (cycles and tick count). Should be called after inlining is complete. // (We do this after inlining because this marks the last point at which the JIT is likely to cause // type-loading and class initialization). void RecordStateAtEndOfInlining(); // Assumes being called at the end of compilation. Update the SQM state. void RecordStateAtEndOfCompilation(); public: #if FUNC_INFO_LOGGING static LPCWSTR compJitFuncInfoFilename; // If a log file for per-function information is required, this is the // filename to write it to. static FILE* compJitFuncInfoFile; // And this is the actual FILE* to write to. #endif // FUNC_INFO_LOGGING Compiler* prevCompiler; // Previous compiler on stack for TLS Compiler* linked list for reentrant compilers. #if MEASURE_NOWAY void RecordNowayAssert(const char* filename, unsigned line, const char* condStr); #endif // MEASURE_NOWAY #ifndef FEATURE_TRACELOGGING // Should we actually fire the noway assert body and the exception handler? bool compShouldThrowOnNoway(); #else // FEATURE_TRACELOGGING // Should we actually fire the noway assert body and the exception handler? bool compShouldThrowOnNoway(const char* filename, unsigned line); // Telemetry instance to use per method compilation. JitTelemetry compJitTelemetry; // Get common parameters that have to be logged with most telemetry data. void compGetTelemetryDefaults(const char** assemblyName, const char** scopeName, const char** methodName, unsigned* methodHash); #endif // !FEATURE_TRACELOGGING #ifdef DEBUG private: NodeToTestDataMap* m_nodeTestData; static const unsigned FIRST_LOOP_HOIST_CSE_CLASS = 1000; unsigned m_loopHoistCSEClass; // LoopHoist test annotations turn into CSE requirements; we // label them with CSE Class #'s starting at FIRST_LOOP_HOIST_CSE_CLASS. // Current kept in this. public: NodeToTestDataMap* GetNodeTestData() { Compiler* compRoot = impInlineRoot(); if (compRoot->m_nodeTestData == nullptr) { compRoot->m_nodeTestData = new (getAllocatorDebugOnly()) NodeToTestDataMap(getAllocatorDebugOnly()); } return compRoot->m_nodeTestData; } typedef JitHashTable<GenTree*, JitPtrKeyFuncs<GenTree>, int> NodeToIntMap; // Returns the set (i.e., the domain of the result map) of nodes that are keys in m_nodeTestData, and // currently occur in the AST graph. NodeToIntMap* FindReachableNodesInNodeTestData(); // Node "from" is being eliminated, and being replaced by node "to". If "from" had any associated // test data, associate that data with "to". void TransferTestDataToNode(GenTree* from, GenTree* to); // These are the methods that test that the various conditions implied by the // test attributes are satisfied. void JitTestCheckSSA(); // SSA builder tests. void JitTestCheckVN(); // Value numbering tests. #endif // DEBUG // The "FieldSeqStore", for canonicalizing field sequences. See the definition of FieldSeqStore for // operations. FieldSeqStore* m_fieldSeqStore; FieldSeqStore* GetFieldSeqStore() { Compiler* compRoot = impInlineRoot(); if (compRoot->m_fieldSeqStore == nullptr) { // Create a CompAllocator that labels sub-structure with CMK_FieldSeqStore, and use that for allocation. CompAllocator ialloc(getAllocator(CMK_FieldSeqStore)); compRoot->m_fieldSeqStore = new (ialloc) FieldSeqStore(ialloc); } return compRoot->m_fieldSeqStore; } typedef JitHashTable<GenTree*, JitPtrKeyFuncs<GenTree>, FieldSeqNode*> NodeToFieldSeqMap; // Some nodes of "TYP_BYREF" or "TYP_I_IMPL" actually represent the address of a field within a struct, but since // the offset of the field is zero, there's no "GT_ADD" node. We normally attach a field sequence to the constant // that is added, but what do we do when that constant is zero, and is thus not present? We use this mechanism to // attach the field sequence directly to the address node. NodeToFieldSeqMap* m_zeroOffsetFieldMap; NodeToFieldSeqMap* GetZeroOffsetFieldMap() { // Don't need to worry about inlining here if (m_zeroOffsetFieldMap == nullptr) { // Create a CompAllocator that labels sub-structure with CMK_ZeroOffsetFieldMap, and use that for // allocation. CompAllocator ialloc(getAllocator(CMK_ZeroOffsetFieldMap)); m_zeroOffsetFieldMap = new (ialloc) NodeToFieldSeqMap(ialloc); } return m_zeroOffsetFieldMap; } // Requires that "op1" is a node of type "TYP_BYREF" or "TYP_I_IMPL". We are dereferencing this with the fields in // "fieldSeq", whose offsets are required all to be zero. Ensures that any field sequence annotation currently on // "op1" or its components is augmented by appending "fieldSeq". In practice, if "op1" is a GT_LCL_FLD, it has // a field sequence as a member; otherwise, it may be the addition of an a byref and a constant, where the const // has a field sequence -- in this case "fieldSeq" is appended to that of the constant; otherwise, we // record the the field sequence using the ZeroOffsetFieldMap described above. // // One exception above is that "op1" is a node of type "TYP_REF" where "op1" is a GT_LCL_VAR. // This happens when System.Object vtable pointer is a regular field at offset 0 in System.Private.CoreLib in // CoreRT. Such case is handled same as the default case. void fgAddFieldSeqForZeroOffset(GenTree* op1, FieldSeqNode* fieldSeq); typedef JitHashTable<const GenTree*, JitPtrKeyFuncs<GenTree>, ArrayInfo> NodeToArrayInfoMap; NodeToArrayInfoMap* m_arrayInfoMap; NodeToArrayInfoMap* GetArrayInfoMap() { Compiler* compRoot = impInlineRoot(); if (compRoot->m_arrayInfoMap == nullptr) { // Create a CompAllocator that labels sub-structure with CMK_ArrayInfoMap, and use that for allocation. CompAllocator ialloc(getAllocator(CMK_ArrayInfoMap)); compRoot->m_arrayInfoMap = new (ialloc) NodeToArrayInfoMap(ialloc); } return compRoot->m_arrayInfoMap; } //----------------------------------------------------------------------------------------------------------------- // Compiler::TryGetArrayInfo: // Given an indirection node, checks to see whether or not that indirection represents an array access, and // if so returns information about the array. // // Arguments: // indir - The `GT_IND` node. // arrayInfo (out) - Information about the accessed array if this function returns true. Undefined otherwise. // // Returns: // True if the `GT_IND` node represents an array access; false otherwise. bool TryGetArrayInfo(GenTreeIndir* indir, ArrayInfo* arrayInfo) { if ((indir->gtFlags & GTF_IND_ARR_INDEX) == 0) { return false; } if (indir->gtOp1->OperIs(GT_INDEX_ADDR)) { GenTreeIndexAddr* const indexAddr = indir->gtOp1->AsIndexAddr(); *arrayInfo = ArrayInfo(indexAddr->gtElemType, indexAddr->gtElemSize, indexAddr->gtElemOffset, indexAddr->gtStructElemClass); return true; } bool found = GetArrayInfoMap()->Lookup(indir, arrayInfo); assert(found); return true; } NodeToUnsignedMap* m_memorySsaMap[MemoryKindCount]; // In some cases, we want to assign intermediate SSA #'s to memory states, and know what nodes create those memory // states. (We do this for try blocks, where, if the try block doesn't do a call that loses track of the memory // state, all the possible memory states are possible initial states of the corresponding catch block(s).) NodeToUnsignedMap* GetMemorySsaMap(MemoryKind memoryKind) { if (memoryKind == GcHeap && byrefStatesMatchGcHeapStates) { // Use the same map for GCHeap and ByrefExposed when their states match. memoryKind = ByrefExposed; } assert(memoryKind < MemoryKindCount); Compiler* compRoot = impInlineRoot(); if (compRoot->m_memorySsaMap[memoryKind] == nullptr) { // Create a CompAllocator that labels sub-structure with CMK_ArrayInfoMap, and use that for allocation. CompAllocator ialloc(getAllocator(CMK_ArrayInfoMap)); compRoot->m_memorySsaMap[memoryKind] = new (ialloc) NodeToUnsignedMap(ialloc); } return compRoot->m_memorySsaMap[memoryKind]; } // The Refany type is the only struct type whose structure is implicitly assumed by IL. We need its fields. CORINFO_CLASS_HANDLE m_refAnyClass; CORINFO_FIELD_HANDLE GetRefanyDataField() { if (m_refAnyClass == nullptr) { m_refAnyClass = info.compCompHnd->getBuiltinClass(CLASSID_TYPED_BYREF); } return info.compCompHnd->getFieldInClass(m_refAnyClass, 0); } CORINFO_FIELD_HANDLE GetRefanyTypeField() { if (m_refAnyClass == nullptr) { m_refAnyClass = info.compCompHnd->getBuiltinClass(CLASSID_TYPED_BYREF); } return info.compCompHnd->getFieldInClass(m_refAnyClass, 1); } #if VARSET_COUNTOPS static BitSetSupport::BitSetOpCounter m_varsetOpCounter; #endif #if ALLVARSET_COUNTOPS static BitSetSupport::BitSetOpCounter m_allvarsetOpCounter; #endif static HelperCallProperties s_helperCallProperties; #ifdef UNIX_AMD64_ABI static var_types GetTypeFromClassificationAndSizes(SystemVClassificationType classType, int size); static var_types GetEightByteType(const SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR& structDesc, unsigned slotNum); static void GetStructTypeOffset(const SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR& structDesc, var_types* type0, var_types* type1, unsigned __int8* offset0, unsigned __int8* offset1); void GetStructTypeOffset(CORINFO_CLASS_HANDLE typeHnd, var_types* type0, var_types* type1, unsigned __int8* offset0, unsigned __int8* offset1); #endif // defined(UNIX_AMD64_ABI) void fgMorphMultiregStructArgs(GenTreeCall* call); GenTree* fgMorphMultiregStructArg(GenTree* arg, fgArgTabEntry* fgEntryPtr); bool killGCRefs(GenTree* tree); }; // end of class Compiler //--------------------------------------------------------------------------------------------------------------------- // GenTreeVisitor: a flexible tree walker implemented using the curiously-recurring-template pattern. // // This class implements a configurable walker for IR trees. There are five configuration options (defaults values are // shown in parentheses): // // - ComputeStack (false): when true, the walker will push each node onto the `m_ancestors` stack. "Ancestors" is a bit // of a misnomer, as the first entry will always be the current node. // // - DoPreOrder (false): when true, the walker will invoke `TVisitor::PreOrderVisit` with the current node as an // argument before visiting the node's operands. // // - DoPostOrder (false): when true, the walker will invoke `TVisitor::PostOrderVisit` with the current node as an // argument after visiting the node's operands. // // - DoLclVarsOnly (false): when true, the walker will only invoke `TVisitor::PreOrderVisit` for lclVar nodes. // `DoPreOrder` must be true if this option is true. // // - UseExecutionOrder (false): when true, then walker will visit a node's operands in execution order (e.g. if a // binary operator has the `GTF_REVERSE_OPS` flag set, the second operand will be // visited before the first). // // At least one of `DoPreOrder` and `DoPostOrder` must be specified. // // A simple pre-order visitor might look something like the following: // // class CountingVisitor final : public GenTreeVisitor<CountingVisitor> // { // public: // enum // { // DoPreOrder = true // }; // // unsigned m_count; // // CountingVisitor(Compiler* compiler) // : GenTreeVisitor<CountingVisitor>(compiler), m_count(0) // { // } // // Compiler::fgWalkResult PreOrderVisit(GenTree* node) // { // m_count++; // } // }; // // This visitor would then be used like so: // // CountingVisitor countingVisitor(compiler); // countingVisitor.WalkTree(root); // template <typename TVisitor> class GenTreeVisitor { protected: typedef Compiler::fgWalkResult fgWalkResult; enum { ComputeStack = false, DoPreOrder = false, DoPostOrder = false, DoLclVarsOnly = false, UseExecutionOrder = false, }; Compiler* m_compiler; ArrayStack<GenTree*> m_ancestors; GenTreeVisitor(Compiler* compiler) : m_compiler(compiler), m_ancestors(compiler->getAllocator(CMK_ArrayStack)) { assert(compiler != nullptr); static_assert_no_msg(TVisitor::DoPreOrder || TVisitor::DoPostOrder); static_assert_no_msg(!TVisitor::DoLclVarsOnly || TVisitor::DoPreOrder); } fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { return fgWalkResult::WALK_CONTINUE; } fgWalkResult PostOrderVisit(GenTree** use, GenTree* user) { return fgWalkResult::WALK_CONTINUE; } public: fgWalkResult WalkTree(GenTree** use, GenTree* user) { assert(use != nullptr); GenTree* node = *use; if (TVisitor::ComputeStack) { m_ancestors.Push(node); } fgWalkResult result = fgWalkResult::WALK_CONTINUE; if (TVisitor::DoPreOrder && !TVisitor::DoLclVarsOnly) { result = reinterpret_cast<TVisitor*>(this)->PreOrderVisit(use, user); if (result == fgWalkResult::WALK_ABORT) { return result; } node = *use; if ((node == nullptr) || (result == fgWalkResult::WALK_SKIP_SUBTREES)) { goto DONE; } } switch (node->OperGet()) { // Leaf lclVars case GT_LCL_VAR: case GT_LCL_FLD: case GT_LCL_VAR_ADDR: case GT_LCL_FLD_ADDR: if (TVisitor::DoLclVarsOnly) { result = reinterpret_cast<TVisitor*>(this)->PreOrderVisit(use, user); if (result == fgWalkResult::WALK_ABORT) { return result; } } FALLTHROUGH; // Leaf nodes case GT_CATCH_ARG: case GT_LABEL: case GT_FTN_ADDR: case GT_RET_EXPR: case GT_CNS_INT: case GT_CNS_LNG: case GT_CNS_DBL: case GT_CNS_STR: case GT_MEMORYBARRIER: case GT_JMP: case GT_JCC: case GT_SETCC: case GT_NO_OP: case GT_START_NONGC: case GT_START_PREEMPTGC: case GT_PROF_HOOK: #if !defined(FEATURE_EH_FUNCLETS) case GT_END_LFIN: #endif // !FEATURE_EH_FUNCLETS case GT_PHI_ARG: case GT_JMPTABLE: case GT_CLS_VAR: case GT_CLS_VAR_ADDR: case GT_ARGPLACE: case GT_PHYSREG: case GT_EMITNOP: case GT_PINVOKE_PROLOG: case GT_PINVOKE_EPILOG: case GT_IL_OFFSET: break; // Lclvar unary operators case GT_STORE_LCL_VAR: case GT_STORE_LCL_FLD: if (TVisitor::DoLclVarsOnly) { result = reinterpret_cast<TVisitor*>(this)->PreOrderVisit(use, user); if (result == fgWalkResult::WALK_ABORT) { return result; } } FALLTHROUGH; // Standard unary operators case GT_NOT: case GT_NEG: case GT_BSWAP: case GT_BSWAP16: case GT_COPY: case GT_RELOAD: case GT_ARR_LENGTH: case GT_CAST: case GT_BITCAST: case GT_CKFINITE: case GT_LCLHEAP: case GT_ADDR: case GT_IND: case GT_OBJ: case GT_BLK: case GT_BOX: case GT_ALLOCOBJ: case GT_INIT_VAL: case GT_JTRUE: case GT_SWITCH: case GT_NULLCHECK: case GT_PUTARG_REG: case GT_PUTARG_STK: case GT_PUTARG_TYPE: case GT_RETURNTRAP: case GT_NOP: case GT_FIELD: case GT_RETURN: case GT_RETFILT: case GT_RUNTIMELOOKUP: case GT_KEEPALIVE: case GT_INC_SATURATE: { GenTreeUnOp* const unOp = node->AsUnOp(); if (unOp->gtOp1 != nullptr) { result = WalkTree(&unOp->gtOp1, unOp); if (result == fgWalkResult::WALK_ABORT) { return result; } } break; } // Special nodes case GT_PHI: for (GenTreePhi::Use& use : node->AsPhi()->Uses()) { result = WalkTree(&use.NodeRef(), node); if (result == fgWalkResult::WALK_ABORT) { return result; } } break; case GT_FIELD_LIST: for (GenTreeFieldList::Use& use : node->AsFieldList()->Uses()) { result = WalkTree(&use.NodeRef(), node); if (result == fgWalkResult::WALK_ABORT) { return result; } } break; case GT_CMPXCHG: { GenTreeCmpXchg* const cmpXchg = node->AsCmpXchg(); result = WalkTree(&cmpXchg->gtOpLocation, cmpXchg); if (result == fgWalkResult::WALK_ABORT) { return result; } result = WalkTree(&cmpXchg->gtOpValue, cmpXchg); if (result == fgWalkResult::WALK_ABORT) { return result; } result = WalkTree(&cmpXchg->gtOpComparand, cmpXchg); if (result == fgWalkResult::WALK_ABORT) { return result; } break; } case GT_ARR_ELEM: { GenTreeArrElem* const arrElem = node->AsArrElem(); result = WalkTree(&arrElem->gtArrObj, arrElem); if (result == fgWalkResult::WALK_ABORT) { return result; } const unsigned rank = arrElem->gtArrRank; for (unsigned dim = 0; dim < rank; dim++) { result = WalkTree(&arrElem->gtArrInds[dim], arrElem); if (result == fgWalkResult::WALK_ABORT) { return result; } } break; } case GT_ARR_OFFSET: { GenTreeArrOffs* const arrOffs = node->AsArrOffs(); result = WalkTree(&arrOffs->gtOffset, arrOffs); if (result == fgWalkResult::WALK_ABORT) { return result; } result = WalkTree(&arrOffs->gtIndex, arrOffs); if (result == fgWalkResult::WALK_ABORT) { return result; } result = WalkTree(&arrOffs->gtArrObj, arrOffs); if (result == fgWalkResult::WALK_ABORT) { return result; } break; } case GT_STORE_DYN_BLK: { GenTreeStoreDynBlk* const dynBlock = node->AsStoreDynBlk(); GenTree** op1Use = &dynBlock->gtOp1; GenTree** op2Use = &dynBlock->gtOp2; GenTree** op3Use = &dynBlock->gtDynamicSize; result = WalkTree(op1Use, dynBlock); if (result == fgWalkResult::WALK_ABORT) { return result; } result = WalkTree(op2Use, dynBlock); if (result == fgWalkResult::WALK_ABORT) { return result; } result = WalkTree(op3Use, dynBlock); if (result == fgWalkResult::WALK_ABORT) { return result; } break; } case GT_CALL: { GenTreeCall* const call = node->AsCall(); if (call->gtCallThisArg != nullptr) { result = WalkTree(&call->gtCallThisArg->NodeRef(), call); if (result == fgWalkResult::WALK_ABORT) { return result; } } for (GenTreeCall::Use& use : call->Args()) { result = WalkTree(&use.NodeRef(), call); if (result == fgWalkResult::WALK_ABORT) { return result; } } for (GenTreeCall::Use& use : call->LateArgs()) { result = WalkTree(&use.NodeRef(), call); if (result == fgWalkResult::WALK_ABORT) { return result; } } if (call->gtCallType == CT_INDIRECT) { if (call->gtCallCookie != nullptr) { result = WalkTree(&call->gtCallCookie, call); if (result == fgWalkResult::WALK_ABORT) { return result; } } result = WalkTree(&call->gtCallAddr, call); if (result == fgWalkResult::WALK_ABORT) { return result; } } if (call->gtControlExpr != nullptr) { result = WalkTree(&call->gtControlExpr, call); if (result == fgWalkResult::WALK_ABORT) { return result; } } break; } #if defined(FEATURE_SIMD) || defined(FEATURE_HW_INTRINSICS) #if defined(FEATURE_SIMD) case GT_SIMD: #endif #if defined(FEATURE_HW_INTRINSICS) case GT_HWINTRINSIC: #endif if (TVisitor::UseExecutionOrder && node->IsReverseOp()) { assert(node->AsMultiOp()->GetOperandCount() == 2); result = WalkTree(&node->AsMultiOp()->Op(2), node); if (result == fgWalkResult::WALK_ABORT) { return result; } result = WalkTree(&node->AsMultiOp()->Op(1), node); if (result == fgWalkResult::WALK_ABORT) { return result; } } else { for (GenTree** use : node->AsMultiOp()->UseEdges()) { result = WalkTree(use, node); if (result == fgWalkResult::WALK_ABORT) { return result; } } } break; #endif // defined(FEATURE_SIMD) || defined(FEATURE_HW_INTRINSICS) // Binary nodes default: { assert(node->OperIsBinary()); GenTreeOp* const op = node->AsOp(); GenTree** op1Use = &op->gtOp1; GenTree** op2Use = &op->gtOp2; if (TVisitor::UseExecutionOrder && node->IsReverseOp()) { std::swap(op1Use, op2Use); } if (*op1Use != nullptr) { result = WalkTree(op1Use, op); if (result == fgWalkResult::WALK_ABORT) { return result; } } if (*op2Use != nullptr) { result = WalkTree(op2Use, op); if (result == fgWalkResult::WALK_ABORT) { return result; } } break; } } DONE: // Finally, visit the current node if (TVisitor::DoPostOrder) { result = reinterpret_cast<TVisitor*>(this)->PostOrderVisit(use, user); } if (TVisitor::ComputeStack) { m_ancestors.Pop(); } return result; } }; template <bool computeStack, bool doPreOrder, bool doPostOrder, bool doLclVarsOnly, bool useExecutionOrder> class GenericTreeWalker final : public GenTreeVisitor<GenericTreeWalker<computeStack, doPreOrder, doPostOrder, doLclVarsOnly, useExecutionOrder>> { public: enum { ComputeStack = computeStack, DoPreOrder = doPreOrder, DoPostOrder = doPostOrder, DoLclVarsOnly = doLclVarsOnly, UseExecutionOrder = useExecutionOrder, }; private: Compiler::fgWalkData* m_walkData; public: GenericTreeWalker(Compiler::fgWalkData* walkData) : GenTreeVisitor<GenericTreeWalker<computeStack, doPreOrder, doPostOrder, doLclVarsOnly, useExecutionOrder>>( walkData->compiler) , m_walkData(walkData) { assert(walkData != nullptr); if (computeStack) { walkData->parentStack = &this->m_ancestors; } } Compiler::fgWalkResult PreOrderVisit(GenTree** use, GenTree* user) { m_walkData->parent = user; return m_walkData->wtprVisitorFn(use, m_walkData); } Compiler::fgWalkResult PostOrderVisit(GenTree** use, GenTree* user) { m_walkData->parent = user; return m_walkData->wtpoVisitorFn(use, m_walkData); } }; // A dominator tree visitor implemented using the curiously-recurring-template pattern, similar to GenTreeVisitor. template <typename TVisitor> class DomTreeVisitor { protected: Compiler* const m_compiler; DomTreeNode* const m_domTree; DomTreeVisitor(Compiler* compiler, DomTreeNode* domTree) : m_compiler(compiler), m_domTree(domTree) { } void Begin() { } void PreOrderVisit(BasicBlock* block) { } void PostOrderVisit(BasicBlock* block) { } void End() { } public: //------------------------------------------------------------------------ // WalkTree: Walk the dominator tree, starting from fgFirstBB. // // Notes: // This performs a non-recursive, non-allocating walk of the tree by using // DomTreeNode's firstChild and nextSibling links to locate the children of // a node and BasicBlock's bbIDom parent link to go back up the tree when // no more children are left. // // Forests are also supported, provided that all the roots are chained via // DomTreeNode::nextSibling to fgFirstBB. // void WalkTree() { static_cast<TVisitor*>(this)->Begin(); for (BasicBlock *next, *block = m_compiler->fgFirstBB; block != nullptr; block = next) { static_cast<TVisitor*>(this)->PreOrderVisit(block); next = m_domTree[block->bbNum].firstChild; if (next != nullptr) { assert(next->bbIDom == block); continue; } do { static_cast<TVisitor*>(this)->PostOrderVisit(block); next = m_domTree[block->bbNum].nextSibling; if (next != nullptr) { assert(next->bbIDom == block->bbIDom); break; } block = block->bbIDom; } while (block != nullptr); } static_cast<TVisitor*>(this)->End(); } }; // EHClauses: adapter class for forward iteration of the exception handling table using range-based `for`, e.g.: // for (EHblkDsc* const ehDsc : EHClauses(compiler)) // class EHClauses { EHblkDsc* m_begin; EHblkDsc* m_end; // Forward iterator for the exception handling table entries. Iteration is in table order. // class iterator { EHblkDsc* m_ehDsc; public: iterator(EHblkDsc* ehDsc) : m_ehDsc(ehDsc) { } EHblkDsc* operator*() const { return m_ehDsc; } iterator& operator++() { ++m_ehDsc; return *this; } bool operator!=(const iterator& i) const { return m_ehDsc != i.m_ehDsc; } }; public: EHClauses(Compiler* comp) : m_begin(comp->compHndBBtab), m_end(comp->compHndBBtab + comp->compHndBBtabCount) { assert((m_begin != nullptr) || (m_begin == m_end)); } iterator begin() const { return iterator(m_begin); } iterator end() const { return iterator(m_end); } }; /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX XX XX Miscellaneous Compiler stuff XX XX XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ // Values used to mark the types a stack slot is used for const unsigned TYPE_REF_INT = 0x01; // slot used as a 32-bit int const unsigned TYPE_REF_LNG = 0x02; // slot used as a 64-bit long const unsigned TYPE_REF_FLT = 0x04; // slot used as a 32-bit float const unsigned TYPE_REF_DBL = 0x08; // slot used as a 64-bit float const unsigned TYPE_REF_PTR = 0x10; // slot used as a 32-bit pointer const unsigned TYPE_REF_BYR = 0x20; // slot used as a byref pointer const unsigned TYPE_REF_STC = 0x40; // slot used as a struct const unsigned TYPE_REF_TYPEMASK = 0x7F; // bits that represent the type // const unsigned TYPE_REF_ADDR_TAKEN = 0x80; // slots address was taken /***************************************************************************** * * Variables to keep track of total code amounts. */ #if DISPLAY_SIZES extern size_t grossVMsize; extern size_t grossNCsize; extern size_t totalNCsize; extern unsigned genMethodICnt; extern unsigned genMethodNCnt; extern size_t gcHeaderISize; extern size_t gcPtrMapISize; extern size_t gcHeaderNSize; extern size_t gcPtrMapNSize; #endif // DISPLAY_SIZES /***************************************************************************** * * Variables to keep track of basic block counts (more data on 1 BB methods) */ #if COUNT_BASIC_BLOCKS extern Histogram bbCntTable; extern Histogram bbOneBBSizeTable; #endif /***************************************************************************** * * Used by optFindNaturalLoops to gather statistical information such as * - total number of natural loops * - number of loops with 1, 2, ... exit conditions * - number of loops that have an iterator (for like) * - number of loops that have a constant iterator */ #if COUNT_LOOPS extern unsigned totalLoopMethods; // counts the total number of methods that have natural loops extern unsigned maxLoopsPerMethod; // counts the maximum number of loops a method has extern unsigned totalLoopOverflows; // # of methods that identified more loops than we can represent extern unsigned totalLoopCount; // counts the total number of natural loops extern unsigned totalUnnatLoopCount; // counts the total number of (not-necessarily natural) loops extern unsigned totalUnnatLoopOverflows; // # of methods that identified more unnatural loops than we can represent extern unsigned iterLoopCount; // counts the # of loops with an iterator (for like) extern unsigned simpleTestLoopCount; // counts the # of loops with an iterator and a simple loop condition (iter < // const) extern unsigned constIterLoopCount; // counts the # of loops with a constant iterator (for like) extern bool hasMethodLoops; // flag to keep track if we already counted a method as having loops extern unsigned loopsThisMethod; // counts the number of loops in the current method extern bool loopOverflowThisMethod; // True if we exceeded the max # of loops in the method. extern Histogram loopCountTable; // Histogram of loop counts extern Histogram loopExitCountTable; // Histogram of loop exit counts #endif // COUNT_LOOPS /***************************************************************************** * variables to keep track of how many iterations we go in a dataflow pass */ #if DATAFLOW_ITER extern unsigned CSEiterCount; // counts the # of iteration for the CSE dataflow extern unsigned CFiterCount; // counts the # of iteration for the Const Folding dataflow #endif // DATAFLOW_ITER #if MEASURE_BLOCK_SIZE extern size_t genFlowNodeSize; extern size_t genFlowNodeCnt; #endif // MEASURE_BLOCK_SIZE #if MEASURE_NODE_SIZE struct NodeSizeStats { void Init() { genTreeNodeCnt = 0; genTreeNodeSize = 0; genTreeNodeActualSize = 0; } // Count of tree nodes allocated. unsigned __int64 genTreeNodeCnt; // The size we allocate. unsigned __int64 genTreeNodeSize; // The actual size of the node. Note that the actual size will likely be smaller // than the allocated size, but we sometimes use SetOper()/ChangeOper() to change // a smaller node to a larger one. TODO-Cleanup: add stats on // SetOper()/ChangeOper() usage to quantify this. unsigned __int64 genTreeNodeActualSize; }; extern NodeSizeStats genNodeSizeStats; // Total node size stats extern NodeSizeStats genNodeSizeStatsPerFunc; // Per-function node size stats extern Histogram genTreeNcntHist; extern Histogram genTreeNsizHist; #endif // MEASURE_NODE_SIZE /***************************************************************************** * Count fatal errors (including noway_asserts). */ #if MEASURE_FATAL extern unsigned fatal_badCode; extern unsigned fatal_noWay; extern unsigned fatal_implLimitation; extern unsigned fatal_NOMEM; extern unsigned fatal_noWayAssertBody; #ifdef DEBUG extern unsigned fatal_noWayAssertBodyArgs; #endif // DEBUG extern unsigned fatal_NYI; #endif // MEASURE_FATAL /***************************************************************************** * Codegen */ #ifdef TARGET_XARCH const instruction INS_SHIFT_LEFT_LOGICAL = INS_shl; const instruction INS_SHIFT_RIGHT_LOGICAL = INS_shr; const instruction INS_SHIFT_RIGHT_ARITHM = INS_sar; const instruction INS_AND = INS_and; const instruction INS_OR = INS_or; const instruction INS_XOR = INS_xor; const instruction INS_NEG = INS_neg; const instruction INS_TEST = INS_test; const instruction INS_MUL = INS_imul; const instruction INS_SIGNED_DIVIDE = INS_idiv; const instruction INS_UNSIGNED_DIVIDE = INS_div; const instruction INS_BREAKPOINT = INS_int3; const instruction INS_ADDC = INS_adc; const instruction INS_SUBC = INS_sbb; const instruction INS_NOT = INS_not; #endif // TARGET_XARCH #ifdef TARGET_ARM const instruction INS_SHIFT_LEFT_LOGICAL = INS_lsl; const instruction INS_SHIFT_RIGHT_LOGICAL = INS_lsr; const instruction INS_SHIFT_RIGHT_ARITHM = INS_asr; const instruction INS_AND = INS_and; const instruction INS_OR = INS_orr; const instruction INS_XOR = INS_eor; const instruction INS_NEG = INS_rsb; const instruction INS_TEST = INS_tst; const instruction INS_MUL = INS_mul; const instruction INS_MULADD = INS_mla; const instruction INS_SIGNED_DIVIDE = INS_sdiv; const instruction INS_UNSIGNED_DIVIDE = INS_udiv; const instruction INS_BREAKPOINT = INS_bkpt; const instruction INS_ADDC = INS_adc; const instruction INS_SUBC = INS_sbc; const instruction INS_NOT = INS_mvn; const instruction INS_ABS = INS_vabs; const instruction INS_SQRT = INS_vsqrt; #endif // TARGET_ARM #ifdef TARGET_ARM64 const instruction INS_MULADD = INS_madd; inline const instruction INS_BREAKPOINT_osHelper() { // GDB needs the encoding of brk #0 // Windbg needs the encoding of brk #F000 return TargetOS::IsUnix ? INS_brk_unix : INS_brk_windows; } #define INS_BREAKPOINT INS_BREAKPOINT_osHelper() const instruction INS_ABS = INS_fabs; const instruction INS_SQRT = INS_fsqrt; #endif // TARGET_ARM64 /*****************************************************************************/ extern const BYTE genTypeSizes[]; extern const BYTE genTypeAlignments[]; extern const BYTE genTypeStSzs[]; extern const BYTE genActualTypes[]; /*****************************************************************************/ #ifdef DEBUG void dumpConvertedVarSet(Compiler* comp, VARSET_VALARG_TP vars); #endif // DEBUG #include "compiler.hpp" // All the shared inline functions /*****************************************************************************/ #endif //_COMPILER_H_ /*****************************************************************************/
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/tests/JIT/Methodical/Invoke/25params/25param3a_cs_ro.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>None</DebugType> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="25param3a.cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>None</DebugType> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="25param3a.cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/coreclr/pal/tests/palsuite/c_runtime/_snwprintf_s/test6/test6.cpp
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /*============================================================================ ** ** Source: test6.c ** ** Purpose: Tests swprintf_s with characters ** ** **==========================================================================*/ #include <palsuite.h> #include "../_snwprintf_s.h" /* memcmp is used to verify the results, so this test is dependent on it. */ /* ditto with wcslen */ PALTEST(c_runtime__snwprintf_s_test6_paltest_snwprintf_test6, "c_runtime/_snwprintf_s/test6/paltest_snwprintf_test6") { WCHAR wc = (WCHAR) 'c'; if (PAL_Initialize(argc, argv) != 0) { return FAIL; } DoWCharTest(convert("foo %c"), wc, convert("foo c")); DoCharTest(convert("foo %hc"), 'b', convert("foo b")); DoWCharTest(convert("foo %lc"), wc, convert("foo c")); DoWCharTest(convert("foo %Lc"), wc, convert("foo c")); DoWCharTest(convert("foo %I64c"), wc, convert("foo c")); DoWCharTest(convert("foo %5c"), wc, convert("foo c")); DoWCharTest(convert("foo %.0c"), wc, convert("foo c")); DoWCharTest(convert("foo %-5c"), wc, convert("foo c ")); DoWCharTest(convert("foo %05c"), wc, convert("foo 0000c")); DoWCharTest(convert("foo % c"), wc, convert("foo c")); DoWCharTest(convert("foo %#c"), wc, convert("foo c")); PAL_Terminate(); return PASS; }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /*============================================================================ ** ** Source: test6.c ** ** Purpose: Tests swprintf_s with characters ** ** **==========================================================================*/ #include <palsuite.h> #include "../_snwprintf_s.h" /* memcmp is used to verify the results, so this test is dependent on it. */ /* ditto with wcslen */ PALTEST(c_runtime__snwprintf_s_test6_paltest_snwprintf_test6, "c_runtime/_snwprintf_s/test6/paltest_snwprintf_test6") { WCHAR wc = (WCHAR) 'c'; if (PAL_Initialize(argc, argv) != 0) { return FAIL; } DoWCharTest(convert("foo %c"), wc, convert("foo c")); DoCharTest(convert("foo %hc"), 'b', convert("foo b")); DoWCharTest(convert("foo %lc"), wc, convert("foo c")); DoWCharTest(convert("foo %Lc"), wc, convert("foo c")); DoWCharTest(convert("foo %I64c"), wc, convert("foo c")); DoWCharTest(convert("foo %5c"), wc, convert("foo c")); DoWCharTest(convert("foo %.0c"), wc, convert("foo c")); DoWCharTest(convert("foo %-5c"), wc, convert("foo c ")); DoWCharTest(convert("foo %05c"), wc, convert("foo 0000c")); DoWCharTest(convert("foo % c"), wc, convert("foo c")); DoWCharTest(convert("foo %#c"), wc, convert("foo c")); PAL_Terminate(); return PASS; }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd.Arm64/MinPairwise.Vector128.Double.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void MinPairwise_Vector128_Double() { var test = new SimpleBinaryOpTest__MinPairwise_Vector128_Double(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleBinaryOpTest__MinPairwise_Vector128_Double { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Double[] inArray1, Double[] inArray2, Double[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Double>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Double>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Double>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Double, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Double, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector128<Double> _fld1; public Vector128<Double> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref testStruct._fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref testStruct._fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__MinPairwise_Vector128_Double testClass) { var result = AdvSimd.Arm64.MinPairwise(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__MinPairwise_Vector128_Double testClass) { fixed (Vector128<Double>* pFld1 = &_fld1) fixed (Vector128<Double>* pFld2 = &_fld2) { var result = AdvSimd.Arm64.MinPairwise( AdvSimd.LoadVector128((Double*)(pFld1)), AdvSimd.LoadVector128((Double*)(pFld2)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Double>>() / sizeof(Double); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Double>>() / sizeof(Double); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Double>>() / sizeof(Double); private static Double[] _data1 = new Double[Op1ElementCount]; private static Double[] _data2 = new Double[Op2ElementCount]; private static Vector128<Double> _clsVar1; private static Vector128<Double> _clsVar2; private Vector128<Double> _fld1; private Vector128<Double> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__MinPairwise_Vector128_Double() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); } public SimpleBinaryOpTest__MinPairwise_Vector128_Double() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } public bool IsSupported => AdvSimd.Arm64.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = AdvSimd.Arm64.MinPairwise( Unsafe.Read<Vector128<Double>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Double>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = AdvSimd.Arm64.MinPairwise( AdvSimd.LoadVector128((Double*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Double*)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(AdvSimd.Arm64).GetMethod(nameof(AdvSimd.Arm64.MinPairwise), new Type[] { typeof(Vector128<Double>), typeof(Vector128<Double>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Double>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Double>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Double>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd.Arm64).GetMethod(nameof(AdvSimd.Arm64.MinPairwise), new Type[] { typeof(Vector128<Double>), typeof(Vector128<Double>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((Double*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Double*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Double>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.Arm64.MinPairwise( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<Double>* pClsVar1 = &_clsVar1) fixed (Vector128<Double>* pClsVar2 = &_clsVar2) { var result = AdvSimd.Arm64.MinPairwise( AdvSimd.LoadVector128((Double*)(pClsVar1)), AdvSimd.LoadVector128((Double*)(pClsVar2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector128<Double>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Double>>(_dataTable.inArray2Ptr); var result = AdvSimd.Arm64.MinPairwise(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector128((Double*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((Double*)(_dataTable.inArray2Ptr)); var result = AdvSimd.Arm64.MinPairwise(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__MinPairwise_Vector128_Double(); var result = AdvSimd.Arm64.MinPairwise(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleBinaryOpTest__MinPairwise_Vector128_Double(); fixed (Vector128<Double>* pFld1 = &test._fld1) fixed (Vector128<Double>* pFld2 = &test._fld2) { var result = AdvSimd.Arm64.MinPairwise( AdvSimd.LoadVector128((Double*)(pFld1)), AdvSimd.LoadVector128((Double*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.Arm64.MinPairwise(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<Double>* pFld1 = &_fld1) fixed (Vector128<Double>* pFld2 = &_fld2) { var result = AdvSimd.Arm64.MinPairwise( AdvSimd.LoadVector128((Double*)(pFld1)), AdvSimd.LoadVector128((Double*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = AdvSimd.Arm64.MinPairwise(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = AdvSimd.Arm64.MinPairwise( AdvSimd.LoadVector128((Double*)(&test._fld1)), AdvSimd.LoadVector128((Double*)(&test._fld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector128<Double> op1, Vector128<Double> op2, void* result, [CallerMemberName] string method = "") { Double[] inArray1 = new Double[Op1ElementCount]; Double[] inArray2 = new Double[Op2ElementCount]; Double[] outArray = new Double[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Double>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Double[] inArray1 = new Double[Op1ElementCount]; Double[] inArray2 = new Double[Op2ElementCount]; Double[] outArray = new Double[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Double>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Double>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Double>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Double[] left, Double[] right, Double[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (BitConverter.DoubleToInt64Bits(Helpers.MinPairwise(left, right, i)) != BitConverter.DoubleToInt64Bits(result[i])) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd.Arm64)}.{nameof(AdvSimd.Arm64.MinPairwise)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void MinPairwise_Vector128_Double() { var test = new SimpleBinaryOpTest__MinPairwise_Vector128_Double(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleBinaryOpTest__MinPairwise_Vector128_Double { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Double[] inArray1, Double[] inArray2, Double[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Double>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Double>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Double>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Double, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Double, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector128<Double> _fld1; public Vector128<Double> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref testStruct._fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref testStruct._fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__MinPairwise_Vector128_Double testClass) { var result = AdvSimd.Arm64.MinPairwise(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__MinPairwise_Vector128_Double testClass) { fixed (Vector128<Double>* pFld1 = &_fld1) fixed (Vector128<Double>* pFld2 = &_fld2) { var result = AdvSimd.Arm64.MinPairwise( AdvSimd.LoadVector128((Double*)(pFld1)), AdvSimd.LoadVector128((Double*)(pFld2)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Double>>() / sizeof(Double); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Double>>() / sizeof(Double); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Double>>() / sizeof(Double); private static Double[] _data1 = new Double[Op1ElementCount]; private static Double[] _data2 = new Double[Op2ElementCount]; private static Vector128<Double> _clsVar1; private static Vector128<Double> _clsVar2; private Vector128<Double> _fld1; private Vector128<Double> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__MinPairwise_Vector128_Double() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); } public SimpleBinaryOpTest__MinPairwise_Vector128_Double() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } public bool IsSupported => AdvSimd.Arm64.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = AdvSimd.Arm64.MinPairwise( Unsafe.Read<Vector128<Double>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Double>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = AdvSimd.Arm64.MinPairwise( AdvSimd.LoadVector128((Double*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Double*)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(AdvSimd.Arm64).GetMethod(nameof(AdvSimd.Arm64.MinPairwise), new Type[] { typeof(Vector128<Double>), typeof(Vector128<Double>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Double>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Double>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Double>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd.Arm64).GetMethod(nameof(AdvSimd.Arm64.MinPairwise), new Type[] { typeof(Vector128<Double>), typeof(Vector128<Double>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((Double*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Double*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Double>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.Arm64.MinPairwise( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<Double>* pClsVar1 = &_clsVar1) fixed (Vector128<Double>* pClsVar2 = &_clsVar2) { var result = AdvSimd.Arm64.MinPairwise( AdvSimd.LoadVector128((Double*)(pClsVar1)), AdvSimd.LoadVector128((Double*)(pClsVar2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector128<Double>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Double>>(_dataTable.inArray2Ptr); var result = AdvSimd.Arm64.MinPairwise(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector128((Double*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((Double*)(_dataTable.inArray2Ptr)); var result = AdvSimd.Arm64.MinPairwise(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__MinPairwise_Vector128_Double(); var result = AdvSimd.Arm64.MinPairwise(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleBinaryOpTest__MinPairwise_Vector128_Double(); fixed (Vector128<Double>* pFld1 = &test._fld1) fixed (Vector128<Double>* pFld2 = &test._fld2) { var result = AdvSimd.Arm64.MinPairwise( AdvSimd.LoadVector128((Double*)(pFld1)), AdvSimd.LoadVector128((Double*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.Arm64.MinPairwise(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<Double>* pFld1 = &_fld1) fixed (Vector128<Double>* pFld2 = &_fld2) { var result = AdvSimd.Arm64.MinPairwise( AdvSimd.LoadVector128((Double*)(pFld1)), AdvSimd.LoadVector128((Double*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = AdvSimd.Arm64.MinPairwise(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = AdvSimd.Arm64.MinPairwise( AdvSimd.LoadVector128((Double*)(&test._fld1)), AdvSimd.LoadVector128((Double*)(&test._fld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector128<Double> op1, Vector128<Double> op2, void* result, [CallerMemberName] string method = "") { Double[] inArray1 = new Double[Op1ElementCount]; Double[] inArray2 = new Double[Op2ElementCount]; Double[] outArray = new Double[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Double>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Double[] inArray1 = new Double[Op1ElementCount]; Double[] inArray2 = new Double[Op2ElementCount]; Double[] outArray = new Double[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Double>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Double>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Double>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Double[] left, Double[] right, Double[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (BitConverter.DoubleToInt64Bits(Helpers.MinPairwise(left, right, i)) != BitConverter.DoubleToInt64Bits(result[i])) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd.Arm64)}.{nameof(AdvSimd.Arm64.MinPairwise)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/tests/JIT/Directed/coverage/importer/Desktop/volatilstind_il_d.ilproj
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <OutputType>Exe</OutputType> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> </PropertyGroup> <ItemGroup> <Compile Include="volatilstind.il" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <OutputType>Exe</OutputType> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> </PropertyGroup> <ItemGroup> <Compile Include="volatilstind.il" /> </ItemGroup> </Project>
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/tests/Loader/classloader/TypeGeneratorTests/TypeGeneratorTest616/Generated616.ilproj
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <ItemGroup> <Compile Include="Generated616.il" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\TestFramework\TestFramework.csproj" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <ItemGroup> <Compile Include="Generated616.il" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\TestFramework\TestFramework.csproj" /> </ItemGroup> </Project>
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/VectorTableLookupExtension.Vector64.Byte.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void VectorTableLookupExtension_Vector64_Byte() { var test = new SimpleTernaryOpTest__VectorTableLookupExtension_Vector64_Byte(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleTernaryOpTest__VectorTableLookupExtension_Vector64_Byte { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] inArray3; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle inHandle3; private GCHandle outHandle; private ulong alignment; public DataTable(Byte[] inArray1, Byte[] inArray2, Byte[] inArray3, Byte[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Byte>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Byte>(); int sizeOfinArray3 = inArray3.Length * Unsafe.SizeOf<Byte>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Byte>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfinArray3 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.inArray3 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.inHandle3 = GCHandle.Alloc(this.inArray3, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Byte, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Byte, byte>(ref inArray2[0]), (uint)sizeOfinArray2); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray3Ptr), ref Unsafe.As<Byte, byte>(ref inArray3[0]), (uint)sizeOfinArray3); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray3Ptr => Align((byte*)(inHandle3.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); inHandle3.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector64<Byte> _fld1; public Vector128<Byte> _fld2; public Vector64<Byte> _fld3; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref testStruct._fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref testStruct._fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (Byte)(TestLibrary.Generator.GetByte() % 20); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref testStruct._fld3), ref Unsafe.As<Byte, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); return testStruct; } public void RunStructFldScenario(SimpleTernaryOpTest__VectorTableLookupExtension_Vector64_Byte testClass) { var result = AdvSimd.VectorTableLookupExtension(_fld1, _fld2, _fld3); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleTernaryOpTest__VectorTableLookupExtension_Vector64_Byte testClass) { fixed (Vector64<Byte>* pFld1 = &_fld1) fixed (Vector128<Byte>* pFld2 = &_fld2) fixed (Vector64<Byte>* pFld3 = &_fld3) { var result = AdvSimd.VectorTableLookupExtension( AdvSimd.LoadVector64((Byte*)(pFld1)), AdvSimd.LoadVector128((Byte*)(pFld2)), AdvSimd.LoadVector64((Byte*)(pFld3)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector64<Byte>>() / sizeof(Byte); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Byte>>() / sizeof(Byte); private static readonly int Op3ElementCount = Unsafe.SizeOf<Vector64<Byte>>() / sizeof(Byte); private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<Byte>>() / sizeof(Byte); private static Byte[] _data1 = new Byte[Op1ElementCount]; private static Byte[] _data2 = new Byte[Op2ElementCount]; private static Byte[] _data3 = new Byte[Op3ElementCount]; private static Vector64<Byte> _clsVar1; private static Vector128<Byte> _clsVar2; private static Vector64<Byte> _clsVar3; private Vector64<Byte> _fld1; private Vector128<Byte> _fld2; private Vector64<Byte> _fld3; private DataTable _dataTable; static SimpleTernaryOpTest__VectorTableLookupExtension_Vector64_Byte() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (Byte)(TestLibrary.Generator.GetByte() % 20); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _clsVar3), ref Unsafe.As<Byte, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); } public SimpleTernaryOpTest__VectorTableLookupExtension_Vector64_Byte() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (Byte)(TestLibrary.Generator.GetByte() % 20); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _fld3), ref Unsafe.As<Byte, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (Byte)(TestLibrary.Generator.GetByte() % 20); } _dataTable = new DataTable(_data1, _data2, _data3, new Byte[RetElementCount], LargestVectorSize); } public bool IsSupported => AdvSimd.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = AdvSimd.VectorTableLookupExtension( Unsafe.Read<Vector64<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr), Unsafe.Read<Vector64<Byte>>(_dataTable.inArray3Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = AdvSimd.VectorTableLookupExtension( AdvSimd.LoadVector64((Byte*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Byte*)(_dataTable.inArray2Ptr)), AdvSimd.LoadVector64((Byte*)(_dataTable.inArray3Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.VectorTableLookupExtension), new Type[] { typeof(Vector64<Byte>), typeof(Vector128<Byte>), typeof(Vector64<Byte>) }) .Invoke(null, new object[] { Unsafe.Read<Vector64<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr), Unsafe.Read<Vector64<Byte>>(_dataTable.inArray3Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Byte>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.VectorTableLookupExtension), new Type[] { typeof(Vector64<Byte>), typeof(Vector128<Byte>), typeof(Vector64<Byte>) }) .Invoke(null, new object[] { AdvSimd.LoadVector64((Byte*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Byte*)(_dataTable.inArray2Ptr)), AdvSimd.LoadVector64((Byte*)(_dataTable.inArray3Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Byte>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.VectorTableLookupExtension( _clsVar1, _clsVar2, _clsVar3 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _clsVar3, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector64<Byte>* pClsVar1 = &_clsVar1) fixed (Vector128<Byte>* pClsVar2 = &_clsVar2) fixed (Vector64<Byte>* pClsVar3 = &_clsVar3) { var result = AdvSimd.VectorTableLookupExtension( AdvSimd.LoadVector64((Byte*)(pClsVar1)), AdvSimd.LoadVector128((Byte*)(pClsVar2)), AdvSimd.LoadVector64((Byte*)(pClsVar3)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _clsVar3, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector64<Byte>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr); var op3 = Unsafe.Read<Vector64<Byte>>(_dataTable.inArray3Ptr); var result = AdvSimd.VectorTableLookupExtension(op1, op2, op3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, op3, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector64((Byte*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((Byte*)(_dataTable.inArray2Ptr)); var op3 = AdvSimd.LoadVector64((Byte*)(_dataTable.inArray3Ptr)); var result = AdvSimd.VectorTableLookupExtension(op1, op2, op3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, op3, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleTernaryOpTest__VectorTableLookupExtension_Vector64_Byte(); var result = AdvSimd.VectorTableLookupExtension(test._fld1, test._fld2, test._fld3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleTernaryOpTest__VectorTableLookupExtension_Vector64_Byte(); fixed (Vector64<Byte>* pFld1 = &test._fld1) fixed (Vector128<Byte>* pFld2 = &test._fld2) fixed (Vector64<Byte>* pFld3 = &test._fld3) { var result = AdvSimd.VectorTableLookupExtension( AdvSimd.LoadVector64((Byte*)(pFld1)), AdvSimd.LoadVector128((Byte*)(pFld2)), AdvSimd.LoadVector64((Byte*)(pFld3)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.VectorTableLookupExtension(_fld1, _fld2, _fld3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector64<Byte>* pFld1 = &_fld1) fixed (Vector128<Byte>* pFld2 = &_fld2) fixed (Vector64<Byte>* pFld3 = &_fld3) { var result = AdvSimd.VectorTableLookupExtension( AdvSimd.LoadVector64((Byte*)(pFld1)), AdvSimd.LoadVector128((Byte*)(pFld2)), AdvSimd.LoadVector64((Byte*)(pFld3)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = AdvSimd.VectorTableLookupExtension(test._fld1, test._fld2, test._fld3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = AdvSimd.VectorTableLookupExtension( AdvSimd.LoadVector64((Byte*)(&test._fld1)), AdvSimd.LoadVector128((Byte*)(&test._fld2)), AdvSimd.LoadVector64((Byte*)(&test._fld3)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector64<Byte> op1, Vector128<Byte> op2, Vector64<Byte> op3, void* result, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; Byte[] inArray3 = new Byte[Op3ElementCount]; Byte[] outArray = new Byte[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), op2); Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray3[0]), op3); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Byte>>()); ValidateResult(inArray1, inArray2, inArray3, outArray, method); } private void ValidateResult(void* op1, void* op2, void* op3, void* result, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; Byte[] inArray3 = new Byte[Op3ElementCount]; Byte[] outArray = new Byte[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector64<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray3[0]), ref Unsafe.AsRef<byte>(op3), (uint)Unsafe.SizeOf<Vector64<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Byte>>()); ValidateResult(inArray1, inArray2, inArray3, outArray, method); } private void ValidateResult(Byte[] firstOp, Byte[] secondOp, Byte[] thirdOp, Byte[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.TableVectorExtension(i, firstOp, thirdOp, secondOp) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.VectorTableLookupExtension)}<Byte>(Vector64<Byte>, Vector128<Byte>, Vector64<Byte>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($"secondOp: ({string.Join(", ", secondOp)})"); TestLibrary.TestFramework.LogInformation($" thirdOp: ({string.Join(", ", thirdOp)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void VectorTableLookupExtension_Vector64_Byte() { var test = new SimpleTernaryOpTest__VectorTableLookupExtension_Vector64_Byte(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleTernaryOpTest__VectorTableLookupExtension_Vector64_Byte { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] inArray3; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle inHandle3; private GCHandle outHandle; private ulong alignment; public DataTable(Byte[] inArray1, Byte[] inArray2, Byte[] inArray3, Byte[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Byte>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Byte>(); int sizeOfinArray3 = inArray3.Length * Unsafe.SizeOf<Byte>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Byte>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfinArray3 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.inArray3 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.inHandle3 = GCHandle.Alloc(this.inArray3, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Byte, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Byte, byte>(ref inArray2[0]), (uint)sizeOfinArray2); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray3Ptr), ref Unsafe.As<Byte, byte>(ref inArray3[0]), (uint)sizeOfinArray3); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray3Ptr => Align((byte*)(inHandle3.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); inHandle3.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector64<Byte> _fld1; public Vector128<Byte> _fld2; public Vector64<Byte> _fld3; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref testStruct._fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref testStruct._fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (Byte)(TestLibrary.Generator.GetByte() % 20); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref testStruct._fld3), ref Unsafe.As<Byte, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); return testStruct; } public void RunStructFldScenario(SimpleTernaryOpTest__VectorTableLookupExtension_Vector64_Byte testClass) { var result = AdvSimd.VectorTableLookupExtension(_fld1, _fld2, _fld3); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleTernaryOpTest__VectorTableLookupExtension_Vector64_Byte testClass) { fixed (Vector64<Byte>* pFld1 = &_fld1) fixed (Vector128<Byte>* pFld2 = &_fld2) fixed (Vector64<Byte>* pFld3 = &_fld3) { var result = AdvSimd.VectorTableLookupExtension( AdvSimd.LoadVector64((Byte*)(pFld1)), AdvSimd.LoadVector128((Byte*)(pFld2)), AdvSimd.LoadVector64((Byte*)(pFld3)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector64<Byte>>() / sizeof(Byte); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Byte>>() / sizeof(Byte); private static readonly int Op3ElementCount = Unsafe.SizeOf<Vector64<Byte>>() / sizeof(Byte); private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<Byte>>() / sizeof(Byte); private static Byte[] _data1 = new Byte[Op1ElementCount]; private static Byte[] _data2 = new Byte[Op2ElementCount]; private static Byte[] _data3 = new Byte[Op3ElementCount]; private static Vector64<Byte> _clsVar1; private static Vector128<Byte> _clsVar2; private static Vector64<Byte> _clsVar3; private Vector64<Byte> _fld1; private Vector128<Byte> _fld2; private Vector64<Byte> _fld3; private DataTable _dataTable; static SimpleTernaryOpTest__VectorTableLookupExtension_Vector64_Byte() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (Byte)(TestLibrary.Generator.GetByte() % 20); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _clsVar3), ref Unsafe.As<Byte, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); } public SimpleTernaryOpTest__VectorTableLookupExtension_Vector64_Byte() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (Byte)(TestLibrary.Generator.GetByte() % 20); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _fld3), ref Unsafe.As<Byte, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (Byte)(TestLibrary.Generator.GetByte() % 20); } _dataTable = new DataTable(_data1, _data2, _data3, new Byte[RetElementCount], LargestVectorSize); } public bool IsSupported => AdvSimd.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = AdvSimd.VectorTableLookupExtension( Unsafe.Read<Vector64<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr), Unsafe.Read<Vector64<Byte>>(_dataTable.inArray3Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = AdvSimd.VectorTableLookupExtension( AdvSimd.LoadVector64((Byte*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Byte*)(_dataTable.inArray2Ptr)), AdvSimd.LoadVector64((Byte*)(_dataTable.inArray3Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.VectorTableLookupExtension), new Type[] { typeof(Vector64<Byte>), typeof(Vector128<Byte>), typeof(Vector64<Byte>) }) .Invoke(null, new object[] { Unsafe.Read<Vector64<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr), Unsafe.Read<Vector64<Byte>>(_dataTable.inArray3Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Byte>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.VectorTableLookupExtension), new Type[] { typeof(Vector64<Byte>), typeof(Vector128<Byte>), typeof(Vector64<Byte>) }) .Invoke(null, new object[] { AdvSimd.LoadVector64((Byte*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Byte*)(_dataTable.inArray2Ptr)), AdvSimd.LoadVector64((Byte*)(_dataTable.inArray3Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Byte>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.VectorTableLookupExtension( _clsVar1, _clsVar2, _clsVar3 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _clsVar3, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector64<Byte>* pClsVar1 = &_clsVar1) fixed (Vector128<Byte>* pClsVar2 = &_clsVar2) fixed (Vector64<Byte>* pClsVar3 = &_clsVar3) { var result = AdvSimd.VectorTableLookupExtension( AdvSimd.LoadVector64((Byte*)(pClsVar1)), AdvSimd.LoadVector128((Byte*)(pClsVar2)), AdvSimd.LoadVector64((Byte*)(pClsVar3)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _clsVar3, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector64<Byte>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr); var op3 = Unsafe.Read<Vector64<Byte>>(_dataTable.inArray3Ptr); var result = AdvSimd.VectorTableLookupExtension(op1, op2, op3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, op3, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector64((Byte*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((Byte*)(_dataTable.inArray2Ptr)); var op3 = AdvSimd.LoadVector64((Byte*)(_dataTable.inArray3Ptr)); var result = AdvSimd.VectorTableLookupExtension(op1, op2, op3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, op3, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleTernaryOpTest__VectorTableLookupExtension_Vector64_Byte(); var result = AdvSimd.VectorTableLookupExtension(test._fld1, test._fld2, test._fld3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleTernaryOpTest__VectorTableLookupExtension_Vector64_Byte(); fixed (Vector64<Byte>* pFld1 = &test._fld1) fixed (Vector128<Byte>* pFld2 = &test._fld2) fixed (Vector64<Byte>* pFld3 = &test._fld3) { var result = AdvSimd.VectorTableLookupExtension( AdvSimd.LoadVector64((Byte*)(pFld1)), AdvSimd.LoadVector128((Byte*)(pFld2)), AdvSimd.LoadVector64((Byte*)(pFld3)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.VectorTableLookupExtension(_fld1, _fld2, _fld3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector64<Byte>* pFld1 = &_fld1) fixed (Vector128<Byte>* pFld2 = &_fld2) fixed (Vector64<Byte>* pFld3 = &_fld3) { var result = AdvSimd.VectorTableLookupExtension( AdvSimd.LoadVector64((Byte*)(pFld1)), AdvSimd.LoadVector128((Byte*)(pFld2)), AdvSimd.LoadVector64((Byte*)(pFld3)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = AdvSimd.VectorTableLookupExtension(test._fld1, test._fld2, test._fld3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = AdvSimd.VectorTableLookupExtension( AdvSimd.LoadVector64((Byte*)(&test._fld1)), AdvSimd.LoadVector128((Byte*)(&test._fld2)), AdvSimd.LoadVector64((Byte*)(&test._fld3)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector64<Byte> op1, Vector128<Byte> op2, Vector64<Byte> op3, void* result, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; Byte[] inArray3 = new Byte[Op3ElementCount]; Byte[] outArray = new Byte[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), op2); Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray3[0]), op3); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Byte>>()); ValidateResult(inArray1, inArray2, inArray3, outArray, method); } private void ValidateResult(void* op1, void* op2, void* op3, void* result, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; Byte[] inArray3 = new Byte[Op3ElementCount]; Byte[] outArray = new Byte[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector64<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray3[0]), ref Unsafe.AsRef<byte>(op3), (uint)Unsafe.SizeOf<Vector64<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Byte>>()); ValidateResult(inArray1, inArray2, inArray3, outArray, method); } private void ValidateResult(Byte[] firstOp, Byte[] secondOp, Byte[] thirdOp, Byte[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.TableVectorExtension(i, firstOp, thirdOp, secondOp) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.VectorTableLookupExtension)}<Byte>(Vector64<Byte>, Vector128<Byte>, Vector64<Byte>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($"secondOp: ({string.Join(", ", secondOp)})"); TestLibrary.TestFramework.LogInformation($" thirdOp: ({string.Join(", ", thirdOp)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/tests/JIT/CodeGenBringUpTests/BinaryRMW_d.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> <Optimize>False</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="BinaryRMW.cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> <Optimize>False</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="BinaryRMW.cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/tests/Loader/classloader/TypeInitialization/CctorsWithSideEffects/CctorThrowStaticField.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /* A .cctor has only one chance to run in any appdomain. If it fails, the 2nd time we try to access a static field we check if .cctor has been run. And it has, but failed so we fail again. Test_CctorThrowStaticField throws an exception inside .cctor. Try to access a static field twice. Expected: Should return the same exception. */ using System; public class A { public static int i; static A() { Console.WriteLine("In A.cctor"); A.i = 5; throw new Exception(); } } public struct B { public static int i; static B() { Console.WriteLine("In B.cctor"); B.i = 5; throw new Exception(); } } public class Test_CctorThrowStaticField { public static int Main() { bool result = true; try { Console.WriteLine("Accessing class's static field"); Console.WriteLine("A.i: " +A.i); Console.WriteLine("Did not catch expected TypeInitializationException exception"); result = false; } catch (TypeInitializationException) { Console.WriteLine("Caught expected exception 1st time"); } catch (Exception e) { Console.WriteLine("Caught unexpected exception 1st time: " + e); result = false; } try { Console.WriteLine("A.i: " +A.i); Console.WriteLine("Did not catch expected TypeInitializationException exception"); result = false; } catch (TypeInitializationException) { Console.WriteLine("Caught expected exception 2nd time\n"); } catch (Exception e) { Console.WriteLine("Caught unexpected exception 2nd time: " + e); result = false; } Console.WriteLine("Accessing struct's static field"); try { Console.WriteLine("B.i: " +B.i); Console.WriteLine("Did not catch expected TypeInitializationException exception"); result = false; } catch (TypeInitializationException) { Console.WriteLine("Caught expected exception 1st time"); } catch (Exception e) { Console.WriteLine("Caught unexpected exception 1st time: " + e); result = false; } try { Console.WriteLine("B.i: " +B.i); Console.WriteLine("Did not catch expected TypeInitializationException exception"); result = false; } catch (TypeInitializationException) { Console.WriteLine("Caught expected exception 2nd time\n"); } catch (Exception e) { Console.WriteLine("Caught unexpected exception 2nd time: " + e); result = false; } if (result) { Console.WriteLine("PASS"); return 100; } else { Console.WriteLine("FAIL"); return 101; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /* A .cctor has only one chance to run in any appdomain. If it fails, the 2nd time we try to access a static field we check if .cctor has been run. And it has, but failed so we fail again. Test_CctorThrowStaticField throws an exception inside .cctor. Try to access a static field twice. Expected: Should return the same exception. */ using System; public class A { public static int i; static A() { Console.WriteLine("In A.cctor"); A.i = 5; throw new Exception(); } } public struct B { public static int i; static B() { Console.WriteLine("In B.cctor"); B.i = 5; throw new Exception(); } } public class Test_CctorThrowStaticField { public static int Main() { bool result = true; try { Console.WriteLine("Accessing class's static field"); Console.WriteLine("A.i: " +A.i); Console.WriteLine("Did not catch expected TypeInitializationException exception"); result = false; } catch (TypeInitializationException) { Console.WriteLine("Caught expected exception 1st time"); } catch (Exception e) { Console.WriteLine("Caught unexpected exception 1st time: " + e); result = false; } try { Console.WriteLine("A.i: " +A.i); Console.WriteLine("Did not catch expected TypeInitializationException exception"); result = false; } catch (TypeInitializationException) { Console.WriteLine("Caught expected exception 2nd time\n"); } catch (Exception e) { Console.WriteLine("Caught unexpected exception 2nd time: " + e); result = false; } Console.WriteLine("Accessing struct's static field"); try { Console.WriteLine("B.i: " +B.i); Console.WriteLine("Did not catch expected TypeInitializationException exception"); result = false; } catch (TypeInitializationException) { Console.WriteLine("Caught expected exception 1st time"); } catch (Exception e) { Console.WriteLine("Caught unexpected exception 1st time: " + e); result = false; } try { Console.WriteLine("B.i: " +B.i); Console.WriteLine("Did not catch expected TypeInitializationException exception"); result = false; } catch (TypeInitializationException) { Console.WriteLine("Caught expected exception 2nd time\n"); } catch (Exception e) { Console.WriteLine("Caught unexpected exception 2nd time: " + e); result = false; } if (result) { Console.WriteLine("PASS"); return 100; } else { Console.WriteLine("FAIL"); return 101; } } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/libraries/System.Net.Mail/src/System/Net/Mime/SmtpDateTime.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Globalization; using System.Collections.Generic; using System.Diagnostics; namespace System.Net.Mime { #region RFC2822 date time string format description // Format of Date Time string as described by RFC 2822 section 4.3 which obsoletes // some field formats that were allowed under RFC 822 // date-time = [ day-of-week "," ] date FWS time [CFWS] // day-of-week = ([FWS] day-name) / obs-day-of-week // day-name = "Mon" / "Tue" / "Wed" / "Thu" / "Fri" / "Sat" / "Sun" // date = day month year // year = 4*DIGIT / obs-year // month = (FWS month-name FWS) / obs-month // month-name = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / "Jul" / "Aug" / // "Sep" / "Oct" / "Nov" / "Dec" // day = ([FWS] 1*2DIGIT) / obs-day // time = time-of-day FWS zone // time-of-day = hour ":" minute [ ":" second ] // hour = 2DIGIT / obs-hour // minute = 2DIGIT / obs-minute // second = 2DIGIT / obs-second // zone = (( "+" / "-" ) 4DIGIT) / obs-zone #endregion // stores a Date and a Time Zone. These are parsed and formatted according to the // rules in RFC 2822 section 3.3. // This class is immutable internal sealed class SmtpDateTime { #region constants // use this when a time zone is unknown or is not supplied internal const string UnknownTimeZoneDefaultOffset = "-0000"; internal const string UtcDefaultTimeZoneOffset = "+0000"; internal const int OffsetLength = 5; // range for absolute value of minutes. it is not necessary to include a max value for hours since // the two-digit value that is parsed can't exceed the max value of hours, which is 99 internal const int MaxMinuteValue = 59; // possible valid values for a date string // these do NOT include the timezone internal const string DateFormatWithDayOfWeek = "ddd, dd MMM yyyy HH:mm:ss"; internal const string DateFormatWithoutDayOfWeek = "dd MMM yyyy HH:mm:ss"; internal const string DateFormatWithDayOfWeekAndNoSeconds = "ddd, dd MMM yyyy HH:mm"; internal const string DateFormatWithoutDayOfWeekAndNoSeconds = "dd MMM yyyy HH:mm"; #endregion #region static fields // array of all possible date time values // if a string matches any one of these it will be parsed correctly internal static readonly string[] s_validDateTimeFormats = new string[] { DateFormatWithDayOfWeek, DateFormatWithoutDayOfWeek, DateFormatWithDayOfWeekAndNoSeconds, DateFormatWithoutDayOfWeekAndNoSeconds }; internal static readonly char[] s_allowedWhiteSpaceChars = new char[] { ' ', '\t' }; internal static readonly Dictionary<string, TimeSpan> s_timeZoneOffsetLookup = InitializeShortHandLookups(); // a TimeSpan must be between these two values in order for it to be within the range allowed // by RFC 2822 internal const long TimeSpanMaxTicks = TimeSpan.TicksPerHour * 99 + TimeSpan.TicksPerMinute * 59; // allowed max values for each digit. min value is always 0 internal const int OffsetMaxValue = 9959; #endregion #region static initializers internal static Dictionary<string, TimeSpan> InitializeShortHandLookups() { var tempTimeZoneOffsetLookup = new Dictionary<string, TimeSpan>(); // all well-known short hand time zone values and their semantic equivalents tempTimeZoneOffsetLookup.Add("UT", TimeSpan.Zero); // +0000 tempTimeZoneOffsetLookup.Add("GMT", TimeSpan.Zero); // +0000 tempTimeZoneOffsetLookup.Add("EDT", new TimeSpan(-4, 0, 0)); // -0400 tempTimeZoneOffsetLookup.Add("EST", new TimeSpan(-5, 0, 0)); // -0500 tempTimeZoneOffsetLookup.Add("CDT", new TimeSpan(-5, 0, 0)); // -0500 tempTimeZoneOffsetLookup.Add("CST", new TimeSpan(-6, 0, 0)); // -0600 tempTimeZoneOffsetLookup.Add("MDT", new TimeSpan(-6, 0, 0)); // -0600 tempTimeZoneOffsetLookup.Add("MST", new TimeSpan(-7, 0, 0)); // -0700 tempTimeZoneOffsetLookup.Add("PDT", new TimeSpan(-7, 0, 0)); // -0700 tempTimeZoneOffsetLookup.Add("PST", new TimeSpan(-8, 0, 0)); // -0800 return tempTimeZoneOffsetLookup; } #endregion #region private fields private readonly DateTime _date; private readonly TimeSpan _timeZone; // true if the time zone is unspecified i.e. -0000 // the time zone will usually be specified private readonly bool _unknownTimeZone; #endregion #region constructors internal SmtpDateTime(DateTime value) { _date = value; switch (value.Kind) { case DateTimeKind.Local: // GetUtcOffset takes local time zone information into account e.g. daylight savings time TimeSpan localTimeZone = TimeZoneInfo.Local.GetUtcOffset(value); _timeZone = ValidateAndGetSanitizedTimeSpan(localTimeZone); break; case DateTimeKind.Unspecified: _unknownTimeZone = true; break; case DateTimeKind.Utc: _timeZone = TimeSpan.Zero; break; } } internal SmtpDateTime(string value) { string timeZoneOffset; _date = ParseValue(value, out timeZoneOffset); if (!TryParseTimeZoneString(timeZoneOffset, out _timeZone)) { // time zone is unknown _unknownTimeZone = true; } } #endregion #region internal properties internal DateTime Date { get { if (_unknownTimeZone) { return DateTime.SpecifyKind(_date, DateTimeKind.Unspecified); } else { // DateTimeOffset will convert the value of this.date to the time as // specified in this.timeZone DateTimeOffset offset = new DateTimeOffset(_date, _timeZone); return offset.LocalDateTime; } } } #if DEBUG // this method is only called by test code internal string TimeZone => _unknownTimeZone ? UnknownTimeZoneDefaultOffset : TimeSpanToOffset(_timeZone); #endif #endregion #region internals // outputs the RFC 2822 formatted date string including time zone public override string ToString() => FormatDate(_date) + " " + (_unknownTimeZone ? UnknownTimeZoneDefaultOffset : TimeSpanToOffset(_timeZone)); // returns true if the offset is of the form [+|-]dddd and // within the range 0000 to 9959 internal void ValidateAndGetTimeZoneOffsetValues(string offset, out bool positive, out int hours, out int minutes) { Debug.Assert(!string.IsNullOrEmpty(offset), "violation of precondition: offset must not be null or empty"); Debug.Assert(offset != UnknownTimeZoneDefaultOffset, "Violation of precondition: do not pass an unknown offset"); Debug.Assert(offset.StartsWith('-') || offset.StartsWith('+'), "offset initial character was not a + or -"); if (offset.Length != OffsetLength) { throw new FormatException(SR.MailDateInvalidFormat); } positive = offset.StartsWith('+'); // TryParse will parse in base 10 by default. do not allow any styles of input beyond the default // which is numeric values only if (!int.TryParse(offset.AsSpan(1, 2), NumberStyles.None, CultureInfo.InvariantCulture, out hours)) { throw new FormatException(SR.MailDateInvalidFormat); } if (!int.TryParse(offset.AsSpan(3, 2), NumberStyles.None, CultureInfo.InvariantCulture, out minutes)) { throw new FormatException(SR.MailDateInvalidFormat); } // we only explicitly validate the minutes. they must be below 59 // the hours are implicitly validated as a number formed from a string of length // 2 can only be <= 99 if (minutes > MaxMinuteValue) { throw new FormatException(SR.MailDateInvalidFormat); } } // returns true if the time zone short hand is all alphabetical characters internal void ValidateTimeZoneShortHandValue(string value) { // time zones can't be empty Debug.Assert(!string.IsNullOrEmpty(value), "violation of precondition: offset must not be null or empty"); // time zones must all be alphabetical characters for (int i = 0; i < value.Length; i++) { if (!char.IsLetter(value, i)) { throw new FormatException(SR.Format(SR.MailHeaderFieldInvalidCharacter, value)); } } } // formats a date only. Does not include time zone internal string FormatDate(DateTime value) => value.ToString("ddd, dd MMM yyyy HH:mm:ss", CultureInfo.InvariantCulture); // parses the date and time zone // postconditions: // return value is valid DateTime representation of the Date portion of data // timeZone is the portion of data which should contain the time zone data // timeZone is NOT evaluated by ParseValue internal DateTime ParseValue(string data, out string timeZone) { // check that there is something to parse if (string.IsNullOrEmpty(data)) { throw new FormatException(SR.MailDateInvalidFormat); } // find the first occurrence of ':' // this tells us where the separator between hour and minute are int indexOfHourSeparator = data.IndexOf(':'); // no ':' means invalid value if (indexOfHourSeparator == -1) { throw new FormatException(SR.Format(SR.MailHeaderFieldInvalidCharacter, data)); } // now we know where hours and minutes are separated. The first whitespace after // that MUST be the separator between the time portion and the timezone portion // timezone may have additional spaces, characters, or comments after it but // this is ok since we'll parse that whole section later int indexOfTimeZoneSeparator = data.IndexOfAny(s_allowedWhiteSpaceChars, indexOfHourSeparator); if (indexOfTimeZoneSeparator == -1) { throw new FormatException(SR.Format(SR.MailHeaderFieldInvalidCharacter, data)); } // extract the time portion and remove all leading and trailing whitespace string date = data.AsSpan(0, indexOfTimeZoneSeparator).Trim().ToString(); // attempt to parse the DateTime component. DateTime dateValue; if (!DateTime.TryParseExact(date, s_validDateTimeFormats, CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces, out dateValue)) { throw new FormatException(SR.MailDateInvalidFormat); } // kind property will be Unspecified since no timezone info was in the date string Debug.Assert(dateValue.Kind == DateTimeKind.Unspecified); // extract the second half of the string. This will start with at least one whitespace character. // Trim the string to remove these characters. string timeZoneString = data.AsSpan(indexOfTimeZoneSeparator).Trim().ToString(); // find, if any, the first whitespace character after the timezone. // These will be CFWS and must be ignored. Remove them. int endOfTimeZoneOffset = timeZoneString.IndexOfAny(s_allowedWhiteSpaceChars); if (endOfTimeZoneOffset != -1) { timeZoneString = timeZoneString.Substring(0, endOfTimeZoneOffset); } if (string.IsNullOrEmpty(timeZoneString)) { throw new FormatException(SR.MailDateInvalidFormat); } timeZone = timeZoneString; return dateValue; } // if this returns true, timeZone is the correct TimeSpan representation of the input // if it returns false then the time zone is unknown and so timeZone must be ignored internal bool TryParseTimeZoneString(string timeZoneString, out TimeSpan timeZone) { // see if the zone is the special unspecified case, a numeric offset, or a shorthand string if (timeZoneString == UnknownTimeZoneDefaultOffset) { // The inputed time zone is the special value "unknown", -0000 timeZone = TimeSpan.Zero; return false; } else if ((timeZoneString[0] == '+' || timeZoneString[0] == '-')) { bool positive; int hours; int minutes; ValidateAndGetTimeZoneOffsetValues(timeZoneString, out positive, out hours, out minutes); // Apply the negative sign, if applicable, to whichever of hours or minutes is NOT 0. if (!positive) { if (hours != 0) { hours *= -1; } else if (minutes != 0) { minutes *= -1; } } timeZone = new TimeSpan(hours, minutes, 0); return true; } else { // not an offset so ensure that it contains no invalid characters ValidateTimeZoneShortHandValue(timeZoneString); // check if the shorthand value has a semantically equivalent offset return s_timeZoneOffsetLookup.TryGetValue(timeZoneString, out timeZone); } } internal TimeSpan ValidateAndGetSanitizedTimeSpan(TimeSpan span) { // sanitize the time span by removing the seconds and milliseconds. Days are not handled here TimeSpan sanitizedTimeSpan = new TimeSpan(span.Days, span.Hours, span.Minutes, 0, 0); // validate range of time span if (Math.Abs(sanitizedTimeSpan.Ticks) > TimeSpanMaxTicks) { throw new FormatException(SR.MailDateInvalidFormat); } return sanitizedTimeSpan; } // precondition: span must be sanitized and within a valid range internal string TimeSpanToOffset(TimeSpan span) { Debug.Assert(span.Seconds == 0, "Span had seconds value"); Debug.Assert(span.Milliseconds == 0, "Span had milliseconds value"); if (span.Ticks == 0) { return UtcDefaultTimeZoneOffset; } else { // get the total number of hours since TimeSpan.Hours won't go beyond 24 // ensure that it's a whole number since the fractional part represents minutes uint hours = (uint)Math.Abs(Math.Floor(span.TotalHours)); uint minutes = (uint)Math.Abs(span.Minutes); Debug.Assert((hours != 0) || (minutes != 0), "Input validation ensures hours or minutes isn't zero"); string output = span.Ticks > 0 ? "+" : "-"; // hours and minutes must be two digits if (hours < 10) { output += "0"; } output += hours.ToString(); if (minutes < 10) { output += "0"; } output += minutes.ToString(); return output; } } #endregion } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Globalization; using System.Collections.Generic; using System.Diagnostics; namespace System.Net.Mime { #region RFC2822 date time string format description // Format of Date Time string as described by RFC 2822 section 4.3 which obsoletes // some field formats that were allowed under RFC 822 // date-time = [ day-of-week "," ] date FWS time [CFWS] // day-of-week = ([FWS] day-name) / obs-day-of-week // day-name = "Mon" / "Tue" / "Wed" / "Thu" / "Fri" / "Sat" / "Sun" // date = day month year // year = 4*DIGIT / obs-year // month = (FWS month-name FWS) / obs-month // month-name = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / "Jul" / "Aug" / // "Sep" / "Oct" / "Nov" / "Dec" // day = ([FWS] 1*2DIGIT) / obs-day // time = time-of-day FWS zone // time-of-day = hour ":" minute [ ":" second ] // hour = 2DIGIT / obs-hour // minute = 2DIGIT / obs-minute // second = 2DIGIT / obs-second // zone = (( "+" / "-" ) 4DIGIT) / obs-zone #endregion // stores a Date and a Time Zone. These are parsed and formatted according to the // rules in RFC 2822 section 3.3. // This class is immutable internal sealed class SmtpDateTime { #region constants // use this when a time zone is unknown or is not supplied internal const string UnknownTimeZoneDefaultOffset = "-0000"; internal const string UtcDefaultTimeZoneOffset = "+0000"; internal const int OffsetLength = 5; // range for absolute value of minutes. it is not necessary to include a max value for hours since // the two-digit value that is parsed can't exceed the max value of hours, which is 99 internal const int MaxMinuteValue = 59; // possible valid values for a date string // these do NOT include the timezone internal const string DateFormatWithDayOfWeek = "ddd, dd MMM yyyy HH:mm:ss"; internal const string DateFormatWithoutDayOfWeek = "dd MMM yyyy HH:mm:ss"; internal const string DateFormatWithDayOfWeekAndNoSeconds = "ddd, dd MMM yyyy HH:mm"; internal const string DateFormatWithoutDayOfWeekAndNoSeconds = "dd MMM yyyy HH:mm"; #endregion #region static fields // array of all possible date time values // if a string matches any one of these it will be parsed correctly internal static readonly string[] s_validDateTimeFormats = new string[] { DateFormatWithDayOfWeek, DateFormatWithoutDayOfWeek, DateFormatWithDayOfWeekAndNoSeconds, DateFormatWithoutDayOfWeekAndNoSeconds }; internal static readonly char[] s_allowedWhiteSpaceChars = new char[] { ' ', '\t' }; internal static readonly Dictionary<string, TimeSpan> s_timeZoneOffsetLookup = InitializeShortHandLookups(); // a TimeSpan must be between these two values in order for it to be within the range allowed // by RFC 2822 internal const long TimeSpanMaxTicks = TimeSpan.TicksPerHour * 99 + TimeSpan.TicksPerMinute * 59; // allowed max values for each digit. min value is always 0 internal const int OffsetMaxValue = 9959; #endregion #region static initializers internal static Dictionary<string, TimeSpan> InitializeShortHandLookups() { var tempTimeZoneOffsetLookup = new Dictionary<string, TimeSpan>(); // all well-known short hand time zone values and their semantic equivalents tempTimeZoneOffsetLookup.Add("UT", TimeSpan.Zero); // +0000 tempTimeZoneOffsetLookup.Add("GMT", TimeSpan.Zero); // +0000 tempTimeZoneOffsetLookup.Add("EDT", new TimeSpan(-4, 0, 0)); // -0400 tempTimeZoneOffsetLookup.Add("EST", new TimeSpan(-5, 0, 0)); // -0500 tempTimeZoneOffsetLookup.Add("CDT", new TimeSpan(-5, 0, 0)); // -0500 tempTimeZoneOffsetLookup.Add("CST", new TimeSpan(-6, 0, 0)); // -0600 tempTimeZoneOffsetLookup.Add("MDT", new TimeSpan(-6, 0, 0)); // -0600 tempTimeZoneOffsetLookup.Add("MST", new TimeSpan(-7, 0, 0)); // -0700 tempTimeZoneOffsetLookup.Add("PDT", new TimeSpan(-7, 0, 0)); // -0700 tempTimeZoneOffsetLookup.Add("PST", new TimeSpan(-8, 0, 0)); // -0800 return tempTimeZoneOffsetLookup; } #endregion #region private fields private readonly DateTime _date; private readonly TimeSpan _timeZone; // true if the time zone is unspecified i.e. -0000 // the time zone will usually be specified private readonly bool _unknownTimeZone; #endregion #region constructors internal SmtpDateTime(DateTime value) { _date = value; switch (value.Kind) { case DateTimeKind.Local: // GetUtcOffset takes local time zone information into account e.g. daylight savings time TimeSpan localTimeZone = TimeZoneInfo.Local.GetUtcOffset(value); _timeZone = ValidateAndGetSanitizedTimeSpan(localTimeZone); break; case DateTimeKind.Unspecified: _unknownTimeZone = true; break; case DateTimeKind.Utc: _timeZone = TimeSpan.Zero; break; } } internal SmtpDateTime(string value) { string timeZoneOffset; _date = ParseValue(value, out timeZoneOffset); if (!TryParseTimeZoneString(timeZoneOffset, out _timeZone)) { // time zone is unknown _unknownTimeZone = true; } } #endregion #region internal properties internal DateTime Date { get { if (_unknownTimeZone) { return DateTime.SpecifyKind(_date, DateTimeKind.Unspecified); } else { // DateTimeOffset will convert the value of this.date to the time as // specified in this.timeZone DateTimeOffset offset = new DateTimeOffset(_date, _timeZone); return offset.LocalDateTime; } } } #if DEBUG // this method is only called by test code internal string TimeZone => _unknownTimeZone ? UnknownTimeZoneDefaultOffset : TimeSpanToOffset(_timeZone); #endif #endregion #region internals // outputs the RFC 2822 formatted date string including time zone public override string ToString() => FormatDate(_date) + " " + (_unknownTimeZone ? UnknownTimeZoneDefaultOffset : TimeSpanToOffset(_timeZone)); // returns true if the offset is of the form [+|-]dddd and // within the range 0000 to 9959 internal void ValidateAndGetTimeZoneOffsetValues(string offset, out bool positive, out int hours, out int minutes) { Debug.Assert(!string.IsNullOrEmpty(offset), "violation of precondition: offset must not be null or empty"); Debug.Assert(offset != UnknownTimeZoneDefaultOffset, "Violation of precondition: do not pass an unknown offset"); Debug.Assert(offset.StartsWith('-') || offset.StartsWith('+'), "offset initial character was not a + or -"); if (offset.Length != OffsetLength) { throw new FormatException(SR.MailDateInvalidFormat); } positive = offset.StartsWith('+'); // TryParse will parse in base 10 by default. do not allow any styles of input beyond the default // which is numeric values only if (!int.TryParse(offset.AsSpan(1, 2), NumberStyles.None, CultureInfo.InvariantCulture, out hours)) { throw new FormatException(SR.MailDateInvalidFormat); } if (!int.TryParse(offset.AsSpan(3, 2), NumberStyles.None, CultureInfo.InvariantCulture, out minutes)) { throw new FormatException(SR.MailDateInvalidFormat); } // we only explicitly validate the minutes. they must be below 59 // the hours are implicitly validated as a number formed from a string of length // 2 can only be <= 99 if (minutes > MaxMinuteValue) { throw new FormatException(SR.MailDateInvalidFormat); } } // returns true if the time zone short hand is all alphabetical characters internal void ValidateTimeZoneShortHandValue(string value) { // time zones can't be empty Debug.Assert(!string.IsNullOrEmpty(value), "violation of precondition: offset must not be null or empty"); // time zones must all be alphabetical characters for (int i = 0; i < value.Length; i++) { if (!char.IsLetter(value, i)) { throw new FormatException(SR.Format(SR.MailHeaderFieldInvalidCharacter, value)); } } } // formats a date only. Does not include time zone internal string FormatDate(DateTime value) => value.ToString("ddd, dd MMM yyyy HH:mm:ss", CultureInfo.InvariantCulture); // parses the date and time zone // postconditions: // return value is valid DateTime representation of the Date portion of data // timeZone is the portion of data which should contain the time zone data // timeZone is NOT evaluated by ParseValue internal DateTime ParseValue(string data, out string timeZone) { // check that there is something to parse if (string.IsNullOrEmpty(data)) { throw new FormatException(SR.MailDateInvalidFormat); } // find the first occurrence of ':' // this tells us where the separator between hour and minute are int indexOfHourSeparator = data.IndexOf(':'); // no ':' means invalid value if (indexOfHourSeparator == -1) { throw new FormatException(SR.Format(SR.MailHeaderFieldInvalidCharacter, data)); } // now we know where hours and minutes are separated. The first whitespace after // that MUST be the separator between the time portion and the timezone portion // timezone may have additional spaces, characters, or comments after it but // this is ok since we'll parse that whole section later int indexOfTimeZoneSeparator = data.IndexOfAny(s_allowedWhiteSpaceChars, indexOfHourSeparator); if (indexOfTimeZoneSeparator == -1) { throw new FormatException(SR.Format(SR.MailHeaderFieldInvalidCharacter, data)); } // extract the time portion and remove all leading and trailing whitespace string date = data.AsSpan(0, indexOfTimeZoneSeparator).Trim().ToString(); // attempt to parse the DateTime component. DateTime dateValue; if (!DateTime.TryParseExact(date, s_validDateTimeFormats, CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces, out dateValue)) { throw new FormatException(SR.MailDateInvalidFormat); } // kind property will be Unspecified since no timezone info was in the date string Debug.Assert(dateValue.Kind == DateTimeKind.Unspecified); // extract the second half of the string. This will start with at least one whitespace character. // Trim the string to remove these characters. string timeZoneString = data.AsSpan(indexOfTimeZoneSeparator).Trim().ToString(); // find, if any, the first whitespace character after the timezone. // These will be CFWS and must be ignored. Remove them. int endOfTimeZoneOffset = timeZoneString.IndexOfAny(s_allowedWhiteSpaceChars); if (endOfTimeZoneOffset != -1) { timeZoneString = timeZoneString.Substring(0, endOfTimeZoneOffset); } if (string.IsNullOrEmpty(timeZoneString)) { throw new FormatException(SR.MailDateInvalidFormat); } timeZone = timeZoneString; return dateValue; } // if this returns true, timeZone is the correct TimeSpan representation of the input // if it returns false then the time zone is unknown and so timeZone must be ignored internal bool TryParseTimeZoneString(string timeZoneString, out TimeSpan timeZone) { // see if the zone is the special unspecified case, a numeric offset, or a shorthand string if (timeZoneString == UnknownTimeZoneDefaultOffset) { // The inputed time zone is the special value "unknown", -0000 timeZone = TimeSpan.Zero; return false; } else if ((timeZoneString[0] == '+' || timeZoneString[0] == '-')) { bool positive; int hours; int minutes; ValidateAndGetTimeZoneOffsetValues(timeZoneString, out positive, out hours, out minutes); // Apply the negative sign, if applicable, to whichever of hours or minutes is NOT 0. if (!positive) { if (hours != 0) { hours *= -1; } else if (minutes != 0) { minutes *= -1; } } timeZone = new TimeSpan(hours, minutes, 0); return true; } else { // not an offset so ensure that it contains no invalid characters ValidateTimeZoneShortHandValue(timeZoneString); // check if the shorthand value has a semantically equivalent offset return s_timeZoneOffsetLookup.TryGetValue(timeZoneString, out timeZone); } } internal TimeSpan ValidateAndGetSanitizedTimeSpan(TimeSpan span) { // sanitize the time span by removing the seconds and milliseconds. Days are not handled here TimeSpan sanitizedTimeSpan = new TimeSpan(span.Days, span.Hours, span.Minutes, 0, 0); // validate range of time span if (Math.Abs(sanitizedTimeSpan.Ticks) > TimeSpanMaxTicks) { throw new FormatException(SR.MailDateInvalidFormat); } return sanitizedTimeSpan; } // precondition: span must be sanitized and within a valid range internal string TimeSpanToOffset(TimeSpan span) { Debug.Assert(span.Seconds == 0, "Span had seconds value"); Debug.Assert(span.Milliseconds == 0, "Span had milliseconds value"); if (span.Ticks == 0) { return UtcDefaultTimeZoneOffset; } else { // get the total number of hours since TimeSpan.Hours won't go beyond 24 // ensure that it's a whole number since the fractional part represents minutes uint hours = (uint)Math.Abs(Math.Floor(span.TotalHours)); uint minutes = (uint)Math.Abs(span.Minutes); Debug.Assert((hours != 0) || (minutes != 0), "Input validation ensures hours or minutes isn't zero"); string output = span.Ticks > 0 ? "+" : "-"; // hours and minutes must be two digits if (hours < 10) { output += "0"; } output += hours.ToString(); if (minutes < 10) { output += "0"; } output += minutes.ToString(); return output; } } #endregion } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./src/libraries/System.Web.HttpUtility/src/System/Web/Util/HttpEncoder.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Net; using System.Text; namespace System.Web.Util { internal static class HttpEncoder { private static void AppendCharAsUnicodeJavaScript(StringBuilder builder, char c) { builder.Append($"\\u{(int)c:x4}"); } private static bool CharRequiresJavaScriptEncoding(char c) => c < 0x20 // control chars always have to be encoded || c == '\"' // chars which must be encoded per JSON spec || c == '\\' || c == '\'' // HTML-sensitive chars encoded for safety || c == '<' || c == '>' || (c == '&') || c == '\u0085' // newline chars (see Unicode 6.2, Table 5-1 [http://www.unicode.org/versions/Unicode6.2.0/ch05.pdf]) have to be encoded || c == '\u2028' || c == '\u2029'; [return: NotNullIfNotNull("value")] internal static string? HtmlAttributeEncode(string? value) { if (string.IsNullOrEmpty(value)) { return value; } // Don't create string writer if we don't have nothing to encode int pos = IndexOfHtmlAttributeEncodingChars(value, 0); if (pos == -1) { return value; } StringWriter writer = new StringWriter(CultureInfo.InvariantCulture); HtmlAttributeEncode(value, writer); return writer.ToString(); } internal static void HtmlAttributeEncode(string? value, TextWriter output) { if (value == null) { return; } ArgumentNullException.ThrowIfNull(output); HtmlAttributeEncodeInternal(value, output); } private static void HtmlAttributeEncodeInternal(string s, TextWriter output) { int index = IndexOfHtmlAttributeEncodingChars(s, 0); if (index == -1) { output.Write(s); } else { output.Write(s.AsSpan(0, index)); ReadOnlySpan<char> remaining = s.AsSpan(index); for (int i = 0; i < remaining.Length; i++) { char ch = remaining[i]; if (ch <= '<') { switch (ch) { case '<': output.Write("&lt;"); break; case '"': output.Write("&quot;"); break; case '\'': output.Write("&#39;"); break; case '&': output.Write("&amp;"); break; default: output.Write(ch); break; } } else { output.Write(ch); } } } } [return: NotNullIfNotNull("value")] internal static string? HtmlDecode(string? value) => string.IsNullOrEmpty(value) ? value : WebUtility.HtmlDecode(value); internal static void HtmlDecode(string? value, TextWriter output!!) { output.Write(WebUtility.HtmlDecode(value)); } [return: NotNullIfNotNull("value")] internal static string? HtmlEncode(string? value) => string.IsNullOrEmpty(value) ? value : WebUtility.HtmlEncode(value); internal static void HtmlEncode(string? value, TextWriter output!!) { output.Write(WebUtility.HtmlEncode(value)); } private static int IndexOfHtmlAttributeEncodingChars(string s, int startPos) { Debug.Assert(0 <= startPos && startPos <= s.Length, "0 <= startPos && startPos <= s.Length"); ReadOnlySpan<char> span = s.AsSpan(startPos); for (int i = 0; i < span.Length; i++) { char ch = span[i]; if (ch <= '<') { switch (ch) { case '<': case '"': case '\'': case '&': return startPos + i; } } } return -1; } private static bool IsNonAsciiByte(byte b) => b >= 0x7F || b < 0x20; internal static string JavaScriptStringEncode(string? value) { if (string.IsNullOrEmpty(value)) { return string.Empty; } StringBuilder? b = null; int startIndex = 0; int count = 0; for (int i = 0; i < value.Length; i++) { char c = value[i]; // Append the unhandled characters (that do not require special treament) // to the string builder when special characters are detected. if (CharRequiresJavaScriptEncoding(c)) { if (b == null) { b = new StringBuilder(value.Length + 5); } if (count > 0) { b.Append(value, startIndex, count); } startIndex = i + 1; count = 0; switch (c) { case '\r': b.Append("\\r"); break; case '\t': b.Append("\\t"); break; case '\"': b.Append("\\\""); break; case '\\': b.Append("\\\\"); break; case '\n': b.Append("\\n"); break; case '\b': b.Append("\\b"); break; case '\f': b.Append("\\f"); break; default: AppendCharAsUnicodeJavaScript(b, c); break; } } else { count++; } } if (b == null) { return value; } if (count > 0) { b.Append(value, startIndex, count); } return b.ToString(); } [return: NotNullIfNotNull("bytes")] internal static byte[]? UrlDecode(byte[]? bytes, int offset, int count) { if (!ValidateUrlEncodingParameters(bytes, offset, count)) { return null; } int decodedBytesCount = 0; byte[] decodedBytes = new byte[count]; for (int i = 0; i < count; i++) { int pos = offset + i; byte b = bytes[pos]; if (b == '+') { b = (byte)' '; } else if (b == '%' && i < count - 2) { int h1 = HexConverter.FromChar(bytes[pos + 1]); int h2 = HexConverter.FromChar(bytes[pos + 2]); if ((h1 | h2) != 0xFF) { // valid 2 hex chars b = (byte)((h1 << 4) | h2); i += 2; } } decodedBytes[decodedBytesCount++] = b; } if (decodedBytesCount < decodedBytes.Length) { byte[] newDecodedBytes = new byte[decodedBytesCount]; Array.Copy(decodedBytes, newDecodedBytes, decodedBytesCount); decodedBytes = newDecodedBytes; } return decodedBytes; } [return: NotNullIfNotNull("bytes")] internal static string? UrlDecode(byte[]? bytes, int offset, int count, Encoding encoding) { if (!ValidateUrlEncodingParameters(bytes, offset, count)) { return null; } UrlDecoder helper = new UrlDecoder(count, encoding); // go through the bytes collapsing %XX and %uXXXX and appending // each byte as byte, with exception of %uXXXX constructs that // are appended as chars for (int i = 0; i < count; i++) { int pos = offset + i; byte b = bytes[pos]; // The code assumes that + and % cannot be in multibyte sequence if (b == '+') { b = (byte)' '; } else if (b == '%' && i < count - 2) { if (bytes[pos + 1] == 'u' && i < count - 5) { int h1 = HexConverter.FromChar(bytes[pos + 2]); int h2 = HexConverter.FromChar(bytes[pos + 3]); int h3 = HexConverter.FromChar(bytes[pos + 4]); int h4 = HexConverter.FromChar(bytes[pos + 5]); if ((h1 | h2 | h3 | h4) != 0xFF) { // valid 4 hex chars char ch = (char)((h1 << 12) | (h2 << 8) | (h3 << 4) | h4); i += 5; // don't add as byte helper.AddChar(ch); continue; } } else { int h1 = HexConverter.FromChar(bytes[pos + 1]); int h2 = HexConverter.FromChar(bytes[pos + 2]); if ((h1 | h2) != 0xFF) { // valid 2 hex chars b = (byte)((h1 << 4) | h2); i += 2; } } } helper.AddByte(b); } return Utf16StringValidator.ValidateString(helper.GetString()); } [return: NotNullIfNotNull("value")] internal static string? UrlDecode(string? value, Encoding encoding) { if (value == null) { return null; } int count = value.Length; UrlDecoder helper = new UrlDecoder(count, encoding); // go through the string's chars collapsing %XX and %uXXXX and // appending each char as char, with exception of %XX constructs // that are appended as bytes for (int pos = 0; pos < count; pos++) { char ch = value[pos]; if (ch == '+') { ch = ' '; } else if (ch == '%' && pos < count - 2) { if (value[pos + 1] == 'u' && pos < count - 5) { int h1 = HexConverter.FromChar(value[pos + 2]); int h2 = HexConverter.FromChar(value[pos + 3]); int h3 = HexConverter.FromChar(value[pos + 4]); int h4 = HexConverter.FromChar(value[pos + 5]); if ((h1 | h2 | h3 | h4) != 0xFF) { // valid 4 hex chars ch = (char)((h1 << 12) | (h2 << 8) | (h3 << 4) | h4); pos += 5; // only add as char helper.AddChar(ch); continue; } } else { int h1 = HexConverter.FromChar(value[pos + 1]); int h2 = HexConverter.FromChar(value[pos + 2]); if ((h1 | h2) != 0xFF) { // valid 2 hex chars byte b = (byte)((h1 << 4) | h2); pos += 2; // don't add as char helper.AddByte(b); continue; } } } if ((ch & 0xFF80) == 0) { helper.AddByte((byte)ch); // 7 bit have to go as bytes because of Unicode } else { helper.AddChar(ch); } } return Utf16StringValidator.ValidateString(helper.GetString()); } [return: NotNullIfNotNull("bytes")] internal static byte[]? UrlEncode(byte[]? bytes, int offset, int count, bool alwaysCreateNewReturnValue) { byte[]? encoded = UrlEncode(bytes, offset, count); return (alwaysCreateNewReturnValue && (encoded != null) && (encoded == bytes)) ? (byte[])encoded.Clone() : encoded; } [return: NotNullIfNotNull("bytes")] private static byte[]? UrlEncode(byte[]? bytes, int offset, int count) { if (!ValidateUrlEncodingParameters(bytes, offset, count)) { return null; } int cSpaces = 0; int cUnsafe = 0; // count them first for (int i = 0; i < count; i++) { char ch = (char)bytes[offset + i]; if (ch == ' ') { cSpaces++; } else if (!HttpEncoderUtility.IsUrlSafeChar(ch)) { cUnsafe++; } } // nothing to expand? if (cSpaces == 0 && cUnsafe == 0) { // DevDiv 912606: respect "offset" and "count" if (0 == offset && bytes.Length == count) { return bytes; } else { byte[] subarray = new byte[count]; Buffer.BlockCopy(bytes, offset, subarray, 0, count); return subarray; } } // expand not 'safe' characters into %XX, spaces to +s byte[] expandedBytes = new byte[count + cUnsafe * 2]; int pos = 0; for (int i = 0; i < count; i++) { byte b = bytes[offset + i]; char ch = (char)b; if (HttpEncoderUtility.IsUrlSafeChar(ch)) { expandedBytes[pos++] = b; } else if (ch == ' ') { expandedBytes[pos++] = (byte)'+'; } else { expandedBytes[pos++] = (byte)'%'; expandedBytes[pos++] = (byte)HexConverter.ToCharLower(b >> 4); expandedBytes[pos++] = (byte)HexConverter.ToCharLower(b); } } return expandedBytes; } // Helper to encode the non-ASCII url characters only private static string UrlEncodeNonAscii(string str, Encoding e) { Debug.Assert(!string.IsNullOrEmpty(str)); Debug.Assert(e != null); byte[] bytes = e.GetBytes(str); byte[] encodedBytes = UrlEncodeNonAscii(bytes, 0, bytes.Length); return Encoding.ASCII.GetString(encodedBytes); } private static byte[] UrlEncodeNonAscii(byte[] bytes, int offset, int count) { int cNonAscii = 0; // count them first for (int i = 0; i < count; i++) { if (IsNonAsciiByte(bytes[offset + i])) { cNonAscii++; } } // nothing to expand? if (cNonAscii == 0) { return bytes; } // expand not 'safe' characters into %XX, spaces to +s byte[] expandedBytes = new byte[count + cNonAscii * 2]; int pos = 0; for (int i = 0; i < count; i++) { byte b = bytes[offset + i]; if (IsNonAsciiByte(b)) { expandedBytes[pos++] = (byte)'%'; expandedBytes[pos++] = (byte)HexConverter.ToCharLower(b >> 4); expandedBytes[pos++] = (byte)HexConverter.ToCharLower(b); } else { expandedBytes[pos++] = b; } } return expandedBytes; } [Obsolete("This method produces non-standards-compliant output and has interoperability issues. The preferred alternative is UrlEncode(*).")] [return: NotNullIfNotNull("value")] internal static string? UrlEncodeUnicode(string? value) { if (value == null) { return null; } int l = value.Length; StringBuilder sb = new StringBuilder(l); for (int i = 0; i < l; i++) { char ch = value[i]; if ((ch & 0xff80) == 0) { // 7 bit? if (HttpEncoderUtility.IsUrlSafeChar(ch)) { sb.Append(ch); } else if (ch == ' ') { sb.Append('+'); } else { sb.Append('%'); sb.Append(HexConverter.ToCharLower(ch >> 4)); sb.Append(HexConverter.ToCharLower(ch)); } } else { // arbitrary Unicode? sb.Append("%u"); sb.Append(HexConverter.ToCharLower(ch >> 12)); sb.Append(HexConverter.ToCharLower(ch >> 8)); sb.Append(HexConverter.ToCharLower(ch >> 4)); sb.Append(HexConverter.ToCharLower(ch)); } } return sb.ToString(); } [return: NotNullIfNotNull("value")] internal static string? UrlPathEncode(string? value) { if (string.IsNullOrEmpty(value)) { return value; } string? schemeAndAuthority; string? path; string? queryAndFragment; if (!UriUtil.TrySplitUriForPathEncode(value, out schemeAndAuthority, out path, out queryAndFragment)) { // If the value is not a valid url, we treat it as a relative url. // We don't need to extract query string from the url since UrlPathEncode() // does not encode query string. schemeAndAuthority = null; path = value; queryAndFragment = null; } return schemeAndAuthority + UrlPathEncodeImpl(path) + queryAndFragment; } // This is the original UrlPathEncode(string) private static string UrlPathEncodeImpl(string value) { if (string.IsNullOrEmpty(value)) { return value; } // recurse in case there is a query string int i = value.IndexOf('?'); if (i >= 0) { return string.Concat(UrlPathEncodeImpl(value.Substring(0, i)), value.AsSpan(i)); } // encode DBCS characters and spaces only return HttpEncoderUtility.UrlEncodeSpaces(UrlEncodeNonAscii(value, Encoding.UTF8)); } private static bool ValidateUrlEncodingParameters([NotNullWhen(true)] byte[]? bytes, int offset, int count) { if (bytes == null && count == 0) { return false; } ArgumentNullException.ThrowIfNull(bytes); if (offset < 0 || offset > bytes.Length) { throw new ArgumentOutOfRangeException(nameof(offset)); } if (count < 0 || offset + count > bytes.Length) { throw new ArgumentOutOfRangeException(nameof(count)); } return true; } // Internal class to facilitate URL decoding -- keeps char buffer and byte buffer, allows appending of either chars or bytes private sealed class UrlDecoder { private readonly int _bufferSize; // Accumulate characters in a special array private int _numChars; private readonly char[] _charBuffer; // Accumulate bytes for decoding into characters in a special array private int _numBytes; private byte[]? _byteBuffer; // Encoding to convert chars to bytes private readonly Encoding _encoding; private void FlushBytes() { if (_numBytes > 0) { Debug.Assert(_byteBuffer != null); _numChars += _encoding.GetChars(_byteBuffer, 0, _numBytes, _charBuffer, _numChars); _numBytes = 0; } } internal UrlDecoder(int bufferSize, Encoding encoding) { _bufferSize = bufferSize; _encoding = encoding; _charBuffer = new char[bufferSize]; // byte buffer created on demand } internal void AddChar(char ch) { if (_numBytes > 0) { FlushBytes(); } _charBuffer[_numChars++] = ch; } internal void AddByte(byte b) { // if there are no pending bytes treat 7 bit bytes as characters // this optimization is temp disable as it doesn't work for some encodings /* if (_numBytes == 0 && ((b & 0x80) == 0)) { AddChar((char)b); } else */ { if (_byteBuffer == null) { _byteBuffer = new byte[_bufferSize]; } _byteBuffer[_numBytes++] = b; } } internal string GetString() { if (_numBytes > 0) { FlushBytes(); } return _numChars > 0 ? new string(_charBuffer, 0, _numChars) : ""; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Net; using System.Text; namespace System.Web.Util { internal static class HttpEncoder { private static void AppendCharAsUnicodeJavaScript(StringBuilder builder, char c) { builder.Append($"\\u{(int)c:x4}"); } private static bool CharRequiresJavaScriptEncoding(char c) => c < 0x20 // control chars always have to be encoded || c == '\"' // chars which must be encoded per JSON spec || c == '\\' || c == '\'' // HTML-sensitive chars encoded for safety || c == '<' || c == '>' || (c == '&') || c == '\u0085' // newline chars (see Unicode 6.2, Table 5-1 [http://www.unicode.org/versions/Unicode6.2.0/ch05.pdf]) have to be encoded || c == '\u2028' || c == '\u2029'; [return: NotNullIfNotNull("value")] internal static string? HtmlAttributeEncode(string? value) { if (string.IsNullOrEmpty(value)) { return value; } // Don't create string writer if we don't have nothing to encode int pos = IndexOfHtmlAttributeEncodingChars(value, 0); if (pos == -1) { return value; } StringWriter writer = new StringWriter(CultureInfo.InvariantCulture); HtmlAttributeEncode(value, writer); return writer.ToString(); } internal static void HtmlAttributeEncode(string? value, TextWriter output) { if (value == null) { return; } ArgumentNullException.ThrowIfNull(output); HtmlAttributeEncodeInternal(value, output); } private static void HtmlAttributeEncodeInternal(string s, TextWriter output) { int index = IndexOfHtmlAttributeEncodingChars(s, 0); if (index == -1) { output.Write(s); } else { output.Write(s.AsSpan(0, index)); ReadOnlySpan<char> remaining = s.AsSpan(index); for (int i = 0; i < remaining.Length; i++) { char ch = remaining[i]; if (ch <= '<') { switch (ch) { case '<': output.Write("&lt;"); break; case '"': output.Write("&quot;"); break; case '\'': output.Write("&#39;"); break; case '&': output.Write("&amp;"); break; default: output.Write(ch); break; } } else { output.Write(ch); } } } } [return: NotNullIfNotNull("value")] internal static string? HtmlDecode(string? value) => string.IsNullOrEmpty(value) ? value : WebUtility.HtmlDecode(value); internal static void HtmlDecode(string? value, TextWriter output!!) { output.Write(WebUtility.HtmlDecode(value)); } [return: NotNullIfNotNull("value")] internal static string? HtmlEncode(string? value) => string.IsNullOrEmpty(value) ? value : WebUtility.HtmlEncode(value); internal static void HtmlEncode(string? value, TextWriter output!!) { output.Write(WebUtility.HtmlEncode(value)); } private static int IndexOfHtmlAttributeEncodingChars(string s, int startPos) { Debug.Assert(0 <= startPos && startPos <= s.Length, "0 <= startPos && startPos <= s.Length"); ReadOnlySpan<char> span = s.AsSpan(startPos); for (int i = 0; i < span.Length; i++) { char ch = span[i]; if (ch <= '<') { switch (ch) { case '<': case '"': case '\'': case '&': return startPos + i; } } } return -1; } private static bool IsNonAsciiByte(byte b) => b >= 0x7F || b < 0x20; internal static string JavaScriptStringEncode(string? value) { if (string.IsNullOrEmpty(value)) { return string.Empty; } StringBuilder? b = null; int startIndex = 0; int count = 0; for (int i = 0; i < value.Length; i++) { char c = value[i]; // Append the unhandled characters (that do not require special treament) // to the string builder when special characters are detected. if (CharRequiresJavaScriptEncoding(c)) { if (b == null) { b = new StringBuilder(value.Length + 5); } if (count > 0) { b.Append(value, startIndex, count); } startIndex = i + 1; count = 0; switch (c) { case '\r': b.Append("\\r"); break; case '\t': b.Append("\\t"); break; case '\"': b.Append("\\\""); break; case '\\': b.Append("\\\\"); break; case '\n': b.Append("\\n"); break; case '\b': b.Append("\\b"); break; case '\f': b.Append("\\f"); break; default: AppendCharAsUnicodeJavaScript(b, c); break; } } else { count++; } } if (b == null) { return value; } if (count > 0) { b.Append(value, startIndex, count); } return b.ToString(); } [return: NotNullIfNotNull("bytes")] internal static byte[]? UrlDecode(byte[]? bytes, int offset, int count) { if (!ValidateUrlEncodingParameters(bytes, offset, count)) { return null; } int decodedBytesCount = 0; byte[] decodedBytes = new byte[count]; for (int i = 0; i < count; i++) { int pos = offset + i; byte b = bytes[pos]; if (b == '+') { b = (byte)' '; } else if (b == '%' && i < count - 2) { int h1 = HexConverter.FromChar(bytes[pos + 1]); int h2 = HexConverter.FromChar(bytes[pos + 2]); if ((h1 | h2) != 0xFF) { // valid 2 hex chars b = (byte)((h1 << 4) | h2); i += 2; } } decodedBytes[decodedBytesCount++] = b; } if (decodedBytesCount < decodedBytes.Length) { byte[] newDecodedBytes = new byte[decodedBytesCount]; Array.Copy(decodedBytes, newDecodedBytes, decodedBytesCount); decodedBytes = newDecodedBytes; } return decodedBytes; } [return: NotNullIfNotNull("bytes")] internal static string? UrlDecode(byte[]? bytes, int offset, int count, Encoding encoding) { if (!ValidateUrlEncodingParameters(bytes, offset, count)) { return null; } UrlDecoder helper = new UrlDecoder(count, encoding); // go through the bytes collapsing %XX and %uXXXX and appending // each byte as byte, with exception of %uXXXX constructs that // are appended as chars for (int i = 0; i < count; i++) { int pos = offset + i; byte b = bytes[pos]; // The code assumes that + and % cannot be in multibyte sequence if (b == '+') { b = (byte)' '; } else if (b == '%' && i < count - 2) { if (bytes[pos + 1] == 'u' && i < count - 5) { int h1 = HexConverter.FromChar(bytes[pos + 2]); int h2 = HexConverter.FromChar(bytes[pos + 3]); int h3 = HexConverter.FromChar(bytes[pos + 4]); int h4 = HexConverter.FromChar(bytes[pos + 5]); if ((h1 | h2 | h3 | h4) != 0xFF) { // valid 4 hex chars char ch = (char)((h1 << 12) | (h2 << 8) | (h3 << 4) | h4); i += 5; // don't add as byte helper.AddChar(ch); continue; } } else { int h1 = HexConverter.FromChar(bytes[pos + 1]); int h2 = HexConverter.FromChar(bytes[pos + 2]); if ((h1 | h2) != 0xFF) { // valid 2 hex chars b = (byte)((h1 << 4) | h2); i += 2; } } } helper.AddByte(b); } return Utf16StringValidator.ValidateString(helper.GetString()); } [return: NotNullIfNotNull("value")] internal static string? UrlDecode(string? value, Encoding encoding) { if (value == null) { return null; } int count = value.Length; UrlDecoder helper = new UrlDecoder(count, encoding); // go through the string's chars collapsing %XX and %uXXXX and // appending each char as char, with exception of %XX constructs // that are appended as bytes for (int pos = 0; pos < count; pos++) { char ch = value[pos]; if (ch == '+') { ch = ' '; } else if (ch == '%' && pos < count - 2) { if (value[pos + 1] == 'u' && pos < count - 5) { int h1 = HexConverter.FromChar(value[pos + 2]); int h2 = HexConverter.FromChar(value[pos + 3]); int h3 = HexConverter.FromChar(value[pos + 4]); int h4 = HexConverter.FromChar(value[pos + 5]); if ((h1 | h2 | h3 | h4) != 0xFF) { // valid 4 hex chars ch = (char)((h1 << 12) | (h2 << 8) | (h3 << 4) | h4); pos += 5; // only add as char helper.AddChar(ch); continue; } } else { int h1 = HexConverter.FromChar(value[pos + 1]); int h2 = HexConverter.FromChar(value[pos + 2]); if ((h1 | h2) != 0xFF) { // valid 2 hex chars byte b = (byte)((h1 << 4) | h2); pos += 2; // don't add as char helper.AddByte(b); continue; } } } if ((ch & 0xFF80) == 0) { helper.AddByte((byte)ch); // 7 bit have to go as bytes because of Unicode } else { helper.AddChar(ch); } } return Utf16StringValidator.ValidateString(helper.GetString()); } [return: NotNullIfNotNull("bytes")] internal static byte[]? UrlEncode(byte[]? bytes, int offset, int count, bool alwaysCreateNewReturnValue) { byte[]? encoded = UrlEncode(bytes, offset, count); return (alwaysCreateNewReturnValue && (encoded != null) && (encoded == bytes)) ? (byte[])encoded.Clone() : encoded; } [return: NotNullIfNotNull("bytes")] private static byte[]? UrlEncode(byte[]? bytes, int offset, int count) { if (!ValidateUrlEncodingParameters(bytes, offset, count)) { return null; } int cSpaces = 0; int cUnsafe = 0; // count them first for (int i = 0; i < count; i++) { char ch = (char)bytes[offset + i]; if (ch == ' ') { cSpaces++; } else if (!HttpEncoderUtility.IsUrlSafeChar(ch)) { cUnsafe++; } } // nothing to expand? if (cSpaces == 0 && cUnsafe == 0) { // DevDiv 912606: respect "offset" and "count" if (0 == offset && bytes.Length == count) { return bytes; } else { byte[] subarray = new byte[count]; Buffer.BlockCopy(bytes, offset, subarray, 0, count); return subarray; } } // expand not 'safe' characters into %XX, spaces to +s byte[] expandedBytes = new byte[count + cUnsafe * 2]; int pos = 0; for (int i = 0; i < count; i++) { byte b = bytes[offset + i]; char ch = (char)b; if (HttpEncoderUtility.IsUrlSafeChar(ch)) { expandedBytes[pos++] = b; } else if (ch == ' ') { expandedBytes[pos++] = (byte)'+'; } else { expandedBytes[pos++] = (byte)'%'; expandedBytes[pos++] = (byte)HexConverter.ToCharLower(b >> 4); expandedBytes[pos++] = (byte)HexConverter.ToCharLower(b); } } return expandedBytes; } // Helper to encode the non-ASCII url characters only private static string UrlEncodeNonAscii(string str, Encoding e) { Debug.Assert(!string.IsNullOrEmpty(str)); Debug.Assert(e != null); byte[] bytes = e.GetBytes(str); byte[] encodedBytes = UrlEncodeNonAscii(bytes, 0, bytes.Length); return Encoding.ASCII.GetString(encodedBytes); } private static byte[] UrlEncodeNonAscii(byte[] bytes, int offset, int count) { int cNonAscii = 0; // count them first for (int i = 0; i < count; i++) { if (IsNonAsciiByte(bytes[offset + i])) { cNonAscii++; } } // nothing to expand? if (cNonAscii == 0) { return bytes; } // expand not 'safe' characters into %XX, spaces to +s byte[] expandedBytes = new byte[count + cNonAscii * 2]; int pos = 0; for (int i = 0; i < count; i++) { byte b = bytes[offset + i]; if (IsNonAsciiByte(b)) { expandedBytes[pos++] = (byte)'%'; expandedBytes[pos++] = (byte)HexConverter.ToCharLower(b >> 4); expandedBytes[pos++] = (byte)HexConverter.ToCharLower(b); } else { expandedBytes[pos++] = b; } } return expandedBytes; } [Obsolete("This method produces non-standards-compliant output and has interoperability issues. The preferred alternative is UrlEncode(*).")] [return: NotNullIfNotNull("value")] internal static string? UrlEncodeUnicode(string? value) { if (value == null) { return null; } int l = value.Length; StringBuilder sb = new StringBuilder(l); for (int i = 0; i < l; i++) { char ch = value[i]; if ((ch & 0xff80) == 0) { // 7 bit? if (HttpEncoderUtility.IsUrlSafeChar(ch)) { sb.Append(ch); } else if (ch == ' ') { sb.Append('+'); } else { sb.Append('%'); sb.Append(HexConverter.ToCharLower(ch >> 4)); sb.Append(HexConverter.ToCharLower(ch)); } } else { // arbitrary Unicode? sb.Append("%u"); sb.Append(HexConverter.ToCharLower(ch >> 12)); sb.Append(HexConverter.ToCharLower(ch >> 8)); sb.Append(HexConverter.ToCharLower(ch >> 4)); sb.Append(HexConverter.ToCharLower(ch)); } } return sb.ToString(); } [return: NotNullIfNotNull("value")] internal static string? UrlPathEncode(string? value) { if (string.IsNullOrEmpty(value)) { return value; } string? schemeAndAuthority; string? path; string? queryAndFragment; if (!UriUtil.TrySplitUriForPathEncode(value, out schemeAndAuthority, out path, out queryAndFragment)) { // If the value is not a valid url, we treat it as a relative url. // We don't need to extract query string from the url since UrlPathEncode() // does not encode query string. schemeAndAuthority = null; path = value; queryAndFragment = null; } return schemeAndAuthority + UrlPathEncodeImpl(path) + queryAndFragment; } // This is the original UrlPathEncode(string) private static string UrlPathEncodeImpl(string value) { if (string.IsNullOrEmpty(value)) { return value; } // recurse in case there is a query string int i = value.IndexOf('?'); if (i >= 0) { return string.Concat(UrlPathEncodeImpl(value.Substring(0, i)), value.AsSpan(i)); } // encode DBCS characters and spaces only return HttpEncoderUtility.UrlEncodeSpaces(UrlEncodeNonAscii(value, Encoding.UTF8)); } private static bool ValidateUrlEncodingParameters([NotNullWhen(true)] byte[]? bytes, int offset, int count) { if (bytes == null && count == 0) { return false; } ArgumentNullException.ThrowIfNull(bytes); if (offset < 0 || offset > bytes.Length) { throw new ArgumentOutOfRangeException(nameof(offset)); } if (count < 0 || offset + count > bytes.Length) { throw new ArgumentOutOfRangeException(nameof(count)); } return true; } // Internal class to facilitate URL decoding -- keeps char buffer and byte buffer, allows appending of either chars or bytes private sealed class UrlDecoder { private readonly int _bufferSize; // Accumulate characters in a special array private int _numChars; private readonly char[] _charBuffer; // Accumulate bytes for decoding into characters in a special array private int _numBytes; private byte[]? _byteBuffer; // Encoding to convert chars to bytes private readonly Encoding _encoding; private void FlushBytes() { if (_numBytes > 0) { Debug.Assert(_byteBuffer != null); _numChars += _encoding.GetChars(_byteBuffer, 0, _numBytes, _charBuffer, _numChars); _numBytes = 0; } } internal UrlDecoder(int bufferSize, Encoding encoding) { _bufferSize = bufferSize; _encoding = encoding; _charBuffer = new char[bufferSize]; // byte buffer created on demand } internal void AddChar(char ch) { if (_numBytes > 0) { FlushBytes(); } _charBuffer[_numChars++] = ch; } internal void AddByte(byte b) { // if there are no pending bytes treat 7 bit bytes as characters // this optimization is temp disable as it doesn't work for some encodings /* if (_numBytes == 0 && ((b & 0x80) == 0)) { AddChar((char)b); } else */ { if (_byteBuffer == null) { _byteBuffer = new byte[_bufferSize]; } _byteBuffer[_numBytes++] = b; } } internal string GetString() { if (_numBytes > 0) { FlushBytes(); } return _numChars > 0 ? new string(_charBuffer, 0, _numChars) : ""; } } } }
-1
dotnet/runtime
65,944
Add regex "unit tests" test project
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
stephentoub
2022-02-28T02:31:37Z
2022-02-28T22:55:36Z
3d6781bdf367b0de082613b7ce9cb9b648ec6309
b4c746b7712e887af066d66d1ec777be6283f6f9
Add regex "unit tests" test project. This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
./docs/design/coreclr/jit/lsra-heuristic-tuning.md
- [Background](#background) - [Register selection heuristics](#register-selection-heuristics) - [Impact measurement](#impact-measurement) - [Genetic Algorithm](#genetic-algorithm) - [Experiments](#experiments) * [Setup](#setup) * [Outcome](#outcome) - [Conclusion](#conclusion) ## Background RyuJIT's implements [linear scan register allocation](https://en.wikipedia.org/wiki/Register_allocation#Linear_scan) (LSRA) algorithm to perform the register assignment of generated code. During register selection, LSRA has various heuristics (17 to be precise) to pick the best register candidate at a given point. Each register candidate falls in one of the two categories. Either they do not contain any variable value and so are "free" to get assigned to hold a variable value. Otherwise, they already hold some variable value and hence, are "busy". If one of the busy registers is selected during assignment, the value it currently holds needs to be first stored into memory (also called "spilling the variable") before they are assigned to something else. RyuJIT's LSRA has the heuristics (14 of them) to pick one of the free registers first, and if none found, has heuristics (4 of them) to select one of the busy registers. Busy register is selected depending on which register is cheaper to spill. We noticed that it is not always beneficial to give preference to free register candidates during register selection. Sometimes, it is better to pick a busy register and retain the free register for the future reference points that are part of hot code path. See [the generated code](https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AXEBDAzgWwB8ABABgAJiBGAOgCUBXAOwwEt8YaBhCfAB1YAbGFADKIgG6swMXAG4AsAChlxAMyUATOS7kA3svJHyygNoBZGBgAWEACYBJfoIAUlm/ad9BAeT5sIJlwaADkIByZBViZogHMASgBdVSokcmiMcgBxKzpsJjteF3j9ZQBIYgB2clJFJQBfZTN3W0dnNytWr19/VkDgsIiomKYE5KVqNOIUcgAFKAyXDPIEEoMlMoB6TcoqAE4XVbrGlQnUyhnRbGcYAEFi0o2JbChybHIAXmzc/ML8YrqZWer2An2+GDyBSK8UBwPIYDBOQhv2hsJe5DsiJ+UP+MPKcJgWOROIB+PRADMiZC/qSnujYlSUbi0a9rIySXiNuToOQXHCEGDaityAAechUUhCgDUUtWjzKQPRCHeXyR1NR5UVrwQoNV2JpnIV/IReuJBsBWpWmNN6uZmv5hJtTNpRqVlKdHIt80WysNZW9LEOwD9AYwhzAIYWgYQdkjPpgcej5MNJ39UbD2ENoZcwcB2YjefTLljhcWCdLgeTFbDCWrLmsnJO9SAA===) taken from [dotnet/runtime Issue#8846](https://github.com/dotnet/runtime/issues/8846). In this example, free registers are allocated to the variables that are out of the for-loop. During the register assignment for variables inside the loop, no free registers are available, and the algorithm spills a busy register to store their value. Astonishingly, it picks the same register for all the variables inside the loop and spill the previous variable values repeatedly. Our understanding is that it happens because of the ordering of heuristics in which we perform register selection. Perhaps, instead of having a fixed heuristics order, we should tweak the order to *sometimes* select busy registers first, before selecting from the pool of free registers. That was the inception of the idea of tuning the register selection heuristics described in [dotnet/runtime Issue# 43318](https://github.com/dotnet/runtime/issues/43318) and we wanted to conduct experiments to understand if we can do better register selection using different criteria. In this document, we will go over in detail to understand what made us pick genetic algorithm to do this experiment and what were the outcome of it. ## Register selection heuristics Below are the heuristics implemented in RyuJIT to select a register: | Shorthand | Name | Description | |-----------|----------------------|---------------------------------------------------------------------------------------------------------| | A | `FREE` | Not currently assigned to an *active* interval. | | B | `CONST_AVAILABLE` | A constant value that is already available in a register. | | C | `THIS_ASSIGNED` | Register already assigned to the current interval. | | D | `COVERS` | Covers the interval's current lifetime. | | E | `OWN_PREFERENCE` | Set of preferred registers of current interval. | | F | `COVERS_RELATED` | Set of preferred registers of interval that is related to the current interval and covers the lifetime. | | G | `RELATED_PREFERENCE` | Set of preferred registers of interval that is related to the current interval. | | H | `CALLER_CALLEE` | Caller or callee-saved registers. | | I | `UNASSIGNED` | Not currently assigned to any active or inactive interval. | | J | `COVERS_FULL` | Covers the interval's current lifetime until the end. | | K | `BEST_FIT` | Available range is the closest match to the full range of the interval | | L | `IS_PREV_REG` | Register was previously assigned to the current interval | | M | `REG_ORDER` | Tie-breaker. Just pick the 1st available "free" register. | | N | `SPILL_COST` | Lowest spill cost of all the candidates. | | O | `FAR_NEXT_REF` | It has farther next reference than the best candidate so far. | | P | `PREV_REG_OPT` | The previous reference of the current assigned interval was optional. | | Q | `REG_NUM` | Tie-breaker. Just pick the 1st available "busy" register. | Heuristic `A` thru `M` are for selecting one of the free registers, while `N` thru `Q` are for selecting one of the busy registers. A simple demonstration of how heuristic selection worked earlier is shown below. We start with free candidates and for each heuristic, narrow those candidates. Whenever, we see that there are more than one registers to pick from, we keep trying heuristics (in the above order) until a point when there is just one register left. If we don't find any register, we continue our search using heuristic `N` to find one of the busy registers that can be spilled. ```c# registerCandidates = 0; // bit-mask of all registers LinearScan::allocateReg(RefPostion refPosition, Inteval* interval) { bool found = false; registerCandidates = allFreeCandidates(); if (!found) { found = applyHeuristics(FREE, FREE_Candidates()); } if (!found) { found = applyHeuristics(CONST_AVAILABLE_Candidates()); } ... if (!found) { found = applyHeuristics(REG_ORDER_Candidates()); } // No free register was available, try to select one of // the busy register registerCandidates = allBusyCandidates(); if (!found) { found = applyHeuristics(SPILL_COST_Candidates()); } if (!found) { found = applyHeuristics(FAR_NEXT_REF_Candidates()); } ... } // Filters the register candidates and returns true only there // is one candidate. bool applyHeuristics(selected_candidates) { filtered_candidates = registerCandidates & selected_candidates; if (filtered_candidates != 0) { registerCandidates = filtered_candidates; return isSingleRegister(registerCandidates); } return false; } ``` If we wanted to change the order of heuristics, we would have to update above code to rearrange the portion of heuristics we apply. To experiment with different heuristics ordering, it is not feasible to do such refactoring for every combination. After doing some research on which design pattern to pick for such problems, we went the old school way and moved the individual heuristics code in its own method (marked with `__forceinline`, to eliminate the throughput impact of refactoring changes). We could use function pointer to invoke one of these methods in any order we wanted. The last bit was an ability to add a way for user to specify heuristic order they want to try. We assigned a single letter to each heuristic (`Shorthand` column in above table) and we exposed `COMPlus_JitLsraOrdering` environment variable to specify the ordering. The default ordering is `"ABCDEFGHIJKLMNOPQ"` (the current order), but if given something else like `"PEHDCGAIJNLKOBFMQ"`, it would apply heuristic in that order. In this example, heuristic corresponding to `P` is `PREV_REG_OPT` and thus would apply busy register heuristics first, followed by `OWN_PREFERENCE`, `CALLER_CALLEE` and so forth. As you notice, now we will be able to apply the busy register heuristics before applying the ones for free registers. After stitching all this together, the refactored code looked like this: ```c# typedef void (RegisterSelection::*HeuristicFn)(); HashTable<char, HeuristicFn> ScoreMappingTable = { {'A', try_FREE}, {'B', try_CONST_AVAILABLE}, ... {'Q', try_REG_NUM} }; LinearScan::allocateReg(RefPostion refPosition, Inteval* interval) { char *ordering = Read_COMPlus_LsraOrdering(); HeuristicFn fn; for (char order in ordering) { if (ScoreMappingTable->Lookup(order, &fn)) { bool found = (this->*fn)(); if (found) { break; } } } } bool LinearScan::try_FREE() { ... return applyHeuristics(); } ... bool LinearScan::try_CONST_AVAILABLE() { ... return applyHeuristics(); } ... bool LinearScan::try_REG_NUM() { ... return applyHeuristics(); } ``` [dotnet/runtime #52832](https://github.com/dotnet/runtime/pull/52832) contains all the refactoring changes that are described above. ## Impact measurement Now that rearranging the heuristic ordering is possible with `COMPlus_JitLsraOrdering`, we decided to measure the impact of the reordering by running [superpmi](https://github.com/dotnet/runtime/blob/e063533eb79eace045f43b41980cbed21c8d7365/src/coreclr/ToolBox/superpmi/readme.md) tool. `superpmi` tool JITs all the methods of a given assembly file (`*.dll` or `*.exe`) without executing the generated machine code. Given two versions of `clrjit.dll` (RyuJIT binary), it also has an ability to perform the comparison of generated code and reporting back the number of methods that got improved/regressed in terms of `CodeSize` (machine code size), `PerfScore` (instruction latency/throughput measurements), `InstructionCount` (number of instructions present), etc. We picked `PerfScore` metrics because that accurately includes the cost of register spilling. If LSRA doesn't come up with optimal register choice, we would see several `mov` instructions that load/store into memory and that would decrease the throughput, increase the latency, and hence lower the `PerfScore`. If the spilling happens inside a loop, `PerfScore` metrics accounts for that by considering the product of loop block weights and `PerfScore`. Thus, our goal would be to reduce the `PerfScore` as much possible, lower the `PerfScore`, better is the code we generated. The baseline for the comparison was the default ordering, and we wanted to compare it with an ordering specified in `COMPlus_JitLsraOrdering`. We could specify any combination of sequence `A` thru `Q` and tweak the LSRA algorithm to apply a different heuristics order. But since there are 17 heuristics, there would be **355,687,428,096,000** (17!) possibilities to try out and it will not be practical to do so. We ought to find a better way! ## Genetic Algorithm [Genetic algorithm](https://en.wikipedia.org/wiki/Genetic_algorithm) is the perfect solution to solve these kind of problems. For those who are not familiar, here is a quick summary - The algorithm starts with a community that has few candidates whose fitness score is predetermined. Each candidate is made up of sequence of genes and all candidates have same number of genes in them. The algorithm picks a pair of fit candidates (parents) and mutate their genes to produce offsprings. The algorithm calculates the fitness of the new offsprings and add them (along with the fitness score) back to the community pool. As the community evolves, more and more candidates who has fitness score equivalent or better than the initial population are added to the community. Of course, the community cannot grow infinitely, so the least fit candidates die. When there are no more candidates that are fit than the fittest candidate, the algorithm stops, giving us a set of fit candidates. This can be perfectly mapped to the heuristic selection ordering problem. We want to start with `"ABCDEFGHIJKLMNOPQ"` (default selection order) and each letter in this combination can be represented as a gene. Genetic algorithm would mutate the gene to produce a different order say `"ABMCDEFGHIKLNJOPQ"` and we will set that value in `COMPlus_JitLsraOrdering` variable. We would then run `superpmi.py` to produce the generated code and compare the `PerfScore` with that of the one produced by the default order. `PerfScore` represents the fitness, lower the value of that metric, more fit is the corresponding candidate, in our case, better is the heuristic ordering. Below is the pseudo code of genetic algorithm that we experimented with to find optimal heuristic ordering. ```c# // Maximum population per generation int MaxPopulation = 100; HashMap<string, float> Community = new HashMap<string, float>(); HashMap<string, float> NextGen = new HashMap<string, float>(); void GeneticAlgorithm() { PopulateCommunity(); do { // new generation NextGen = new HashMap<string, float>(); candidateCount = 0; while(candidateCount++ < MaxPopulation) { // Use tournament selection method to pick // 2 candidates from "Community". // https://en.wikipedia.org/wiki/Tournament_selection (parent1, parent2) = DoSelection(); // Mutate genes of parent1 and parent2 to produce // 2 offsprings (offspring0, offspring1) = MutateGenes(parent1, parent2) // Add offsprings to the community AddNewOffspring(offspring0) AddNewOffspring(offspring1) } Community = NextGen; // Loop until there are unique candidates are being produced in the // community } while (uniqueCandidates); } // Populate the community with random candidates void PopulateCommunity() { candidateCount = 0; while(candidateCount < MaxPopulation) { newCandidate = GetRandomCombination("ABCDEFGHIJKLMNOPQ") AddNewOffspring(newCandidate) } } // Trigger superpmi tool and read back the PerfScore void ComputeFitness(candidate) { perfScore = exec("superpmi.py asmdiffs -base_jit_path default\clrjit.dll -diff_jit_path other\clrjit.dll -diff_jit_option JitLsraOrdering=" + candidate) return perfScore } // Compuate fitness for both offsprings // and add them to the community void AddNewOffspring(candidate) { Community[candidate] = ComputeFitness(candidate) // Evict less fit candidate if (Community.Count > MaxPopulation) { weakCandidate = CandidateWithHighestPerfScore(Community); Community.Remove(weakCandidate) } } // Perform crossover and mutation techniques void MutateGenes(offspring0, offspring1) { assert(offspring0.Length == offspring1.Length) // crossover crossOverPoint = random(0, offspring0.Length) i = 0 while (i++ < crossOverPoint) { char c = offspring0[i] offspring0[i] = offspring1[i] offspring1[i] = c } // mutation randomIndex = random(0, offspring0.Length) char c = offspring0[randomIndex] offspring0[randomIndex] = offspring1[randomIndex] offspring1[randomIndex] = c return offspring0, offspring1 } ``` With genetic algorithm in place, we were ready to perform some experiments to find an optimal heuristic order. ## Experiments With `superpmi`, we have an ability to run JIT against all the methods present in .NET libraries and [Microbenchmarks](https://github.com/dotnet/performance/tree/main/src/Benchmarks/micro). We also need to conduct this experiment for all OS/architecture that we support - Windows/x64, Windows/arm64, Linux/x64, Linux/arm and Linux/arm64. ### Setup To conduct experiments, we made few changes to the way superpmi gathers `PerfScore` and reports it back. 1. `superpmi.exe` was modified to aggregate **relative** `PerfScore` difference of code generated by default and modified LSRA ordering. When `superpmi.exe` is run in parallel (which is by default), this number was reported back on the console by each parallel process. 2. `superpmi.py` was modified to further aggregate the relative `PerfScore` differences of parallel `superpmi.exe` processes and report back the final relative `PerfScore` difference. 3. LSRA has many asserts throughout the codebase. They assume that during register selection, all the free registers are tried first before checking for busy registers. Since we wanted to understand the impact of preferring busy registers as well, we had to disable those asserts. 4. `superpmi.exe asmdiffs` takes two versions of `clrjit.dll` that you want to compare. Both must be from different location. In our case, we only wanted to experiment with different heuristic ordering by passing different values for `COMPlus_JitLsraOrdering`, we made a copy of `clrjit.dll` -> `copy_clrjit.dll` and passed various ordering to the copied `copy_clrjit.dll`. Here is the sample invocation of `superpmi.py` that genetic algorithm invoked to get the `PerfScore` (fitness score) of each experimented ordering: ``` python superpmi.py asmdiffs -f benchmarks -base_jit_path clrjit.dll -diff_jit_path copy_clrjit.dll -target_os windows -target_arch x64 -error_limit 10 -diff_jit_option JitLsraOrdering=APCDEGHNIOFJKLBMQ -log_file benchmarks_APCDEGHNIOFJKLBMQ.log ``` All the above changes are in the private branch [lsra-refactoring branch](https://github.com/kunalspathak/runtime/tree/lsra-refactoring). ### Outcome Below are the heuristic ordering that genetic algorithm came up with for different configuration (scenarios/OS/architectures). The `PerfScore` column represent the aggregate of relative difference of `PerfScore` of all the methods. We preferred relative difference rather than absolute difference of `PerfScore` because we didn't want a dominant method's numbers hide the impact of other smaller methods. | Configuration | Ordering | PerfScore | |-------------------------|--------------------|-------------| | windows-x64 Benchmarks | `EHPDGAJCBNKOLFIMQ` | -36.540712 | | windows-x64 Libraries | `PEHDCGAIJNLKOBFMQ` | -271.749901 | | windows-x86 Benchmarks | `EHDCFPGJBIALNOKMQ` | -73.004577 | | windows-x86 Libraries | `APCDEGHNIOFJKLBMQ` | -168.335079 | | Linux-x64 Benchmarks | `HGIDJNLCPOBKAEFMQ` | -96.966704 | | Linux-x64 Libraries | `HDGAECNIPLBOFKJMQ` | -391.835935 | | Linux-arm64 Libraries | `HECDBFGIANLOKJMPQ` | -249.900161 | As seen from the table, there are lot of better ordering than the default `"ABCDEFGHIJKLMNOPQ"`, which if used, can give us better register selection and hence, better performance. But we can also see that not all ordering that genetic algorithm came up with are same for all configurations. We wanted to find a common and similar ordering that can benefit all the scenarios across multiple platforms. As a last step of experiment, we tried to apply each of the best ordering that we had to other configurations and see how they perform. For example, `"EHPDGAJCBNKOLFIMQ"` is the most optimal ordering for windows/x64/Benchmarks configuration and we wanted to evaluate if that ordering could also be beneficial to Linux/arm64/Libraries. Likewise, for `"PEHDCGAIJNLKOBFMQ"` (optimal ordering for windows/x64/Libraries) and so forth. Below table shows the compiled data of `PerfScore` that we get when we applied best ordering of individual configuration to other configurations. Each row contains a configuration along with the optimal ordering that genetic algorithm came up with. The columns represent the `PerfScore` we get if we apply the optimal ordering to the configuration listed in the column title. | Configuration | Optimal Ordering | Linux-x64 Benchmarks | windows-x64 Benchmarks | windows-arm64 Benchmarks | Linux-x64 Libraries | Linux-arm64 Libraries | windows-x64 Libraries | windows-arm64 Libraries.pmi | windows-x86 Benchmarks | Linux-arm Libraries | windows-x86 Libraries | |------------------------|-------------------|-----------------------|------------------------|--------------------------|-----------------------|-----------------------|-----------------------|-----------------------------|------------------------|-----------------------|-----------------------| | windows-x64 Benchmarks | `EHPDGAJCBNKOLFIMQ` | -83.496405 | **-36.540712** | -19.09969 | -340.009195 | -103.340802 | -265.397122 | -113.718544 | -62.126579 | 11292.33497 | 18.510854 | | windows-x64 Libraries | `PEHDCGAIJNLKOBFMQ` | -85.572973 | -35.853492 | -19.07247 | -355.615641 | -103.028599 | **-271.749901** | -114.1154 | -70.087852 | 31974.87698 | -46.803569 | | windows-x86 Benchmarks | `EHDCFPGJBIALNOKMQ` | **-101.903471** | -19.844343 | -41.041839 | **-419.933377** | -247.95955 | -179.127655 | -265.675453 | **-73.004577** | 10679.36843 | -136.780091 | | windows-x86 Libraries | `APCDEGHNIOFJKLBMQ` | -26.907257 | -0.284718 | -30.144657 | -164.340576 | -220.351459 | -73.413256 | -232.256476 | -10.25733 | 31979.07983 | **-168.335079** | | linux-x64 Benchmarks | `HGIDJNLCPOBKAEFMQ` | -96.966704 | -9.29483 | -50.215283 | -361.159848 | -221.622609 | -64.308995 | -244.127555 | 13.188704 | 8392.714652 | 397.994465 | | linux-x64 Libraries | `HDGAECNIPLBOFKJMQ` | -97.682606 | -13.882952 | -51.929281 | -391.835935 | -240.63813 | -101.495244 | -262.746033 | -22.621316 | 8456.327283 | 165.982045 | | linux-arm64 Libraries | `HECDBFGIANLOKJMPQ` | -97.259922 | -11.159774 | **-54.424627** | -330.340402 | **-249.900161** | -52.359275 | **-270.482763** | -35.304525 | **2404.874376** | 125.707741 | | | Max PerfScore | **`EHDCFPGJBIALNOKMQ`** | **`EHPDGAJCBNKOLFIMQ`** | **`HECDBFGIANLOKJMPQ`** | **`HDGAECNIPLBOFKJMQ`** | **`HECDBFGIANLOKJMPQ`** | **`PEHDCGAIJNLKOBFMQ`** | **`HECDBFGIANLOKJMPQ`** | **`EHDCFPGJBIALNOKMQ`** | **`HECDBFGIANLOKJMPQ`** | **`APCDEGHNIOFJKLBMQ`** | The last row in the above table tells the best ordering for the configuration (of that column) out of optimal orderings of all configurations. Below table summarizes 1st and 2nd best ordering for individual configuration. | Configuration | 1st best | 2nd best | |--------------------------|----------------------|----------------------| | windows-x64 Benchmarks | `EHPDGAJCBNKOLFIMQ` | `PEHDCGAIJNLKOBFMQ` | | windows-x64 Libraries | `PEHDCGAIJNLKOBFMQ` | `EHPDGAJCBNKOLFIMQ` | | windows-x86 Benchmarks | `EHDCFPGJBIALNOKMQ` | `PEHDCGAIJNLKOBFMQ` | | windows-x86 Libraries | `APCDEGHNIOFJKLBMQ` | `EHDCFPGJBIALNOKMQ` | | windows-arm64 Benchmarks | `HECDBFGIANLOKJMPQ` | `HDGAECNIPLBOFKJMQ` | | windows-arm64 Libraries | `HECDBFGIANLOKJMPQ` | `EHDCFPGJBIALNOKMQ` | If we see the pattern under the "1st best" column, we see that the sequence `E` and `H` are towards the beginning, meaning that overall, it is profitable to have `OWN_PREFERENCE` (one of the preferred registers for a given interval) or `CALLEE_CALLER` (caller and callee registers) as one of the first heuristic criteria. Next, most of the ordering has `C` and `D` that are also popular that maps to `THIS_ASSIGNED` (already assigned to the current interval) and `COVERS` (covers the lifetime of an interval). One of the busy register heuristics `P` that maps to `PREV_REG_OPT` (Previous reference of the currently assigned interval was optional) is also present at the beginning. While these ordering gives good `PerfScore`, there were several regressions observed for other methods. Most of the regressions falls under one or more of the following categories: 1. There are some key challenges in LSRA's resolution phase highlighted in [dotnet/runtime #47194](https://github.com/dotnet/runtime/issues/47194). Once resolution moves are identified for all the blocks, there is a need to revisit those moves to see if there are some that can be optimized out. Several methods regressed their `PerfScore` because we added lot of resolution moves at block boundaries. 2. Even though there is a flexibility of trying different register selection ordering, LSRA has limited knowledge about the method and portion of code for which it is allocating register. For example, during allocation, it doesn't know if it is allocating for code inside loop and that it should keep spare registers to use in that code. There has to be a phase before LSRA that consolidates this information in a data structure that can be used by LSRA during register selection. 3. While doing the experiments, we realized other low hanging fruits in LSRA that amplifies the regression caused by reordering the register selection heuristics. For example, if a variable is defined just once, it can be spilled at the place where it is defined and then, it doesn't need to be spilled throughout the method. This was achieved in [dotnet/runtime #54345](https://github.com/dotnet/runtime/pull/54345). ## Conclusion Register allocation is a complex topic, slight change in algorithm could have huge impact on the generated code. We explored various ideas for finding optimal heuristic selection ordering. Using Genetic algorithm, we could find optimal ordering and there was also some commonality in the heuristics order that was performance efficient for majority of configuration that we tested. However, with many improvements, there were also regressions in many methods across all configurations. We discovered that there was other area of improvements that need to be fixed first before we enable heuristic tuning feature, [[RyuJIT][LSRA]](https://github.com/dotnet/runtime/issues?q=is%3Aissue+is%3Aopen+%22%5BRyuJIT%5D%5BLSRA%5D%22+) captures some of the issues. Hence, we decided not to change any heuristic ordering at the current time. We will focus on fixing these issues first and once the existing LSRA weakness are addressed, we can choose to return to this experiment and use the techniques, tools, and knowledge here to inform a heuristic re-ordering. Going forward, we could also auto tune the heuristic ordering based on various factors like how many method parameters are present, if loops are present or not, exception handling, etc. Opportunities are endless, time is limited, so got to make better choices!
- [Background](#background) - [Register selection heuristics](#register-selection-heuristics) - [Impact measurement](#impact-measurement) - [Genetic Algorithm](#genetic-algorithm) - [Experiments](#experiments) * [Setup](#setup) * [Outcome](#outcome) - [Conclusion](#conclusion) ## Background RyuJIT's implements [linear scan register allocation](https://en.wikipedia.org/wiki/Register_allocation#Linear_scan) (LSRA) algorithm to perform the register assignment of generated code. During register selection, LSRA has various heuristics (17 to be precise) to pick the best register candidate at a given point. Each register candidate falls in one of the two categories. Either they do not contain any variable value and so are "free" to get assigned to hold a variable value. Otherwise, they already hold some variable value and hence, are "busy". If one of the busy registers is selected during assignment, the value it currently holds needs to be first stored into memory (also called "spilling the variable") before they are assigned to something else. RyuJIT's LSRA has the heuristics (14 of them) to pick one of the free registers first, and if none found, has heuristics (4 of them) to select one of the busy registers. Busy register is selected depending on which register is cheaper to spill. We noticed that it is not always beneficial to give preference to free register candidates during register selection. Sometimes, it is better to pick a busy register and retain the free register for the future reference points that are part of hot code path. See [the generated code](https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AXEBDAzgWwB8ABABgAJiBGAOgCUBXAOwwEt8YaBhCfAB1YAbGFADKIgG6swMXAG4AsAChlxAMyUATOS7kA3svJHyygNoBZGBgAWEACYBJfoIAUlm/ad9BAeT5sIJlwaADkIByZBViZogHMASgBdVSokcmiMcgBxKzpsJjteF3j9ZQBIYgB2clJFJQBfZTN3W0dnNytWr19/VkDgsIiomKYE5KVqNOIUcgAFKAyXDPIEEoMlMoB6TcoqAE4XVbrGlQnUyhnRbGcYAEFi0o2JbChybHIAXmzc/ML8YrqZWer2An2+GDyBSK8UBwPIYDBOQhv2hsJe5DsiJ+UP+MPKcJgWOROIB+PRADMiZC/qSnujYlSUbi0a9rIySXiNuToOQXHCEGDaityAAechUUhCgDUUtWjzKQPRCHeXyR1NR5UVrwQoNV2JpnIV/IReuJBsBWpWmNN6uZmv5hJtTNpRqVlKdHIt80WysNZW9LEOwD9AYwhzAIYWgYQdkjPpgcej5MNJ39UbD2ENoZcwcB2YjefTLljhcWCdLgeTFbDCWrLmsnJO9SAA===) taken from [dotnet/runtime Issue#8846](https://github.com/dotnet/runtime/issues/8846). In this example, free registers are allocated to the variables that are out of the for-loop. During the register assignment for variables inside the loop, no free registers are available, and the algorithm spills a busy register to store their value. Astonishingly, it picks the same register for all the variables inside the loop and spill the previous variable values repeatedly. Our understanding is that it happens because of the ordering of heuristics in which we perform register selection. Perhaps, instead of having a fixed heuristics order, we should tweak the order to *sometimes* select busy registers first, before selecting from the pool of free registers. That was the inception of the idea of tuning the register selection heuristics described in [dotnet/runtime Issue# 43318](https://github.com/dotnet/runtime/issues/43318) and we wanted to conduct experiments to understand if we can do better register selection using different criteria. In this document, we will go over in detail to understand what made us pick genetic algorithm to do this experiment and what were the outcome of it. ## Register selection heuristics Below are the heuristics implemented in RyuJIT to select a register: | Shorthand | Name | Description | |-----------|----------------------|---------------------------------------------------------------------------------------------------------| | A | `FREE` | Not currently assigned to an *active* interval. | | B | `CONST_AVAILABLE` | A constant value that is already available in a register. | | C | `THIS_ASSIGNED` | Register already assigned to the current interval. | | D | `COVERS` | Covers the interval's current lifetime. | | E | `OWN_PREFERENCE` | Set of preferred registers of current interval. | | F | `COVERS_RELATED` | Set of preferred registers of interval that is related to the current interval and covers the lifetime. | | G | `RELATED_PREFERENCE` | Set of preferred registers of interval that is related to the current interval. | | H | `CALLER_CALLEE` | Caller or callee-saved registers. | | I | `UNASSIGNED` | Not currently assigned to any active or inactive interval. | | J | `COVERS_FULL` | Covers the interval's current lifetime until the end. | | K | `BEST_FIT` | Available range is the closest match to the full range of the interval | | L | `IS_PREV_REG` | Register was previously assigned to the current interval | | M | `REG_ORDER` | Tie-breaker. Just pick the 1st available "free" register. | | N | `SPILL_COST` | Lowest spill cost of all the candidates. | | O | `FAR_NEXT_REF` | It has farther next reference than the best candidate so far. | | P | `PREV_REG_OPT` | The previous reference of the current assigned interval was optional. | | Q | `REG_NUM` | Tie-breaker. Just pick the 1st available "busy" register. | Heuristic `A` thru `M` are for selecting one of the free registers, while `N` thru `Q` are for selecting one of the busy registers. A simple demonstration of how heuristic selection worked earlier is shown below. We start with free candidates and for each heuristic, narrow those candidates. Whenever, we see that there are more than one registers to pick from, we keep trying heuristics (in the above order) until a point when there is just one register left. If we don't find any register, we continue our search using heuristic `N` to find one of the busy registers that can be spilled. ```c# registerCandidates = 0; // bit-mask of all registers LinearScan::allocateReg(RefPostion refPosition, Inteval* interval) { bool found = false; registerCandidates = allFreeCandidates(); if (!found) { found = applyHeuristics(FREE, FREE_Candidates()); } if (!found) { found = applyHeuristics(CONST_AVAILABLE_Candidates()); } ... if (!found) { found = applyHeuristics(REG_ORDER_Candidates()); } // No free register was available, try to select one of // the busy register registerCandidates = allBusyCandidates(); if (!found) { found = applyHeuristics(SPILL_COST_Candidates()); } if (!found) { found = applyHeuristics(FAR_NEXT_REF_Candidates()); } ... } // Filters the register candidates and returns true only there // is one candidate. bool applyHeuristics(selected_candidates) { filtered_candidates = registerCandidates & selected_candidates; if (filtered_candidates != 0) { registerCandidates = filtered_candidates; return isSingleRegister(registerCandidates); } return false; } ``` If we wanted to change the order of heuristics, we would have to update above code to rearrange the portion of heuristics we apply. To experiment with different heuristics ordering, it is not feasible to do such refactoring for every combination. After doing some research on which design pattern to pick for such problems, we went the old school way and moved the individual heuristics code in its own method (marked with `__forceinline`, to eliminate the throughput impact of refactoring changes). We could use function pointer to invoke one of these methods in any order we wanted. The last bit was an ability to add a way for user to specify heuristic order they want to try. We assigned a single letter to each heuristic (`Shorthand` column in above table) and we exposed `COMPlus_JitLsraOrdering` environment variable to specify the ordering. The default ordering is `"ABCDEFGHIJKLMNOPQ"` (the current order), but if given something else like `"PEHDCGAIJNLKOBFMQ"`, it would apply heuristic in that order. In this example, heuristic corresponding to `P` is `PREV_REG_OPT` and thus would apply busy register heuristics first, followed by `OWN_PREFERENCE`, `CALLER_CALLEE` and so forth. As you notice, now we will be able to apply the busy register heuristics before applying the ones for free registers. After stitching all this together, the refactored code looked like this: ```c# typedef void (RegisterSelection::*HeuristicFn)(); HashTable<char, HeuristicFn> ScoreMappingTable = { {'A', try_FREE}, {'B', try_CONST_AVAILABLE}, ... {'Q', try_REG_NUM} }; LinearScan::allocateReg(RefPostion refPosition, Inteval* interval) { char *ordering = Read_COMPlus_LsraOrdering(); HeuristicFn fn; for (char order in ordering) { if (ScoreMappingTable->Lookup(order, &fn)) { bool found = (this->*fn)(); if (found) { break; } } } } bool LinearScan::try_FREE() { ... return applyHeuristics(); } ... bool LinearScan::try_CONST_AVAILABLE() { ... return applyHeuristics(); } ... bool LinearScan::try_REG_NUM() { ... return applyHeuristics(); } ``` [dotnet/runtime #52832](https://github.com/dotnet/runtime/pull/52832) contains all the refactoring changes that are described above. ## Impact measurement Now that rearranging the heuristic ordering is possible with `COMPlus_JitLsraOrdering`, we decided to measure the impact of the reordering by running [superpmi](https://github.com/dotnet/runtime/blob/e063533eb79eace045f43b41980cbed21c8d7365/src/coreclr/ToolBox/superpmi/readme.md) tool. `superpmi` tool JITs all the methods of a given assembly file (`*.dll` or `*.exe`) without executing the generated machine code. Given two versions of `clrjit.dll` (RyuJIT binary), it also has an ability to perform the comparison of generated code and reporting back the number of methods that got improved/regressed in terms of `CodeSize` (machine code size), `PerfScore` (instruction latency/throughput measurements), `InstructionCount` (number of instructions present), etc. We picked `PerfScore` metrics because that accurately includes the cost of register spilling. If LSRA doesn't come up with optimal register choice, we would see several `mov` instructions that load/store into memory and that would decrease the throughput, increase the latency, and hence lower the `PerfScore`. If the spilling happens inside a loop, `PerfScore` metrics accounts for that by considering the product of loop block weights and `PerfScore`. Thus, our goal would be to reduce the `PerfScore` as much possible, lower the `PerfScore`, better is the code we generated. The baseline for the comparison was the default ordering, and we wanted to compare it with an ordering specified in `COMPlus_JitLsraOrdering`. We could specify any combination of sequence `A` thru `Q` and tweak the LSRA algorithm to apply a different heuristics order. But since there are 17 heuristics, there would be **355,687,428,096,000** (17!) possibilities to try out and it will not be practical to do so. We ought to find a better way! ## Genetic Algorithm [Genetic algorithm](https://en.wikipedia.org/wiki/Genetic_algorithm) is the perfect solution to solve these kind of problems. For those who are not familiar, here is a quick summary - The algorithm starts with a community that has few candidates whose fitness score is predetermined. Each candidate is made up of sequence of genes and all candidates have same number of genes in them. The algorithm picks a pair of fit candidates (parents) and mutate their genes to produce offsprings. The algorithm calculates the fitness of the new offsprings and add them (along with the fitness score) back to the community pool. As the community evolves, more and more candidates who has fitness score equivalent or better than the initial population are added to the community. Of course, the community cannot grow infinitely, so the least fit candidates die. When there are no more candidates that are fit than the fittest candidate, the algorithm stops, giving us a set of fit candidates. This can be perfectly mapped to the heuristic selection ordering problem. We want to start with `"ABCDEFGHIJKLMNOPQ"` (default selection order) and each letter in this combination can be represented as a gene. Genetic algorithm would mutate the gene to produce a different order say `"ABMCDEFGHIKLNJOPQ"` and we will set that value in `COMPlus_JitLsraOrdering` variable. We would then run `superpmi.py` to produce the generated code and compare the `PerfScore` with that of the one produced by the default order. `PerfScore` represents the fitness, lower the value of that metric, more fit is the corresponding candidate, in our case, better is the heuristic ordering. Below is the pseudo code of genetic algorithm that we experimented with to find optimal heuristic ordering. ```c# // Maximum population per generation int MaxPopulation = 100; HashMap<string, float> Community = new HashMap<string, float>(); HashMap<string, float> NextGen = new HashMap<string, float>(); void GeneticAlgorithm() { PopulateCommunity(); do { // new generation NextGen = new HashMap<string, float>(); candidateCount = 0; while(candidateCount++ < MaxPopulation) { // Use tournament selection method to pick // 2 candidates from "Community". // https://en.wikipedia.org/wiki/Tournament_selection (parent1, parent2) = DoSelection(); // Mutate genes of parent1 and parent2 to produce // 2 offsprings (offspring0, offspring1) = MutateGenes(parent1, parent2) // Add offsprings to the community AddNewOffspring(offspring0) AddNewOffspring(offspring1) } Community = NextGen; // Loop until there are unique candidates are being produced in the // community } while (uniqueCandidates); } // Populate the community with random candidates void PopulateCommunity() { candidateCount = 0; while(candidateCount < MaxPopulation) { newCandidate = GetRandomCombination("ABCDEFGHIJKLMNOPQ") AddNewOffspring(newCandidate) } } // Trigger superpmi tool and read back the PerfScore void ComputeFitness(candidate) { perfScore = exec("superpmi.py asmdiffs -base_jit_path default\clrjit.dll -diff_jit_path other\clrjit.dll -diff_jit_option JitLsraOrdering=" + candidate) return perfScore } // Compuate fitness for both offsprings // and add them to the community void AddNewOffspring(candidate) { Community[candidate] = ComputeFitness(candidate) // Evict less fit candidate if (Community.Count > MaxPopulation) { weakCandidate = CandidateWithHighestPerfScore(Community); Community.Remove(weakCandidate) } } // Perform crossover and mutation techniques void MutateGenes(offspring0, offspring1) { assert(offspring0.Length == offspring1.Length) // crossover crossOverPoint = random(0, offspring0.Length) i = 0 while (i++ < crossOverPoint) { char c = offspring0[i] offspring0[i] = offspring1[i] offspring1[i] = c } // mutation randomIndex = random(0, offspring0.Length) char c = offspring0[randomIndex] offspring0[randomIndex] = offspring1[randomIndex] offspring1[randomIndex] = c return offspring0, offspring1 } ``` With genetic algorithm in place, we were ready to perform some experiments to find an optimal heuristic order. ## Experiments With `superpmi`, we have an ability to run JIT against all the methods present in .NET libraries and [Microbenchmarks](https://github.com/dotnet/performance/tree/main/src/Benchmarks/micro). We also need to conduct this experiment for all OS/architecture that we support - Windows/x64, Windows/arm64, Linux/x64, Linux/arm and Linux/arm64. ### Setup To conduct experiments, we made few changes to the way superpmi gathers `PerfScore` and reports it back. 1. `superpmi.exe` was modified to aggregate **relative** `PerfScore` difference of code generated by default and modified LSRA ordering. When `superpmi.exe` is run in parallel (which is by default), this number was reported back on the console by each parallel process. 2. `superpmi.py` was modified to further aggregate the relative `PerfScore` differences of parallel `superpmi.exe` processes and report back the final relative `PerfScore` difference. 3. LSRA has many asserts throughout the codebase. They assume that during register selection, all the free registers are tried first before checking for busy registers. Since we wanted to understand the impact of preferring busy registers as well, we had to disable those asserts. 4. `superpmi.exe asmdiffs` takes two versions of `clrjit.dll` that you want to compare. Both must be from different location. In our case, we only wanted to experiment with different heuristic ordering by passing different values for `COMPlus_JitLsraOrdering`, we made a copy of `clrjit.dll` -> `copy_clrjit.dll` and passed various ordering to the copied `copy_clrjit.dll`. Here is the sample invocation of `superpmi.py` that genetic algorithm invoked to get the `PerfScore` (fitness score) of each experimented ordering: ``` python superpmi.py asmdiffs -f benchmarks -base_jit_path clrjit.dll -diff_jit_path copy_clrjit.dll -target_os windows -target_arch x64 -error_limit 10 -diff_jit_option JitLsraOrdering=APCDEGHNIOFJKLBMQ -log_file benchmarks_APCDEGHNIOFJKLBMQ.log ``` All the above changes are in the private branch [lsra-refactoring branch](https://github.com/kunalspathak/runtime/tree/lsra-refactoring). ### Outcome Below are the heuristic ordering that genetic algorithm came up with for different configuration (scenarios/OS/architectures). The `PerfScore` column represent the aggregate of relative difference of `PerfScore` of all the methods. We preferred relative difference rather than absolute difference of `PerfScore` because we didn't want a dominant method's numbers hide the impact of other smaller methods. | Configuration | Ordering | PerfScore | |-------------------------|--------------------|-------------| | windows-x64 Benchmarks | `EHPDGAJCBNKOLFIMQ` | -36.540712 | | windows-x64 Libraries | `PEHDCGAIJNLKOBFMQ` | -271.749901 | | windows-x86 Benchmarks | `EHDCFPGJBIALNOKMQ` | -73.004577 | | windows-x86 Libraries | `APCDEGHNIOFJKLBMQ` | -168.335079 | | Linux-x64 Benchmarks | `HGIDJNLCPOBKAEFMQ` | -96.966704 | | Linux-x64 Libraries | `HDGAECNIPLBOFKJMQ` | -391.835935 | | Linux-arm64 Libraries | `HECDBFGIANLOKJMPQ` | -249.900161 | As seen from the table, there are lot of better ordering than the default `"ABCDEFGHIJKLMNOPQ"`, which if used, can give us better register selection and hence, better performance. But we can also see that not all ordering that genetic algorithm came up with are same for all configurations. We wanted to find a common and similar ordering that can benefit all the scenarios across multiple platforms. As a last step of experiment, we tried to apply each of the best ordering that we had to other configurations and see how they perform. For example, `"EHPDGAJCBNKOLFIMQ"` is the most optimal ordering for windows/x64/Benchmarks configuration and we wanted to evaluate if that ordering could also be beneficial to Linux/arm64/Libraries. Likewise, for `"PEHDCGAIJNLKOBFMQ"` (optimal ordering for windows/x64/Libraries) and so forth. Below table shows the compiled data of `PerfScore` that we get when we applied best ordering of individual configuration to other configurations. Each row contains a configuration along with the optimal ordering that genetic algorithm came up with. The columns represent the `PerfScore` we get if we apply the optimal ordering to the configuration listed in the column title. | Configuration | Optimal Ordering | Linux-x64 Benchmarks | windows-x64 Benchmarks | windows-arm64 Benchmarks | Linux-x64 Libraries | Linux-arm64 Libraries | windows-x64 Libraries | windows-arm64 Libraries.pmi | windows-x86 Benchmarks | Linux-arm Libraries | windows-x86 Libraries | |------------------------|-------------------|-----------------------|------------------------|--------------------------|-----------------------|-----------------------|-----------------------|-----------------------------|------------------------|-----------------------|-----------------------| | windows-x64 Benchmarks | `EHPDGAJCBNKOLFIMQ` | -83.496405 | **-36.540712** | -19.09969 | -340.009195 | -103.340802 | -265.397122 | -113.718544 | -62.126579 | 11292.33497 | 18.510854 | | windows-x64 Libraries | `PEHDCGAIJNLKOBFMQ` | -85.572973 | -35.853492 | -19.07247 | -355.615641 | -103.028599 | **-271.749901** | -114.1154 | -70.087852 | 31974.87698 | -46.803569 | | windows-x86 Benchmarks | `EHDCFPGJBIALNOKMQ` | **-101.903471** | -19.844343 | -41.041839 | **-419.933377** | -247.95955 | -179.127655 | -265.675453 | **-73.004577** | 10679.36843 | -136.780091 | | windows-x86 Libraries | `APCDEGHNIOFJKLBMQ` | -26.907257 | -0.284718 | -30.144657 | -164.340576 | -220.351459 | -73.413256 | -232.256476 | -10.25733 | 31979.07983 | **-168.335079** | | linux-x64 Benchmarks | `HGIDJNLCPOBKAEFMQ` | -96.966704 | -9.29483 | -50.215283 | -361.159848 | -221.622609 | -64.308995 | -244.127555 | 13.188704 | 8392.714652 | 397.994465 | | linux-x64 Libraries | `HDGAECNIPLBOFKJMQ` | -97.682606 | -13.882952 | -51.929281 | -391.835935 | -240.63813 | -101.495244 | -262.746033 | -22.621316 | 8456.327283 | 165.982045 | | linux-arm64 Libraries | `HECDBFGIANLOKJMPQ` | -97.259922 | -11.159774 | **-54.424627** | -330.340402 | **-249.900161** | -52.359275 | **-270.482763** | -35.304525 | **2404.874376** | 125.707741 | | | Max PerfScore | **`EHDCFPGJBIALNOKMQ`** | **`EHPDGAJCBNKOLFIMQ`** | **`HECDBFGIANLOKJMPQ`** | **`HDGAECNIPLBOFKJMQ`** | **`HECDBFGIANLOKJMPQ`** | **`PEHDCGAIJNLKOBFMQ`** | **`HECDBFGIANLOKJMPQ`** | **`EHDCFPGJBIALNOKMQ`** | **`HECDBFGIANLOKJMPQ`** | **`APCDEGHNIOFJKLBMQ`** | The last row in the above table tells the best ordering for the configuration (of that column) out of optimal orderings of all configurations. Below table summarizes 1st and 2nd best ordering for individual configuration. | Configuration | 1st best | 2nd best | |--------------------------|----------------------|----------------------| | windows-x64 Benchmarks | `EHPDGAJCBNKOLFIMQ` | `PEHDCGAIJNLKOBFMQ` | | windows-x64 Libraries | `PEHDCGAIJNLKOBFMQ` | `EHPDGAJCBNKOLFIMQ` | | windows-x86 Benchmarks | `EHDCFPGJBIALNOKMQ` | `PEHDCGAIJNLKOBFMQ` | | windows-x86 Libraries | `APCDEGHNIOFJKLBMQ` | `EHDCFPGJBIALNOKMQ` | | windows-arm64 Benchmarks | `HECDBFGIANLOKJMPQ` | `HDGAECNIPLBOFKJMQ` | | windows-arm64 Libraries | `HECDBFGIANLOKJMPQ` | `EHDCFPGJBIALNOKMQ` | If we see the pattern under the "1st best" column, we see that the sequence `E` and `H` are towards the beginning, meaning that overall, it is profitable to have `OWN_PREFERENCE` (one of the preferred registers for a given interval) or `CALLEE_CALLER` (caller and callee registers) as one of the first heuristic criteria. Next, most of the ordering has `C` and `D` that are also popular that maps to `THIS_ASSIGNED` (already assigned to the current interval) and `COVERS` (covers the lifetime of an interval). One of the busy register heuristics `P` that maps to `PREV_REG_OPT` (Previous reference of the currently assigned interval was optional) is also present at the beginning. While these ordering gives good `PerfScore`, there were several regressions observed for other methods. Most of the regressions falls under one or more of the following categories: 1. There are some key challenges in LSRA's resolution phase highlighted in [dotnet/runtime #47194](https://github.com/dotnet/runtime/issues/47194). Once resolution moves are identified for all the blocks, there is a need to revisit those moves to see if there are some that can be optimized out. Several methods regressed their `PerfScore` because we added lot of resolution moves at block boundaries. 2. Even though there is a flexibility of trying different register selection ordering, LSRA has limited knowledge about the method and portion of code for which it is allocating register. For example, during allocation, it doesn't know if it is allocating for code inside loop and that it should keep spare registers to use in that code. There has to be a phase before LSRA that consolidates this information in a data structure that can be used by LSRA during register selection. 3. While doing the experiments, we realized other low hanging fruits in LSRA that amplifies the regression caused by reordering the register selection heuristics. For example, if a variable is defined just once, it can be spilled at the place where it is defined and then, it doesn't need to be spilled throughout the method. This was achieved in [dotnet/runtime #54345](https://github.com/dotnet/runtime/pull/54345). ## Conclusion Register allocation is a complex topic, slight change in algorithm could have huge impact on the generated code. We explored various ideas for finding optimal heuristic selection ordering. Using Genetic algorithm, we could find optimal ordering and there was also some commonality in the heuristics order that was performance efficient for majority of configuration that we tested. However, with many improvements, there were also regressions in many methods across all configurations. We discovered that there was other area of improvements that need to be fixed first before we enable heuristic tuning feature, [[RyuJIT][LSRA]](https://github.com/dotnet/runtime/issues?q=is%3Aissue+is%3Aopen+%22%5BRyuJIT%5D%5BLSRA%5D%22+) captures some of the issues. Hence, we decided not to change any heuristic ordering at the current time. We will focus on fixing these issues first and once the existing LSRA weakness are addressed, we can choose to return to this experiment and use the techniques, tools, and knowledge here to inform a heuristic re-ordering. Going forward, we could also auto tune the heuristic ordering based on various factors like how many method parameters are present, if loops are present or not, exception handling, etc. Opportunities are endless, time is limited, so got to make better choices!
-1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/libraries/System.Diagnostics.Process/tests/ProcessStandardConsoleTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Text; using Microsoft.DotNet.RemoteExecutor; using Microsoft.Win32; using Xunit; namespace System.Diagnostics.Tests { public class ProcessStandardConsoleTests : ProcessTestBase { [ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))] public void TestChangesInConsoleEncoding() { const int ConsoleEncoding = 437; void RunWithExpectedCodePage(int expectedCodePage) { Process p = CreateProcessLong(); p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.Start(); Assert.Equal(expectedCodePage, p.StandardInput.Encoding.CodePage); Assert.Equal(expectedCodePage, p.StandardOutput.CurrentEncoding.CodePage); Assert.Equal(expectedCodePage, p.StandardError.CurrentEncoding.CodePage); p.Kill(); Assert.True(p.WaitForExit(WaitInMS)); }; // Don't test this on Windows containers, as the test is currently failing // cf. https://github.com/dotnet/runtime/issues/42000 if (!OperatingSystem.IsWindows() || PlatformDetection.IsInContainer) { RunWithExpectedCodePage(Encoding.UTF8.CodePage); return; } int inputEncoding = Interop.GetConsoleCP(); int outputEncoding = Interop.GetConsoleOutputCP(); try { Interop.SetConsoleCP(ConsoleEncoding); Interop.SetConsoleOutputCP(ConsoleEncoding); RunWithExpectedCodePage(ConsoleEncoding); } finally { Interop.SetConsoleCP(inputEncoding); Interop.SetConsoleOutputCP(outputEncoding); } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Text; using Microsoft.DotNet.RemoteExecutor; using Microsoft.Win32; using Xunit; namespace System.Diagnostics.Tests { public class ProcessStandardConsoleTests : ProcessTestBase { [ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))] public void TestChangesInConsoleEncoding() { const int ConsoleEncoding = 437; void RunWithExpectedCodePage(int expectedCodePage) { Process p = CreateProcessLong(); p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.Start(); Assert.Equal(expectedCodePage, p.StandardInput.Encoding.CodePage); Assert.Equal(expectedCodePage, p.StandardOutput.CurrentEncoding.CodePage); Assert.Equal(expectedCodePage, p.StandardError.CurrentEncoding.CodePage); p.Kill(); Assert.True(p.WaitForExit(WaitInMS)); }; // Don't test this on Windows containers, as there is a known issue. // See https://github.com/dotnet/runtime/issues/42000 for more details. if (!OperatingSystem.IsWindows() || PlatformDetection.IsInContainer) { RunWithExpectedCodePage(Encoding.UTF8.CodePage); return; } int inputEncoding = Interop.GetConsoleCP(); int outputEncoding = Interop.GetConsoleOutputCP(); try { Interop.SetConsoleCP(ConsoleEncoding); Interop.SetConsoleOutputCP(ConsoleEncoding); RunWithExpectedCodePage(ConsoleEncoding); } finally { Interop.SetConsoleCP(inputEncoding); Interop.SetConsoleOutputCP(outputEncoding); } } } }
1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryFormatterWriter.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; namespace System.Runtime.Serialization.Formatters.Binary { internal sealed class BinaryFormatterWriter { private const int ChunkSize = 4096; private readonly Stream _outputStream; private readonly FormatterTypeStyle _formatterTypeStyle; private readonly ObjectWriter _objectWriter; private readonly BinaryWriter _dataWriter; private int _consecutiveNullArrayEntryCount; private Dictionary<string, ObjectMapInfo>? _objectMapTable; private BinaryObject? _binaryObject; private BinaryObjectWithMap? _binaryObjectWithMap; private BinaryObjectWithMapTyped? _binaryObjectWithMapTyped; private BinaryObjectString? _binaryObjectString; private BinaryArray? _binaryArray; private byte[]? _byteBuffer; private MemberPrimitiveUnTyped? _memberPrimitiveUnTyped; private MemberPrimitiveTyped? _memberPrimitiveTyped; private ObjectNull? _objectNull; private MemberReference? _memberReference; private BinaryAssembly? _binaryAssembly; internal BinaryFormatterWriter(Stream outputStream, ObjectWriter objectWriter, FormatterTypeStyle formatterTypeStyle) { _outputStream = outputStream; _formatterTypeStyle = formatterTypeStyle; _objectWriter = objectWriter; _dataWriter = new BinaryWriter(outputStream, Encoding.UTF8); } internal void WriteBegin() { } internal void WriteEnd() { _dataWriter.Flush(); } internal void WriteBoolean(bool value) => _dataWriter.Write(value); internal void WriteByte(byte value) => _dataWriter.Write(value); private void WriteBytes(byte[] value) => _dataWriter.Write(value); private void WriteBytes(byte[] byteA, int offset, int size) => _dataWriter.Write(byteA, offset, size); internal void WriteChar(char value) => _dataWriter.Write(value); internal void WriteChars(char[] value) => _dataWriter.Write(value); internal void WriteDecimal(decimal value) => WriteString(value.ToString(CultureInfo.InvariantCulture)); internal void WriteSingle(float value) => _dataWriter.Write(value); internal void WriteDouble(double value) => _dataWriter.Write(value); internal void WriteInt16(short value) => _dataWriter.Write(value); internal void WriteInt32(int value) => _dataWriter.Write(value); internal void WriteInt64(long value) => _dataWriter.Write(value); internal void WriteSByte(sbyte value) => WriteByte(unchecked((byte)value)); internal void WriteString(string value) => _dataWriter.Write(value); internal void WriteTimeSpan(TimeSpan value) => WriteInt64(value.Ticks); internal void WriteDateTime(DateTime value) { // In .NET Framework, BinaryFormatter is able to access DateTime's ToBinaryRaw, // which just returns the value of its sole Int64 dateData field. Here, we don't // have access to that member (which doesn't even exist anymore, since it was only for // BinaryFormatter, which is now in a separate assembly). To address that, // we access the sole field directly via an unsafe cast. long dateData = Unsafe.As<DateTime, long>(ref value); WriteInt64(dateData); } internal void WriteUInt16(ushort value) => _dataWriter.Write(value); internal void WriteUInt32(uint value) => _dataWriter.Write(value); internal void WriteUInt64(ulong value) => _dataWriter.Write(value); internal void WriteObjectEnd(NameInfo memberNameInfo, NameInfo typeNameInfo) { } internal void WriteSerializationHeaderEnd() { var record = new MessageEnd(); record.Write(this); } internal void WriteSerializationHeader(int topId, int headerId, int minorVersion, int majorVersion) { var record = new SerializationHeaderRecord(BinaryHeaderEnum.SerializedStreamHeader, topId, headerId, minorVersion, majorVersion); record.Write(this); } internal void WriteObject(NameInfo nameInfo, NameInfo? typeNameInfo, int numMembers, string[] memberNames, Type[] memberTypes, WriteObjectInfo[] memberObjectInfos) { InternalWriteItemNull(); int assemId; int objectId = (int)nameInfo._objectId; Debug.Assert(typeNameInfo != null); // Explicitly called with null, asserting for now https://github.com/dotnet/runtime/issues/31402 string? objectName = objectId < 0 ? typeNameInfo.NIname : // Nested Object nameInfo.NIname; // Non-Nested if (_objectMapTable == null) { _objectMapTable = new Dictionary<string, ObjectMapInfo>(); } Debug.Assert(objectName != null); if (_objectMapTable.TryGetValue(objectName, out ObjectMapInfo? objectMapInfo) && objectMapInfo.IsCompatible(numMembers, memberNames, memberTypes)) { // Object if (_binaryObject == null) { _binaryObject = new BinaryObject(); } _binaryObject.Set(objectId, objectMapInfo._objectId); _binaryObject.Write(this); } else if (!typeNameInfo._transmitTypeOnObject) { // ObjectWithMap if (_binaryObjectWithMap == null) { _binaryObjectWithMap = new BinaryObjectWithMap(); } // BCL types are not placed into table assemId = (int)typeNameInfo._assemId; _binaryObjectWithMap.Set(objectId, objectName, numMembers, memberNames, assemId); _binaryObjectWithMap.Write(this); if (objectMapInfo == null) { _objectMapTable.Add(objectName, new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes)); } } else { // ObjectWithMapTyped var binaryTypeEnumA = new BinaryTypeEnum[numMembers]; var typeInformationA = new object?[numMembers]; var assemIdA = new int[numMembers]; for (int i = 0; i < numMembers; i++) { object? typeInformation; binaryTypeEnumA[i] = BinaryTypeConverter.GetBinaryTypeInfo(memberTypes[i], memberObjectInfos[i], null, _objectWriter, out typeInformation, out assemId); typeInformationA[i] = typeInformation; assemIdA[i] = assemId; } if (_binaryObjectWithMapTyped == null) { _binaryObjectWithMapTyped = new BinaryObjectWithMapTyped(); } // BCL types are not placed in table assemId = (int)typeNameInfo._assemId; _binaryObjectWithMapTyped.Set(objectId, objectName, numMembers, memberNames, binaryTypeEnumA, typeInformationA, assemIdA, assemId); _binaryObjectWithMapTyped.Write(this); if (objectMapInfo == null) { _objectMapTable.Add(objectName, new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes)); } } } internal void WriteObjectString(int objectId, string? value) { InternalWriteItemNull(); if (_binaryObjectString == null) { _binaryObjectString = new BinaryObjectString(); } _binaryObjectString.Set(objectId, value); _binaryObjectString.Write(this); } internal void WriteSingleArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo? objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound, Array array) { InternalWriteItemNull(); BinaryArrayTypeEnum binaryArrayTypeEnum; var lengthA = new int[1]; lengthA[0] = length; int[]? lowerBoundA = null; object? typeInformation; if (lowerBound == 0) { binaryArrayTypeEnum = BinaryArrayTypeEnum.Single; } else { binaryArrayTypeEnum = BinaryArrayTypeEnum.SingleOffset; lowerBoundA = new int[1]; lowerBoundA[0] = lowerBound; } int assemId; BinaryTypeEnum binaryTypeEnum = BinaryTypeConverter.GetBinaryTypeInfo( arrayElemTypeNameInfo._type!, objectInfo, arrayElemTypeNameInfo.NIname, _objectWriter, out typeInformation, out assemId); if (_binaryArray == null) { _binaryArray = new BinaryArray(); } _binaryArray.Set((int)arrayNameInfo._objectId, 1, lengthA, lowerBoundA, binaryTypeEnum, typeInformation, binaryArrayTypeEnum, assemId); _binaryArray.Write(this); if (Converter.IsWriteAsByteArray(arrayElemTypeNameInfo._primitiveTypeEnum) && (lowerBound == 0)) { //array is written out as an array of bytes if (arrayElemTypeNameInfo._primitiveTypeEnum == InternalPrimitiveTypeE.Byte) { WriteBytes((byte[])array); } else if (arrayElemTypeNameInfo._primitiveTypeEnum == InternalPrimitiveTypeE.Char) { WriteChars((char[])array); } else { WriteArrayAsBytes(array, Converter.TypeLength(arrayElemTypeNameInfo._primitiveTypeEnum)); } } } private void WriteArrayAsBytes(Array array, int typeLength) { InternalWriteItemNull(); int arrayOffset = 0; if (_byteBuffer == null) { _byteBuffer = new byte[ChunkSize]; } while (arrayOffset < array.Length) { int numArrayItems = Math.Min(ChunkSize / typeLength, array.Length - arrayOffset); int bufferUsed = numArrayItems * typeLength; Buffer.BlockCopy(array, arrayOffset * typeLength, _byteBuffer, 0, bufferUsed); if (!BitConverter.IsLittleEndian) { // we know that we are writing a primitive type, so just do a simple swap for (int i = 0; i < bufferUsed; i += typeLength) { for (int j = 0; j < typeLength / 2; j++) { byte tmp = _byteBuffer[i + j]; _byteBuffer[i + j] = _byteBuffer[i + typeLength - 1 - j]; _byteBuffer[i + typeLength - 1 - j] = tmp; } } } WriteBytes(_byteBuffer, 0, bufferUsed); arrayOffset += numArrayItems; } } internal void WriteJaggedArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo? objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound) { InternalWriteItemNull(); BinaryArrayTypeEnum binaryArrayTypeEnum; var lengthA = new int[1]; lengthA[0] = length; int[]? lowerBoundA = null; object? typeInformation; int assemId; if (lowerBound == 0) { binaryArrayTypeEnum = BinaryArrayTypeEnum.Jagged; } else { binaryArrayTypeEnum = BinaryArrayTypeEnum.JaggedOffset; lowerBoundA = new int[1]; lowerBoundA[0] = lowerBound; } BinaryTypeEnum binaryTypeEnum = BinaryTypeConverter.GetBinaryTypeInfo(arrayElemTypeNameInfo._type!, objectInfo, arrayElemTypeNameInfo.NIname, _objectWriter, out typeInformation, out assemId); if (_binaryArray == null) { _binaryArray = new BinaryArray(); } _binaryArray.Set((int)arrayNameInfo._objectId, 1, lengthA, lowerBoundA, binaryTypeEnum, typeInformation, binaryArrayTypeEnum, assemId); _binaryArray.Write(this); } internal void WriteRectangleArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo? objectInfo, NameInfo arrayElemTypeNameInfo, int rank, int[] lengthA, int[] lowerBoundA) { InternalWriteItemNull(); BinaryArrayTypeEnum binaryArrayTypeEnum = BinaryArrayTypeEnum.Rectangular; object? typeInformation; int assemId; BinaryTypeEnum binaryTypeEnum = BinaryTypeConverter.GetBinaryTypeInfo(arrayElemTypeNameInfo._type!, objectInfo, arrayElemTypeNameInfo.NIname, _objectWriter, out typeInformation, out assemId); if (_binaryArray == null) { _binaryArray = new BinaryArray(); } for (int i = 0; i < rank; i++) { if (lowerBoundA[i] != 0) { binaryArrayTypeEnum = BinaryArrayTypeEnum.RectangularOffset; break; } } _binaryArray.Set((int)arrayNameInfo._objectId, rank, lengthA, lowerBoundA, binaryTypeEnum, typeInformation, binaryArrayTypeEnum, assemId); _binaryArray.Write(this); } internal void WriteObjectByteArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo? objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound, byte[] byteA) { InternalWriteItemNull(); WriteSingleArray(memberNameInfo, arrayNameInfo, objectInfo, arrayElemTypeNameInfo, length, lowerBound, byteA); } internal void WriteMember(NameInfo memberNameInfo, NameInfo typeNameInfo, object value) { InternalWriteItemNull(); InternalPrimitiveTypeE typeInformation = typeNameInfo._primitiveTypeEnum; // Writes Members with primitive values if (memberNameInfo._transmitTypeOnMember) { if (_memberPrimitiveTyped == null) { _memberPrimitiveTyped = new MemberPrimitiveTyped(); } _memberPrimitiveTyped.Set(typeInformation, value); _memberPrimitiveTyped.Write(this); } else { if (_memberPrimitiveUnTyped == null) { _memberPrimitiveUnTyped = new MemberPrimitiveUnTyped(); } _memberPrimitiveUnTyped.Set(typeInformation, value); _memberPrimitiveUnTyped.Write(this); } } internal void WriteNullMember(NameInfo memberNameInfo, NameInfo typeNameInfo) { InternalWriteItemNull(); if (_objectNull == null) { _objectNull = new ObjectNull(); } if (!memberNameInfo._isArrayItem) { _objectNull.SetNullCount(1); _objectNull.Write(this); _consecutiveNullArrayEntryCount = 0; } } internal void WriteMemberObjectRef(NameInfo memberNameInfo, int idRef) { InternalWriteItemNull(); if (_memberReference == null) { _memberReference = new MemberReference(); } _memberReference.Set(idRef); _memberReference.Write(this); } internal void WriteMemberNested(NameInfo memberNameInfo) { InternalWriteItemNull(); } internal void WriteMemberString(NameInfo memberNameInfo, NameInfo typeNameInfo, string? value) { InternalWriteItemNull(); WriteObjectString((int)typeNameInfo._objectId, value); } internal void WriteItem(NameInfo itemNameInfo, NameInfo typeNameInfo, object value) { InternalWriteItemNull(); WriteMember(itemNameInfo, typeNameInfo, value); } internal void WriteNullItem(NameInfo itemNameInfo, NameInfo typeNameInfo) { _consecutiveNullArrayEntryCount++; InternalWriteItemNull(); } internal void WriteDelayedNullItem() { _consecutiveNullArrayEntryCount++; } internal void WriteItemEnd() => InternalWriteItemNull(); private void InternalWriteItemNull() { if (_consecutiveNullArrayEntryCount > 0) { if (_objectNull == null) { _objectNull = new ObjectNull(); } _objectNull.SetNullCount(_consecutiveNullArrayEntryCount); _objectNull.Write(this); _consecutiveNullArrayEntryCount = 0; } } internal void WriteItemObjectRef(NameInfo nameInfo, int idRef) { InternalWriteItemNull(); WriteMemberObjectRef(nameInfo, idRef); } internal void WriteAssembly(Type? type, string assemblyString, int assemId, bool isNew) { //If the file being tested wasn't built as an assembly, then we're going to get null back //for the assembly name. This is very unfortunate. InternalWriteItemNull(); if (assemblyString == null) { assemblyString = string.Empty; } if (isNew) { if (_binaryAssembly == null) { _binaryAssembly = new BinaryAssembly(); } _binaryAssembly.Set(assemId, assemblyString); _binaryAssembly.Write(this); } } // Method to write a value onto a stream given its primitive type code internal void WriteValue(InternalPrimitiveTypeE code, object? value) { switch (code) { case InternalPrimitiveTypeE.Boolean: WriteBoolean(Convert.ToBoolean(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.Byte: WriteByte(Convert.ToByte(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.Char: WriteChar(Convert.ToChar(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.Double: WriteDouble(Convert.ToDouble(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.Int16: WriteInt16(Convert.ToInt16(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.Int32: WriteInt32(Convert.ToInt32(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.Int64: WriteInt64(Convert.ToInt64(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.SByte: WriteSByte(Convert.ToSByte(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.Single: WriteSingle(Convert.ToSingle(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.UInt16: WriteUInt16(Convert.ToUInt16(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.UInt32: WriteUInt32(Convert.ToUInt32(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.UInt64: WriteUInt64(Convert.ToUInt64(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.Decimal: WriteDecimal(Convert.ToDecimal(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.TimeSpan: WriteTimeSpan((TimeSpan)value!); break; case InternalPrimitiveTypeE.DateTime: WriteDateTime((DateTime)value!); break; default: throw new SerializationException(SR.Format(SR.Serialization_TypeCode, code.ToString())); } } private sealed class ObjectMapInfo { internal readonly int _objectId; private readonly int _numMembers; private readonly string[] _memberNames; private readonly Type[] _memberTypes; internal ObjectMapInfo(int objectId, int numMembers, string[] memberNames, Type[] memberTypes) { _objectId = objectId; _numMembers = numMembers; _memberNames = memberNames; _memberTypes = memberTypes; } internal bool IsCompatible(int numMembers, string[] memberNames, Type[]? memberTypes) { if (_numMembers != numMembers) { return false; } for (int i = 0; i < numMembers; i++) { if (!(_memberNames[i].Equals(memberNames[i]))) { return false; } if ((memberTypes != null) && (_memberTypes[i] != memberTypes[i])) { return false; } } return true; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; namespace System.Runtime.Serialization.Formatters.Binary { internal sealed class BinaryFormatterWriter { private const int ChunkSize = 4096; private readonly Stream _outputStream; private readonly FormatterTypeStyle _formatterTypeStyle; private readonly ObjectWriter _objectWriter; private readonly BinaryWriter _dataWriter; private int _consecutiveNullArrayEntryCount; private Dictionary<string, ObjectMapInfo>? _objectMapTable; private BinaryObject? _binaryObject; private BinaryObjectWithMap? _binaryObjectWithMap; private BinaryObjectWithMapTyped? _binaryObjectWithMapTyped; private BinaryObjectString? _binaryObjectString; private BinaryArray? _binaryArray; private byte[]? _byteBuffer; private MemberPrimitiveUnTyped? _memberPrimitiveUnTyped; private MemberPrimitiveTyped? _memberPrimitiveTyped; private ObjectNull? _objectNull; private MemberReference? _memberReference; private BinaryAssembly? _binaryAssembly; internal BinaryFormatterWriter(Stream outputStream, ObjectWriter objectWriter, FormatterTypeStyle formatterTypeStyle) { _outputStream = outputStream; _formatterTypeStyle = formatterTypeStyle; _objectWriter = objectWriter; _dataWriter = new BinaryWriter(outputStream, Encoding.UTF8); } internal void WriteBegin() { } internal void WriteEnd() { _dataWriter.Flush(); } internal void WriteBoolean(bool value) => _dataWriter.Write(value); internal void WriteByte(byte value) => _dataWriter.Write(value); private void WriteBytes(byte[] value) => _dataWriter.Write(value); private void WriteBytes(byte[] byteA, int offset, int size) => _dataWriter.Write(byteA, offset, size); internal void WriteChar(char value) => _dataWriter.Write(value); internal void WriteChars(char[] value) => _dataWriter.Write(value); internal void WriteDecimal(decimal value) => WriteString(value.ToString(CultureInfo.InvariantCulture)); internal void WriteSingle(float value) => _dataWriter.Write(value); internal void WriteDouble(double value) => _dataWriter.Write(value); internal void WriteInt16(short value) => _dataWriter.Write(value); internal void WriteInt32(int value) => _dataWriter.Write(value); internal void WriteInt64(long value) => _dataWriter.Write(value); internal void WriteSByte(sbyte value) => WriteByte(unchecked((byte)value)); internal void WriteString(string value) => _dataWriter.Write(value); internal void WriteTimeSpan(TimeSpan value) => WriteInt64(value.Ticks); internal void WriteDateTime(DateTime value) { // In .NET Framework, BinaryFormatter is able to access DateTime's ToBinaryRaw, // which just returns the value of its sole Int64 dateData field. Here, we don't // have access to that member (which doesn't even exist anymore, since it was only for // BinaryFormatter, which is now in a separate assembly). To address that, // we access the sole field directly via an unsafe cast. long dateData = Unsafe.As<DateTime, long>(ref value); WriteInt64(dateData); } internal void WriteUInt16(ushort value) => _dataWriter.Write(value); internal void WriteUInt32(uint value) => _dataWriter.Write(value); internal void WriteUInt64(ulong value) => _dataWriter.Write(value); internal void WriteObjectEnd(NameInfo memberNameInfo, NameInfo typeNameInfo) { } internal void WriteSerializationHeaderEnd() { var record = new MessageEnd(); record.Write(this); } internal void WriteSerializationHeader(int topId, int headerId, int minorVersion, int majorVersion) { var record = new SerializationHeaderRecord(BinaryHeaderEnum.SerializedStreamHeader, topId, headerId, minorVersion, majorVersion); record.Write(this); } internal void WriteObject(NameInfo nameInfo, NameInfo? typeNameInfo, int numMembers, string[] memberNames, Type[] memberTypes, WriteObjectInfo[] memberObjectInfos) { InternalWriteItemNull(); int assemId; int objectId = (int)nameInfo._objectId; Debug.Assert(typeNameInfo != null); // Explicitly called with null. Potential bug, but closed as Won't Fix: https://github.com/dotnet/runtime/issues/31402 string? objectName = objectId < 0 ? typeNameInfo.NIname : // Nested Object nameInfo.NIname; // Non-Nested if (_objectMapTable == null) { _objectMapTable = new Dictionary<string, ObjectMapInfo>(); } Debug.Assert(objectName != null); if (_objectMapTable.TryGetValue(objectName, out ObjectMapInfo? objectMapInfo) && objectMapInfo.IsCompatible(numMembers, memberNames, memberTypes)) { // Object if (_binaryObject == null) { _binaryObject = new BinaryObject(); } _binaryObject.Set(objectId, objectMapInfo._objectId); _binaryObject.Write(this); } else if (!typeNameInfo._transmitTypeOnObject) { // ObjectWithMap if (_binaryObjectWithMap == null) { _binaryObjectWithMap = new BinaryObjectWithMap(); } // BCL types are not placed into table assemId = (int)typeNameInfo._assemId; _binaryObjectWithMap.Set(objectId, objectName, numMembers, memberNames, assemId); _binaryObjectWithMap.Write(this); if (objectMapInfo == null) { _objectMapTable.Add(objectName, new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes)); } } else { // ObjectWithMapTyped var binaryTypeEnumA = new BinaryTypeEnum[numMembers]; var typeInformationA = new object?[numMembers]; var assemIdA = new int[numMembers]; for (int i = 0; i < numMembers; i++) { object? typeInformation; binaryTypeEnumA[i] = BinaryTypeConverter.GetBinaryTypeInfo(memberTypes[i], memberObjectInfos[i], null, _objectWriter, out typeInformation, out assemId); typeInformationA[i] = typeInformation; assemIdA[i] = assemId; } if (_binaryObjectWithMapTyped == null) { _binaryObjectWithMapTyped = new BinaryObjectWithMapTyped(); } // BCL types are not placed in table assemId = (int)typeNameInfo._assemId; _binaryObjectWithMapTyped.Set(objectId, objectName, numMembers, memberNames, binaryTypeEnumA, typeInformationA, assemIdA, assemId); _binaryObjectWithMapTyped.Write(this); if (objectMapInfo == null) { _objectMapTable.Add(objectName, new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes)); } } } internal void WriteObjectString(int objectId, string? value) { InternalWriteItemNull(); if (_binaryObjectString == null) { _binaryObjectString = new BinaryObjectString(); } _binaryObjectString.Set(objectId, value); _binaryObjectString.Write(this); } internal void WriteSingleArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo? objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound, Array array) { InternalWriteItemNull(); BinaryArrayTypeEnum binaryArrayTypeEnum; var lengthA = new int[1]; lengthA[0] = length; int[]? lowerBoundA = null; object? typeInformation; if (lowerBound == 0) { binaryArrayTypeEnum = BinaryArrayTypeEnum.Single; } else { binaryArrayTypeEnum = BinaryArrayTypeEnum.SingleOffset; lowerBoundA = new int[1]; lowerBoundA[0] = lowerBound; } int assemId; BinaryTypeEnum binaryTypeEnum = BinaryTypeConverter.GetBinaryTypeInfo( arrayElemTypeNameInfo._type!, objectInfo, arrayElemTypeNameInfo.NIname, _objectWriter, out typeInformation, out assemId); if (_binaryArray == null) { _binaryArray = new BinaryArray(); } _binaryArray.Set((int)arrayNameInfo._objectId, 1, lengthA, lowerBoundA, binaryTypeEnum, typeInformation, binaryArrayTypeEnum, assemId); _binaryArray.Write(this); if (Converter.IsWriteAsByteArray(arrayElemTypeNameInfo._primitiveTypeEnum) && (lowerBound == 0)) { //array is written out as an array of bytes if (arrayElemTypeNameInfo._primitiveTypeEnum == InternalPrimitiveTypeE.Byte) { WriteBytes((byte[])array); } else if (arrayElemTypeNameInfo._primitiveTypeEnum == InternalPrimitiveTypeE.Char) { WriteChars((char[])array); } else { WriteArrayAsBytes(array, Converter.TypeLength(arrayElemTypeNameInfo._primitiveTypeEnum)); } } } private void WriteArrayAsBytes(Array array, int typeLength) { InternalWriteItemNull(); int arrayOffset = 0; if (_byteBuffer == null) { _byteBuffer = new byte[ChunkSize]; } while (arrayOffset < array.Length) { int numArrayItems = Math.Min(ChunkSize / typeLength, array.Length - arrayOffset); int bufferUsed = numArrayItems * typeLength; Buffer.BlockCopy(array, arrayOffset * typeLength, _byteBuffer, 0, bufferUsed); if (!BitConverter.IsLittleEndian) { // we know that we are writing a primitive type, so just do a simple swap for (int i = 0; i < bufferUsed; i += typeLength) { for (int j = 0; j < typeLength / 2; j++) { byte tmp = _byteBuffer[i + j]; _byteBuffer[i + j] = _byteBuffer[i + typeLength - 1 - j]; _byteBuffer[i + typeLength - 1 - j] = tmp; } } } WriteBytes(_byteBuffer, 0, bufferUsed); arrayOffset += numArrayItems; } } internal void WriteJaggedArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo? objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound) { InternalWriteItemNull(); BinaryArrayTypeEnum binaryArrayTypeEnum; var lengthA = new int[1]; lengthA[0] = length; int[]? lowerBoundA = null; object? typeInformation; int assemId; if (lowerBound == 0) { binaryArrayTypeEnum = BinaryArrayTypeEnum.Jagged; } else { binaryArrayTypeEnum = BinaryArrayTypeEnum.JaggedOffset; lowerBoundA = new int[1]; lowerBoundA[0] = lowerBound; } BinaryTypeEnum binaryTypeEnum = BinaryTypeConverter.GetBinaryTypeInfo(arrayElemTypeNameInfo._type!, objectInfo, arrayElemTypeNameInfo.NIname, _objectWriter, out typeInformation, out assemId); if (_binaryArray == null) { _binaryArray = new BinaryArray(); } _binaryArray.Set((int)arrayNameInfo._objectId, 1, lengthA, lowerBoundA, binaryTypeEnum, typeInformation, binaryArrayTypeEnum, assemId); _binaryArray.Write(this); } internal void WriteRectangleArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo? objectInfo, NameInfo arrayElemTypeNameInfo, int rank, int[] lengthA, int[] lowerBoundA) { InternalWriteItemNull(); BinaryArrayTypeEnum binaryArrayTypeEnum = BinaryArrayTypeEnum.Rectangular; object? typeInformation; int assemId; BinaryTypeEnum binaryTypeEnum = BinaryTypeConverter.GetBinaryTypeInfo(arrayElemTypeNameInfo._type!, objectInfo, arrayElemTypeNameInfo.NIname, _objectWriter, out typeInformation, out assemId); if (_binaryArray == null) { _binaryArray = new BinaryArray(); } for (int i = 0; i < rank; i++) { if (lowerBoundA[i] != 0) { binaryArrayTypeEnum = BinaryArrayTypeEnum.RectangularOffset; break; } } _binaryArray.Set((int)arrayNameInfo._objectId, rank, lengthA, lowerBoundA, binaryTypeEnum, typeInformation, binaryArrayTypeEnum, assemId); _binaryArray.Write(this); } internal void WriteObjectByteArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo? objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound, byte[] byteA) { InternalWriteItemNull(); WriteSingleArray(memberNameInfo, arrayNameInfo, objectInfo, arrayElemTypeNameInfo, length, lowerBound, byteA); } internal void WriteMember(NameInfo memberNameInfo, NameInfo typeNameInfo, object value) { InternalWriteItemNull(); InternalPrimitiveTypeE typeInformation = typeNameInfo._primitiveTypeEnum; // Writes Members with primitive values if (memberNameInfo._transmitTypeOnMember) { if (_memberPrimitiveTyped == null) { _memberPrimitiveTyped = new MemberPrimitiveTyped(); } _memberPrimitiveTyped.Set(typeInformation, value); _memberPrimitiveTyped.Write(this); } else { if (_memberPrimitiveUnTyped == null) { _memberPrimitiveUnTyped = new MemberPrimitiveUnTyped(); } _memberPrimitiveUnTyped.Set(typeInformation, value); _memberPrimitiveUnTyped.Write(this); } } internal void WriteNullMember(NameInfo memberNameInfo, NameInfo typeNameInfo) { InternalWriteItemNull(); if (_objectNull == null) { _objectNull = new ObjectNull(); } if (!memberNameInfo._isArrayItem) { _objectNull.SetNullCount(1); _objectNull.Write(this); _consecutiveNullArrayEntryCount = 0; } } internal void WriteMemberObjectRef(NameInfo memberNameInfo, int idRef) { InternalWriteItemNull(); if (_memberReference == null) { _memberReference = new MemberReference(); } _memberReference.Set(idRef); _memberReference.Write(this); } internal void WriteMemberNested(NameInfo memberNameInfo) { InternalWriteItemNull(); } internal void WriteMemberString(NameInfo memberNameInfo, NameInfo typeNameInfo, string? value) { InternalWriteItemNull(); WriteObjectString((int)typeNameInfo._objectId, value); } internal void WriteItem(NameInfo itemNameInfo, NameInfo typeNameInfo, object value) { InternalWriteItemNull(); WriteMember(itemNameInfo, typeNameInfo, value); } internal void WriteNullItem(NameInfo itemNameInfo, NameInfo typeNameInfo) { _consecutiveNullArrayEntryCount++; InternalWriteItemNull(); } internal void WriteDelayedNullItem() { _consecutiveNullArrayEntryCount++; } internal void WriteItemEnd() => InternalWriteItemNull(); private void InternalWriteItemNull() { if (_consecutiveNullArrayEntryCount > 0) { if (_objectNull == null) { _objectNull = new ObjectNull(); } _objectNull.SetNullCount(_consecutiveNullArrayEntryCount); _objectNull.Write(this); _consecutiveNullArrayEntryCount = 0; } } internal void WriteItemObjectRef(NameInfo nameInfo, int idRef) { InternalWriteItemNull(); WriteMemberObjectRef(nameInfo, idRef); } internal void WriteAssembly(Type? type, string assemblyString, int assemId, bool isNew) { //If the file being tested wasn't built as an assembly, then we're going to get null back //for the assembly name. This is very unfortunate. InternalWriteItemNull(); if (assemblyString == null) { assemblyString = string.Empty; } if (isNew) { if (_binaryAssembly == null) { _binaryAssembly = new BinaryAssembly(); } _binaryAssembly.Set(assemId, assemblyString); _binaryAssembly.Write(this); } } // Method to write a value onto a stream given its primitive type code internal void WriteValue(InternalPrimitiveTypeE code, object? value) { switch (code) { case InternalPrimitiveTypeE.Boolean: WriteBoolean(Convert.ToBoolean(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.Byte: WriteByte(Convert.ToByte(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.Char: WriteChar(Convert.ToChar(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.Double: WriteDouble(Convert.ToDouble(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.Int16: WriteInt16(Convert.ToInt16(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.Int32: WriteInt32(Convert.ToInt32(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.Int64: WriteInt64(Convert.ToInt64(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.SByte: WriteSByte(Convert.ToSByte(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.Single: WriteSingle(Convert.ToSingle(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.UInt16: WriteUInt16(Convert.ToUInt16(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.UInt32: WriteUInt32(Convert.ToUInt32(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.UInt64: WriteUInt64(Convert.ToUInt64(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.Decimal: WriteDecimal(Convert.ToDecimal(value, CultureInfo.InvariantCulture)); break; case InternalPrimitiveTypeE.TimeSpan: WriteTimeSpan((TimeSpan)value!); break; case InternalPrimitiveTypeE.DateTime: WriteDateTime((DateTime)value!); break; default: throw new SerializationException(SR.Format(SR.Serialization_TypeCode, code.ToString())); } } private sealed class ObjectMapInfo { internal readonly int _objectId; private readonly int _numMembers; private readonly string[] _memberNames; private readonly Type[] _memberTypes; internal ObjectMapInfo(int objectId, int numMembers, string[] memberNames, Type[] memberTypes) { _objectId = objectId; _numMembers = numMembers; _memberNames = memberNames; _memberTypes = memberTypes; } internal bool IsCompatible(int numMembers, string[] memberNames, Type[]? memberTypes) { if (_numMembers != numMembers) { return false; } for (int i = 0; i < numMembers; i++) { if (!(_memberNames[i].Equals(memberNames[i]))) { return false; } if ((memberTypes != null) && (_memberTypes[i] != memberTypes[i])) { return false; } } return true; } } } }
1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/libraries/System.Text.RegularExpressions/tests/Regex.Groups.Tests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Globalization; using System.Tests; using System.Threading.Tasks; using Xunit; namespace System.Text.RegularExpressions.Tests { public class RegexGroupTests { public static IEnumerable<object[]> Groups_Basic_TestData() { foreach (RegexEngine engine in RegexHelpers.AvailableEngines) { // (A - B) B is a subset of A(ie B only contains chars that are in A) yield return new object[] { engine, null, "[abcd-[d]]+", "dddaabbccddd", RegexOptions.None, new string[] { "aabbcc" } }; yield return new object[] { engine, null, @"[\d-[357]]+", "33312468955", RegexOptions.None, new string[] { "124689" } }; yield return new object[] { engine, null, @"[\d-[357]]+", "51246897", RegexOptions.None, new string[] { "124689" } }; yield return new object[] { engine, null, @"[\d-[357]]+", "3312468977", RegexOptions.None, new string[] { "124689" } }; yield return new object[] { engine, null, @"[\w-[b-y]]+", "bbbaaaABCD09zzzyyy", RegexOptions.None, new string[] { "aaaABCD09zzz" } }; yield return new object[] { engine, null, @"[\w-[\d]]+", "0AZaz9", RegexOptions.None, new string[] { "AZaz" } }; yield return new object[] { engine, null, @"[\w-[\p{Ll}]]+", "a09AZz", RegexOptions.None, new string[] { "09AZ" } }; yield return new object[] { engine, null, @"[\d-[13579]]+", "1024689", RegexOptions.ECMAScript, new string[] { "02468" } }; yield return new object[] { engine, null, @"[\d-[13579]]+", "\x066102468\x0660", RegexOptions.ECMAScript, new string[] { "02468" } }; yield return new object[] { engine, null, @"[\d-[13579]]+", "\x066102468\x0660", RegexOptions.None, new string[] { "\x066102468\x0660" } }; yield return new object[] { engine, null, @"[\p{Ll}-[ae-z]]+", "aaabbbcccdddeee", RegexOptions.None, new string[] { "bbbcccddd" } }; yield return new object[] { engine, null, @"[\p{Nd}-[2468]]+", "20135798", RegexOptions.None, new string[] { "013579" } }; yield return new object[] { engine, null, @"[\P{Lu}-[ae-z]]+", "aaabbbcccdddeee", RegexOptions.None, new string[] { "bbbcccddd" } }; yield return new object[] { engine, null, @"[\P{Nd}-[\p{Ll}]]+", "az09AZ'[]", RegexOptions.None, new string[] { "AZ'[]" } }; // (A - B) B is a superset of A (ie B contains chars that are in A plus other chars that are not in A) yield return new object[] { engine, null, "[abcd-[def]]+", "fedddaabbccddd", RegexOptions.None, new string[] { "aabbcc" } }; yield return new object[] { engine, null, @"[\d-[357a-z]]+", "az33312468955", RegexOptions.None, new string[] { "124689" } }; yield return new object[] { engine, null, @"[\d-[de357fgA-Z]]+", "AZ51246897", RegexOptions.None, new string[] { "124689" } }; yield return new object[] { engine, null, @"[\d-[357\p{Ll}]]+", "az3312468977", RegexOptions.None, new string[] { "124689" } }; yield return new object[] { engine, null, @"[\w-[b-y\s]]+", " \tbbbaaaABCD09zzzyyy", RegexOptions.None, new string[] { "aaaABCD09zzz" } }; yield return new object[] { engine, null, @"[\w-[\d\p{Po}]]+", "!#0AZaz9", RegexOptions.None, new string[] { "AZaz" } }; yield return new object[] { engine, null, @"[\w-[\p{Ll}\s]]+", "a09AZz", RegexOptions.None, new string[] { "09AZ" } }; yield return new object[] { engine, null, @"[\d-[13579a-zA-Z]]+", "AZ1024689", RegexOptions.ECMAScript, new string[] { "02468" } }; yield return new object[] { engine, null, @"[\d-[13579abcd]]+", "abcd\x066102468\x0660", RegexOptions.ECMAScript, new string[] { "02468" } }; yield return new object[] { engine, null, @"[\d-[13579\s]]+", " \t\x066102468\x0660", RegexOptions.None, new string[] { "\x066102468\x0660" } }; yield return new object[] { engine, null, @"[\w-[b-y\p{Po}]]+", "!#bbbaaaABCD09zzzyyy", RegexOptions.None, new string[] { "aaaABCD09zzz" } }; yield return new object[] { engine, null, @"[\w-[b-y!.,]]+", "!.,bbbaaaABCD09zzzyyy", RegexOptions.None, new string[] { "aaaABCD09zzz" } }; yield return new object[] { engine, null, "[\\w-[b-y\x00-\x0F]]+", "\0bbbaaaABCD09zzzyyy", RegexOptions.None, new string[] { "aaaABCD09zzz" } }; yield return new object[] { engine, null, @"[\p{Ll}-[ae-z0-9]]+", "09aaabbbcccdddeee", RegexOptions.None, new string[] { "bbbcccddd" } }; yield return new object[] { engine, null, @"[\p{Nd}-[2468az]]+", "az20135798", RegexOptions.None, new string[] { "013579" } }; yield return new object[] { engine, null, @"[\P{Lu}-[ae-zA-Z]]+", "AZaaabbbcccdddeee", RegexOptions.None, new string[] { "bbbcccddd" } }; yield return new object[] { engine, null, @"[\P{Nd}-[\p{Ll}0123456789]]+", "09az09AZ'[]", RegexOptions.None, new string[] { "AZ'[]" } }; // (A - B) B only contains chars that are not in A yield return new object[] { engine, null, "[abc-[defg]]+", "dddaabbccddd", RegexOptions.None, new string[] { "aabbcc" } }; yield return new object[] { engine, null, @"[\d-[abc]]+", "abc09abc", RegexOptions.None, new string[] { "09" } }; yield return new object[] { engine, null, @"[\d-[a-zA-Z]]+", "az09AZ", RegexOptions.None, new string[] { "09" } }; yield return new object[] { engine, null, @"[\d-[\p{Ll}]]+", "az09az", RegexOptions.None, new string[] { "09" } }; yield return new object[] { engine, null, @"[\w-[\x00-\x0F]]+", "bbbaaaABYZ09zzzyyy", RegexOptions.None, new string[] { "bbbaaaABYZ09zzzyyy" } }; yield return new object[] { engine, null, @"[\w-[\s]]+", "0AZaz9", RegexOptions.None, new string[] { "0AZaz9" } }; yield return new object[] { engine, null, @"[\w-[\W]]+", "0AZaz9", RegexOptions.None, new string[] { "0AZaz9" } }; yield return new object[] { engine, null, @"[\w-[\p{Po}]]+", "#a09AZz!", RegexOptions.None, new string[] { "a09AZz" } }; yield return new object[] { engine, null, @"[\d-[\D]]+", "azAZ1024689", RegexOptions.ECMAScript, new string[] { "1024689" } }; yield return new object[] { engine, null, @"[\d-[a-zA-Z]]+", "azAZ\x066102468\x0660", RegexOptions.ECMAScript, new string[] { "02468" } }; yield return new object[] { engine, null, @"[\d-[\p{Ll}]]+", "\x066102468\x0660", RegexOptions.None, new string[] { "\x066102468\x0660" } }; yield return new object[] { engine, null, @"[a-zA-Z0-9-[\s]]+", " \tazAZ09", RegexOptions.None, new string[] { "azAZ09" } }; yield return new object[] { engine, null, @"[a-zA-Z0-9-[\W]]+", "bbbaaaABCD09zzzyyy", RegexOptions.None, new string[] { "bbbaaaABCD09zzzyyy" } }; yield return new object[] { engine, null, @"[a-zA-Z0-9-[^a-zA-Z0-9]]+", "bbbaaaABCD09zzzyyy", RegexOptions.None, new string[] { "bbbaaaABCD09zzzyyy" } }; yield return new object[] { engine, null, @"[\p{Ll}-[A-Z]]+", "AZaz09", RegexOptions.None, new string[] { "az" } }; yield return new object[] { engine, null, @"[\p{Nd}-[a-z]]+", "az09", RegexOptions.None, new string[] { "09" } }; yield return new object[] { engine, null, @"[\P{Lu}-[\p{Lu}]]+", "AZazAZ", RegexOptions.None, new string[] { "az" } }; yield return new object[] { engine, null, @"[\P{Lu}-[A-Z]]+", "AZazAZ", RegexOptions.None, new string[] { "az" } }; yield return new object[] { engine, null, @"[\P{Nd}-[\p{Nd}]]+", "azAZ09", RegexOptions.None, new string[] { "azAZ" } }; yield return new object[] { engine, null, @"[\P{Nd}-[2-8]]+", "1234567890azAZ1234567890", RegexOptions.None, new string[] { "azAZ" } }; // Alternating construct yield return new object[] { engine, null, @"([ ]|[\w-[0-9]])+", "09az AZ90", RegexOptions.None, new string[] { "az AZ", "Z" } }; yield return new object[] { engine, null, @"([0-9-[02468]]|[0-9-[13579]])+", "az1234567890za", RegexOptions.None, new string[] { "1234567890", "0" } }; yield return new object[] { engine, null, @"([^0-9-[a-zAE-Z]]|[\w-[a-zAF-Z]])+", "azBCDE1234567890BCDEFza", RegexOptions.None, new string[] { "BCDE1234567890BCDE", "E" } }; yield return new object[] { engine, null, @"([\p{Ll}-[aeiou]]|[^\w-[\s]])+", "aeiobcdxyz!@#aeio", RegexOptions.None, new string[] { "bcdxyz!@#", "#" } }; yield return new object[] { engine, null, @"(?:hello|hi){1,3}", "hello", RegexOptions.None, new string[] { "hello" } }; yield return new object[] { engine, null, @"(hello|hi){1,3}", "hellohihey", RegexOptions.None, new string[] { "hellohi", "hi" } }; yield return new object[] { engine, null, @"(?:hello|hi){1,3}", "hellohihey", RegexOptions.None, new string[] { "hellohi" } }; yield return new object[] { engine, null, @"(?:hello|hi){2,2}", "hellohihey", RegexOptions.None, new string[] { "hellohi" } }; yield return new object[] { engine, null, @"(?:hello|hi){2,2}?", "hellohihihello", RegexOptions.None, new string[] { "hellohi" } }; yield return new object[] { engine, null, @"(?:abc|def|ghi|hij|klm|no){1,4}", "this is a test nonoabcxyz this is only a test", RegexOptions.None, new string[] { "nonoabc" } }; yield return new object[] { engine, null, @"xyz(abc|def)xyz", "abcxyzdefxyzabc", RegexOptions.None, new string[] { "xyzdefxyz", "def" } }; yield return new object[] { engine, null, @"abc|(?:def|ghi)", "ghi", RegexOptions.None, new string[] { "ghi" } }; yield return new object[] { engine, null, @"abc|(def|ghi)", "def", RegexOptions.None, new string[] { "def", "def" } }; // Multiple character classes using character class subtraction yield return new object[] { engine, null, @"98[\d-[9]][\d-[8]][\d-[0]]", "98911 98881 98870 98871", RegexOptions.None, new string[] { "98871" } }; yield return new object[] { engine, null, @"m[\w-[^aeiou]][\w-[^aeiou]]t", "mbbt mect meet", RegexOptions.None, new string[] { "meet" } }; // Negation with character class subtraction yield return new object[] { engine, null, "[abcdef-[^bce]]+", "adfbcefda", RegexOptions.None, new string[] { "bce" } }; yield return new object[] { engine, null, "[^cde-[ag]]+", "agbfxyzga", RegexOptions.None, new string[] { "bfxyz" } }; // Misc The idea here is come up with real world examples of char class subtraction. Things that // would be difficult to define without it yield return new object[] { engine, null, @"[\p{L}-[^\p{Lu}]]+", "09',.abcxyzABCXYZ", RegexOptions.None, new string[] { "ABCXYZ" } }; yield return new object[] { engine, null, @"[\p{IsGreek}-[\P{Lu}]]+", "\u0390\u03FE\u0386\u0388\u03EC\u03EE\u0400", RegexOptions.None, new string[] { "\u03FE\u0386\u0388\u03EC\u03EE" } }; yield return new object[] { engine, null, @"[\p{IsBasicLatin}-[G-L]]+", "GAFMZL", RegexOptions.None, new string[] { "AFMZ" } }; yield return new object[] { engine, null, "[a-zA-Z-[aeiouAEIOU]]+", "aeiouAEIOUbcdfghjklmnpqrstvwxyz", RegexOptions.None, new string[] { "bcdfghjklmnpqrstvwxyz" } }; // The following is an overly complex way of matching an ip address using char class subtraction yield return new object[] { engine, null, @"^ (?<octet>^ ( ( (?<Octet2xx>[\d-[013-9]]) | [\d-[2-9]] ) (?(Octet2xx) ( (?<Octet25x>[\d-[01-46-9]]) | [\d-[5-9]] ) ( (?(Octet25x) [\d-[6-9]] | [\d] ) ) | [\d]{2} ) ) | ([\d][\d]) | [\d] )$" , "255", RegexOptions.IgnorePatternWhitespace, new string[] { "255", "255", "2", "5", "5", "", "255", "2", "5" } }; // Character Class Substraction yield return new object[] { engine, null, @"[abcd\-d-[bc]]+", "bbbaaa---dddccc", RegexOptions.None, new string[] { "aaa---ddd" } }; yield return new object[] { engine, null, @"[^a-f-[\x00-\x60\u007B-\uFFFF]]+", "aaafffgggzzz{{{", RegexOptions.None, new string[] { "gggzzz" } }; yield return new object[] { engine, null, @"[\[\]a-f-[[]]+", "gggaaafff]]][[[", RegexOptions.None, new string[] { "aaafff]]]" } }; yield return new object[] { engine, null, @"[\[\]a-f-[]]]+", "gggaaafff[[[]]]", RegexOptions.None, new string[] { "aaafff[[[" } }; yield return new object[] { engine, null, @"[ab\-\[cd-[-[]]]]", "a]]", RegexOptions.None, new string[] { "a]]" } }; yield return new object[] { engine, null, @"[ab\-\[cd-[-[]]]]", "b]]", RegexOptions.None, new string[] { "b]]" } }; yield return new object[] { engine, null, @"[ab\-\[cd-[-[]]]]", "c]]", RegexOptions.None, new string[] { "c]]" } }; yield return new object[] { engine, null, @"[ab\-\[cd-[-[]]]]", "d]]", RegexOptions.None, new string[] { "d]]" } }; yield return new object[] { engine, null, @"[ab\-\[cd-[[]]]]", "a]]", RegexOptions.None, new string[] { "a]]" } }; yield return new object[] { engine, null, @"[ab\-\[cd-[[]]]]", "b]]", RegexOptions.None, new string[] { "b]]" } }; yield return new object[] { engine, null, @"[ab\-\[cd-[[]]]]", "c]]", RegexOptions.None, new string[] { "c]]" } }; yield return new object[] { engine, null, @"[ab\-\[cd-[[]]]]", "d]]", RegexOptions.None, new string[] { "d]]" } }; yield return new object[] { engine, null, @"[ab\-\[cd-[[]]]]", "-]]", RegexOptions.None, new string[] { "-]]" } }; yield return new object[] { engine, null, @"[a-[c-e]]+", "bbbaaaccc", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"[a-[c-e]]+", "```aaaccc", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"[a-d\--[bc]]+", "cccaaa--dddbbb", RegexOptions.None, new string[] { "aaa--ddd" } }; // Not Character class substraction yield return new object[] { engine, null, @"[\0- [bc]+", "!!!\0\0\t\t [[[[bbbcccaaa", RegexOptions.None, new string[] { "\0\0\t\t [[[[bbbccc" } }; yield return new object[] { engine, null, "[[abcd]-[bc]]+", "a-b]", RegexOptions.None, new string[] { "a-b]" } }; yield return new object[] { engine, null, "[-[e-g]+", "ddd[[[---eeefffggghhh", RegexOptions.None, new string[] { "[[[---eeefffggg" } }; yield return new object[] { engine, null, "[-e-g]+", "ddd---eeefffggghhh", RegexOptions.None, new string[] { "---eeefffggg" } }; yield return new object[] { engine, null, "[a-e - m-p]+", "---a b c d e m n o p---", RegexOptions.None, new string[] { "a b c d e m n o p" } }; yield return new object[] { engine, null, "[^-[bc]]", "b] c] -] aaaddd]", RegexOptions.None, new string[] { "d]" } }; yield return new object[] { engine, null, "[^-[bc]]", "b] c] -] aaa]ddd]", RegexOptions.None, new string[] { "a]" } }; // Make sure we correctly handle \- yield return new object[] { engine, null, @"[a\-[bc]+", "```bbbaaa---[[[cccddd", RegexOptions.None, new string[] { "bbbaaa---[[[ccc" } }; yield return new object[] { engine, null, @"[a\-[\-\-bc]+", "```bbbaaa---[[[cccddd", RegexOptions.None, new string[] { "bbbaaa---[[[ccc" } }; yield return new object[] { engine, null, @"[a\-\[\-\[\-bc]+", "```bbbaaa---[[[cccddd", RegexOptions.None, new string[] { "bbbaaa---[[[ccc" } }; yield return new object[] { engine, null, @"[abc\--[b]]+", "[[[```bbbaaa---cccddd", RegexOptions.None, new string[] { "aaa---ccc" } }; yield return new object[] { engine, null, @"[abc\-z-[b]]+", "```aaaccc---zzzbbb", RegexOptions.None, new string[] { "aaaccc---zzz" } }; yield return new object[] { engine, null, @"[a-d\-[b]+", "```aaabbbcccddd----[[[[]]]", RegexOptions.None, new string[] { "aaabbbcccddd----[[[[" } }; yield return new object[] { engine, null, @"[abcd\-d\-[bc]+", "bbbaaa---[[[dddccc", RegexOptions.None, new string[] { "bbbaaa---[[[dddccc" } }; // Everything works correctly with option RegexOptions.IgnorePatternWhitespace yield return new object[] { engine, null, "[a - c - [ b ] ]+", "dddaaa ccc [[[[ bbb ]]]", RegexOptions.IgnorePatternWhitespace, new string[] { " ]]]" } }; yield return new object[] { engine, null, "[a - c - [ b ] +", "dddaaa ccc [[[[ bbb ]]]", RegexOptions.IgnorePatternWhitespace, new string[] { "aaa ccc [[[[ bbb " } }; // Unicode Char Classes yield return new object[] { engine, null, @"(\p{Lu}\w*)\s(\p{Lu}\w*)", "Hello World", RegexOptions.None, new string[] { "Hello World", "Hello", "World" } }; yield return new object[] { engine, null, @"(\p{Lu}\p{Ll}*)\s(\p{Lu}\p{Ll}*)", "Hello World", RegexOptions.None, new string[] { "Hello World", "Hello", "World" } }; yield return new object[] { engine, null, @"(\P{Ll}\p{Ll}*)\s(\P{Ll}\p{Ll}*)", "Hello World", RegexOptions.None, new string[] { "Hello World", "Hello", "World" } }; yield return new object[] { engine, null, @"(\P{Lu}+\p{Lu})\s(\P{Lu}+\p{Lu})", "hellO worlD", RegexOptions.None, new string[] { "hellO worlD", "hellO", "worlD" } }; yield return new object[] { engine, null, @"(\p{Lt}\w*)\s(\p{Lt}*\w*)", "\u01C5ello \u01C5orld", RegexOptions.None, new string[] { "\u01C5ello \u01C5orld", "\u01C5ello", "\u01C5orld" } }; yield return new object[] { engine, null, @"(\P{Lt}\w*)\s(\P{Lt}*\w*)", "Hello World", RegexOptions.None, new string[] { "Hello World", "Hello", "World" } }; // Character ranges IgnoreCase yield return new object[] { engine, null, @"[@-D]+", "eE?@ABCDabcdeE", RegexOptions.IgnoreCase, new string[] { "@ABCDabcd" } }; yield return new object[] { engine, null, @"[>-D]+", "eE=>?@ABCDabcdeE", RegexOptions.IgnoreCase, new string[] { ">?@ABCDabcd" } }; yield return new object[] { engine, null, @"[\u0554-\u0557]+", "\u0583\u0553\u0554\u0555\u0556\u0584\u0585\u0586\u0557\u0558", RegexOptions.IgnoreCase, new string[] { "\u0554\u0555\u0556\u0584\u0585\u0586\u0557" } }; yield return new object[] { engine, null, @"[X-\]]+", "wWXYZxyz[\\]^", RegexOptions.IgnoreCase, new string[] { "XYZxyz[\\]" } }; yield return new object[] { engine, null, @"[X-\u0533]+", "\u0551\u0554\u0560AXYZaxyz\u0531\u0532\u0533\u0561\u0562\u0563\u0564", RegexOptions.IgnoreCase, new string[] { "AXYZaxyz\u0531\u0532\u0533\u0561\u0562\u0563" } }; yield return new object[] { engine, null, @"[X-a]+", "wWAXYZaxyz", RegexOptions.IgnoreCase, new string[] { "AXYZaxyz" } }; yield return new object[] { engine, null, @"[X-c]+", "wWABCXYZabcxyz", RegexOptions.IgnoreCase, new string[] { "ABCXYZabcxyz" } }; yield return new object[] { engine, null, @"[X-\u00C0]+", "\u00C1\u00E1\u00C0\u00E0wWABCXYZabcxyz", RegexOptions.IgnoreCase, new string[] { "\u00C0\u00E0wWABCXYZabcxyz" } }; yield return new object[] { engine, null, @"[\u0100\u0102\u0104]+", "\u00FF \u0100\u0102\u0104\u0101\u0103\u0105\u0106", RegexOptions.IgnoreCase, new string[] { "\u0100\u0102\u0104\u0101\u0103\u0105" } }; yield return new object[] { engine, null, @"[B-D\u0130]+", "aAeE\u0129\u0131\u0068 BCDbcD\u0130\u0069\u0070", RegexOptions.IgnoreCase, new string[] { "BCDbcD\u0130\u0069" } }; yield return new object[] { engine, null, @"[\u013B\u013D\u013F]+", "\u013A\u013B\u013D\u013F\u013C\u013E\u0140\u0141", RegexOptions.IgnoreCase, new string[] { "\u013B\u013D\u013F\u013C\u013E\u0140" } }; // Escape Chars yield return new object[] { engine, null, "(Cat)\r(Dog)", "Cat\rDog", RegexOptions.None, new string[] { "Cat\rDog", "Cat", "Dog" } }; yield return new object[] { engine, null, "(Cat)\t(Dog)", "Cat\tDog", RegexOptions.None, new string[] { "Cat\tDog", "Cat", "Dog" } }; yield return new object[] { engine, null, "(Cat)\f(Dog)", "Cat\fDog", RegexOptions.None, new string[] { "Cat\fDog", "Cat", "Dog" } }; // Miscellaneous { witout matching } yield return new object[] { engine, null, @"{5", "hello {5 world", RegexOptions.None, new string[] { "{5" } }; yield return new object[] { engine, null, @"{5,", "hello {5, world", RegexOptions.None, new string[] { "{5," } }; yield return new object[] { engine, null, @"{5,6", "hello {5,6 world", RegexOptions.None, new string[] { "{5,6" } }; // Miscellaneous inline options yield return new object[] { engine, null, @"(?n:(?<cat>cat)(\s+)(?<dog>dog))", "cat dog", RegexOptions.None, new string[] { "cat dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(?n:(cat)(\s+)(dog))", "cat dog", RegexOptions.None, new string[] { "cat dog" } }; yield return new object[] { engine, null, @"(?n:(cat)(?<SpaceChars>\s+)(dog))", "cat dog", RegexOptions.None, new string[] { "cat dog", " " } }; yield return new object[] { engine, null, @"(?x: (?<cat>cat) # Cat statement (\s+) # Whitespace chars (?<dog>dog # Dog statement ))", "cat dog", RegexOptions.None, new string[] { "cat dog", " ", "cat", "dog" } }; yield return new object[] { engine, null, @"(?+i:cat)", "CAT", RegexOptions.None, new string[] { "CAT" } }; // \d, \D, \s, \S, \w, \W, \P, \p inside character range yield return new object[] { engine, null, @"cat([\d]*)dog", "hello123cat230927dog1412d", RegexOptions.None, new string[] { "cat230927dog", "230927" } }; yield return new object[] { engine, null, @"([\D]*)dog", "65498catdog58719", RegexOptions.None, new string[] { "catdog", "cat" } }; yield return new object[] { engine, null, @"cat([\s]*)dog", "wiocat dog3270", RegexOptions.None, new string[] { "cat dog", " " } }; yield return new object[] { engine, null, @"cat([\S]*)", "sfdcatdog 3270", RegexOptions.None, new string[] { "catdog", "dog" } }; yield return new object[] { engine, null, @"cat([\w]*)", "sfdcatdog 3270", RegexOptions.None, new string[] { "catdog", "dog" } }; yield return new object[] { engine, null, @"cat([\W]*)dog", "wiocat dog3270", RegexOptions.None, new string[] { "cat dog", " " } }; yield return new object[] { engine, null, @"([\p{Lu}]\w*)\s([\p{Lu}]\w*)", "Hello World", RegexOptions.None, new string[] { "Hello World", "Hello", "World" } }; yield return new object[] { engine, null, @"([\P{Ll}][\p{Ll}]*)\s([\P{Ll}][\p{Ll}]*)", "Hello World", RegexOptions.None, new string[] { "Hello World", "Hello", "World" } }; // \x, \u, \a, \b, \e, \f, \n, \r, \t, \v, \c, inside character range yield return new object[] { engine, null, @"(cat)([\x41]*)(dog)", "catAAAdog", RegexOptions.None, new string[] { "catAAAdog", "cat", "AAA", "dog" } }; yield return new object[] { engine, null, @"(cat)([\u0041]*)(dog)", "catAAAdog", RegexOptions.None, new string[] { "catAAAdog", "cat", "AAA", "dog" } }; yield return new object[] { engine, null, @"(cat)([\a]*)(dog)", "cat\a\a\adog", RegexOptions.None, new string[] { "cat\a\a\adog", "cat", "\a\a\a", "dog" } }; yield return new object[] { engine, null, @"(cat)([\b]*)(dog)", "cat\b\b\bdog", RegexOptions.None, new string[] { "cat\b\b\bdog", "cat", "\b\b\b", "dog" } }; yield return new object[] { engine, null, @"(cat)([\e]*)(dog)", "cat\u001B\u001B\u001Bdog", RegexOptions.None, new string[] { "cat\u001B\u001B\u001Bdog", "cat", "\u001B\u001B\u001B", "dog" } }; yield return new object[] { engine, null, @"(cat)([\f]*)(dog)", "cat\f\f\fdog", RegexOptions.None, new string[] { "cat\f\f\fdog", "cat", "\f\f\f", "dog" } }; yield return new object[] { engine, null, @"(cat)([\r]*)(dog)", "cat\r\r\rdog", RegexOptions.None, new string[] { "cat\r\r\rdog", "cat", "\r\r\r", "dog" } }; yield return new object[] { engine, null, @"(cat)([\v]*)(dog)", "cat\v\v\vdog", RegexOptions.None, new string[] { "cat\v\v\vdog", "cat", "\v\v\v", "dog" } }; // \d, \D, \s, \S, \w, \W, \P, \p inside character range ([0-5]) with ECMA Option yield return new object[] { engine, null, @"cat([\d]*)dog", "hello123cat230927dog1412d", RegexOptions.ECMAScript, new string[] { "cat230927dog", "230927" } }; yield return new object[] { engine, null, @"([\D]*)dog", "65498catdog58719", RegexOptions.ECMAScript, new string[] { "catdog", "cat" } }; yield return new object[] { engine, null, @"cat([\s]*)dog", "wiocat dog3270", RegexOptions.ECMAScript, new string[] { "cat dog", " " } }; yield return new object[] { engine, null, @"cat([\S]*)", "sfdcatdog 3270", RegexOptions.ECMAScript, new string[] { "catdog", "dog" } }; yield return new object[] { engine, null, @"cat([\w]*)", "sfdcatdog 3270", RegexOptions.ECMAScript, new string[] { "catdog", "dog" } }; yield return new object[] { engine, null, @"cat([\W]*)dog", "wiocat dog3270", RegexOptions.ECMAScript, new string[] { "cat dog", " " } }; yield return new object[] { engine, null, @"([\p{Lu}]\w*)\s([\p{Lu}]\w*)", "Hello World", RegexOptions.ECMAScript, new string[] { "Hello World", "Hello", "World" } }; yield return new object[] { engine, null, @"([\P{Ll}][\p{Ll}]*)\s([\P{Ll}][\p{Ll}]*)", "Hello World", RegexOptions.ECMAScript, new string[] { "Hello World", "Hello", "World" } }; // \d, \D, \s, \S, \w, \W, \P, \p outside character range ([0-5]) with ECMA Option yield return new object[] { engine, null, @"(cat)\d*dog", "hello123cat230927dog1412d", RegexOptions.ECMAScript, new string[] { "cat230927dog", "cat" } }; yield return new object[] { engine, null, @"\D*(dog)", "65498catdog58719", RegexOptions.ECMAScript, new string[] { "catdog", "dog" } }; yield return new object[] { engine, null, @"(cat)\s*(dog)", "wiocat dog3270", RegexOptions.ECMAScript, new string[] { "cat dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(cat)\S*", "sfdcatdog 3270", RegexOptions.ECMAScript, new string[] { "catdog", "cat" } }; yield return new object[] { engine, null, @"(cat)\w*", "sfdcatdog 3270", RegexOptions.ECMAScript, new string[] { "catdog", "cat" } }; yield return new object[] { engine, null, @"(cat)\W*(dog)", "wiocat dog3270", RegexOptions.ECMAScript, new string[] { "cat dog", "cat", "dog" } }; yield return new object[] { engine, null, @"\p{Lu}(\w*)\s\p{Lu}(\w*)", "Hello World", RegexOptions.ECMAScript, new string[] { "Hello World", "ello", "orld" } }; yield return new object[] { engine, null, @"\P{Ll}\p{Ll}*\s\P{Ll}\p{Ll}*", "Hello World", RegexOptions.ECMAScript, new string[] { "Hello World" } }; // Use < in a group yield return new object[] { engine, null, @"cat(?<dog121>dog)", "catcatdogdogcat", RegexOptions.None, new string[] { "catdog", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s*(?<cat>dog)", "catcat dogdogcat", RegexOptions.None, new string[] { "cat dog", "dog" } }; yield return new object[] { engine, null, @"(?<1>cat)\s*(?<1>dog)", "catcat dogdogcat", RegexOptions.None, new string[] { "cat dog", "dog" } }; yield return new object[] { engine, null, @"(?<2048>cat)\s*(?<2048>dog)", "catcat dogdogcat", RegexOptions.None, new string[] { "cat dog", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\w+(?<dog-cat>dog)", "cat_Hello_World_dog", RegexOptions.None, new string[] { "cat_Hello_World_dog", "", "_Hello_World_" } }; yield return new object[] { engine, null, @"(?<cat>cat)\w+(?<-cat>dog)", "cat_Hello_World_dog", RegexOptions.None, new string[] { "cat_Hello_World_dog", "" } }; yield return new object[] { engine, null, @"(?<cat>cat)\w+(?<cat-cat>dog)", "cat_Hello_World_dog", RegexOptions.None, new string[] { "cat_Hello_World_dog", "_Hello_World_" } }; yield return new object[] { engine, null, @"(?<1>cat)\w+(?<dog-1>dog)", "cat_Hello_World_dog", RegexOptions.None, new string[] { "cat_Hello_World_dog", "", "_Hello_World_" } }; yield return new object[] { engine, null, @"(?<cat>cat)\w+(?<2-cat>dog)", "cat_Hello_World_dog", RegexOptions.None, new string[] { "cat_Hello_World_dog", "", "_Hello_World_" } }; yield return new object[] { engine, null, @"(?<1>cat)\w+(?<2-1>dog)", "cat_Hello_World_dog", RegexOptions.None, new string[] { "cat_Hello_World_dog", "", "_Hello_World_" } }; // Quantifiers yield return new object[] { engine, null, @"(?<cat>cat){", "STARTcat{", RegexOptions.None, new string[] { "cat{", "cat" } }; yield return new object[] { engine, null, @"(?<cat>cat){fdsa", "STARTcat{fdsa", RegexOptions.None, new string[] { "cat{fdsa", "cat" } }; yield return new object[] { engine, null, @"(?<cat>cat){1", "STARTcat{1", RegexOptions.None, new string[] { "cat{1", "cat" } }; yield return new object[] { engine, null, @"(?<cat>cat){1END", "STARTcat{1END", RegexOptions.None, new string[] { "cat{1END", "cat" } }; yield return new object[] { engine, null, @"(?<cat>cat){1,", "STARTcat{1,", RegexOptions.None, new string[] { "cat{1,", "cat" } }; yield return new object[] { engine, null, @"(?<cat>cat){1,END", "STARTcat{1,END", RegexOptions.None, new string[] { "cat{1,END", "cat" } }; yield return new object[] { engine, null, @"(?<cat>cat){1,2", "STARTcat{1,2", RegexOptions.None, new string[] { "cat{1,2", "cat" } }; yield return new object[] { engine, null, @"(?<cat>cat){1,2END", "STARTcat{1,2END", RegexOptions.None, new string[] { "cat{1,2END", "cat" } }; // Use IgnorePatternWhitespace yield return new object[] { engine, null, @"(cat) #cat \s+ #followed by 1 or more whitespace (dog) #followed by dog ", "cat dog", RegexOptions.IgnorePatternWhitespace, new string[] { "cat dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(cat) #cat \s+ #followed by 1 or more whitespace (dog) #followed by dog", "cat dog", RegexOptions.IgnorePatternWhitespace, new string[] { "cat dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(cat) (?#cat) \s+ (?#followed by 1 or more whitespace) (dog) (?#followed by dog)", "cat dog", RegexOptions.IgnorePatternWhitespace, new string[] { "cat dog", "cat", "dog" } }; // Back Reference yield return new object[] { engine, null, @"(?<cat>cat)(?<dog>dog)\k<cat>", "asdfcatdogcatdog", RegexOptions.None, new string[] { "catdogcat", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\k<cat>", "asdfcat dogcat dog", RegexOptions.None, new string[] { "cat dogcat", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\k'cat'", "asdfcat dogcat dog", RegexOptions.None, new string[] { "cat dogcat", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\<cat>", "asdfcat dogcat dog", RegexOptions.None, new string[] { "cat dogcat", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\'cat'", "asdfcat dogcat dog", RegexOptions.None, new string[] { "cat dogcat", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\k<1>", "asdfcat dogcat dog", RegexOptions.None, new string[] { "cat dogcat", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\k'1'", "asdfcat dogcat dog", RegexOptions.None, new string[] { "cat dogcat", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\<1>", "asdfcat dogcat dog", RegexOptions.None, new string[] { "cat dogcat", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\'1'", "asdfcat dogcat dog", RegexOptions.None, new string[] { "cat dogcat", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\1", "asdfcat dogcat dog", RegexOptions.None, new string[] { "cat dogcat", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\1", "asdfcat dogcat dog", RegexOptions.ECMAScript, new string[] { "cat dogcat", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\k<dog>", "asdfcat dogdog dog", RegexOptions.None, new string[] { "cat dogdog", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\2", "asdfcat dogdog dog", RegexOptions.None, new string[] { "cat dogdog", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\2", "asdfcat dogdog dog", RegexOptions.ECMAScript, new string[] { "cat dogdog", "cat", "dog" } }; // Octal yield return new object[] { engine, null, @"(cat)(\077)", "hellocat?dogworld", RegexOptions.None, new string[] { "cat?", "cat", "?" } }; yield return new object[] { engine, null, @"(cat)(\77)", "hellocat?dogworld", RegexOptions.None, new string[] { "cat?", "cat", "?" } }; yield return new object[] { engine, null, @"(cat)(\176)", "hellocat~dogworld", RegexOptions.None, new string[] { "cat~", "cat", "~" } }; yield return new object[] { engine, null, @"(cat)(\400)", "hellocat\0dogworld", RegexOptions.None, new string[] { "cat\0", "cat", "\0" } }; yield return new object[] { engine, null, @"(cat)(\300)", "hellocat\u00C0dogworld", RegexOptions.None, new string[] { "cat\u00C0", "cat", "\u00C0" } }; yield return new object[] { engine, null, @"(cat)(\477)", "hellocat\u003Fdogworld", RegexOptions.None, new string[] { "cat\u003F", "cat", "\u003F" } }; yield return new object[] { engine, null, @"(cat)(\777)", "hellocat\u00FFdogworld", RegexOptions.None, new string[] { "cat\u00FF", "cat", "\u00FF" } }; yield return new object[] { engine, null, @"(cat)(\7770)", "hellocat\u00FF0dogworld", RegexOptions.None, new string[] { "cat\u00FF0", "cat", "\u00FF0" } }; yield return new object[] { engine, null, @"(cat)(\077)", "hellocat?dogworld", RegexOptions.ECMAScript, new string[] { "cat?", "cat", "?" } }; yield return new object[] { engine, null, @"(cat)(\77)", "hellocat?dogworld", RegexOptions.ECMAScript, new string[] { "cat?", "cat", "?" } }; yield return new object[] { engine, null, @"(cat)(\7)", "hellocat\adogworld", RegexOptions.ECMAScript, new string[] { "cat\a", "cat", "\a" } }; yield return new object[] { engine, null, @"(cat)(\40)", "hellocat dogworld", RegexOptions.ECMAScript, new string[] { "cat ", "cat", " " } }; yield return new object[] { engine, null, @"(cat)(\040)", "hellocat dogworld", RegexOptions.ECMAScript, new string[] { "cat ", "cat", " " } }; yield return new object[] { engine, null, @"(cat)(\176)", "hellocatcat76dogworld", RegexOptions.ECMAScript, new string[] { "catcat76", "cat", "cat76" } }; yield return new object[] { engine, null, @"(cat)(\377)", "hellocat\u00FFdogworld", RegexOptions.ECMAScript, new string[] { "cat\u00FF", "cat", "\u00FF" } }; yield return new object[] { engine, null, @"(cat)(\400)", "hellocat 0Fdogworld", RegexOptions.ECMAScript, new string[] { "cat 0", "cat", " 0" } }; // Decimal yield return new object[] { engine, null, @"(cat)\s+(?<2147483646>dog)", "asdlkcat dogiwod", RegexOptions.None, new string[] { "cat dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(cat)\s+(?<2147483647>dog)", "asdlkcat dogiwod", RegexOptions.None, new string[] { "cat dog", "cat", "dog" } }; // Hex yield return new object[] { engine, null, @"(cat)(\x2a*)(dog)", "asdlkcat***dogiwod", RegexOptions.None, new string[] { "cat***dog", "cat", "***", "dog" } }; yield return new object[] { engine, null, @"(cat)(\x2b*)(dog)", "asdlkcat+++dogiwod", RegexOptions.None, new string[] { "cat+++dog", "cat", "+++", "dog" } }; yield return new object[] { engine, null, @"(cat)(\x2c*)(dog)", "asdlkcat,,,dogiwod", RegexOptions.None, new string[] { "cat,,,dog", "cat", ",,,", "dog" } }; yield return new object[] { engine, null, @"(cat)(\x2d*)(dog)", "asdlkcat---dogiwod", RegexOptions.None, new string[] { "cat---dog", "cat", "---", "dog" } }; yield return new object[] { engine, null, @"(cat)(\x2e*)(dog)", "asdlkcat...dogiwod", RegexOptions.None, new string[] { "cat...dog", "cat", "...", "dog" } }; yield return new object[] { engine, null, @"(cat)(\x2f*)(dog)", "asdlkcat///dogiwod", RegexOptions.None, new string[] { "cat///dog", "cat", "///", "dog" } }; yield return new object[] { engine, null, @"(cat)(\x2A*)(dog)", "asdlkcat***dogiwod", RegexOptions.None, new string[] { "cat***dog", "cat", "***", "dog" } }; yield return new object[] { engine, null, @"(cat)(\x2B*)(dog)", "asdlkcat+++dogiwod", RegexOptions.None, new string[] { "cat+++dog", "cat", "+++", "dog" } }; yield return new object[] { engine, null, @"(cat)(\x2C*)(dog)", "asdlkcat,,,dogiwod", RegexOptions.None, new string[] { "cat,,,dog", "cat", ",,,", "dog" } }; yield return new object[] { engine, null, @"(cat)(\x2D*)(dog)", "asdlkcat---dogiwod", RegexOptions.None, new string[] { "cat---dog", "cat", "---", "dog" } }; yield return new object[] { engine, null, @"(cat)(\x2E*)(dog)", "asdlkcat...dogiwod", RegexOptions.None, new string[] { "cat...dog", "cat", "...", "dog" } }; yield return new object[] { engine, null, @"(cat)(\x2F*)(dog)", "asdlkcat///dogiwod", RegexOptions.None, new string[] { "cat///dog", "cat", "///", "dog" } }; // ScanControl yield return new object[] { engine, null, @"(cat)(\c@*)(dog)", "asdlkcat\0\0dogiwod", RegexOptions.None, new string[] { "cat\0\0dog", "cat", "\0\0", "dog" } }; yield return new object[] { engine, null, @"(cat)(\cA*)(dog)", "asdlkcat\u0001dogiwod", RegexOptions.None, new string[] { "cat\u0001dog", "cat", "\u0001", "dog" } }; yield return new object[] { engine, null, @"(cat)(\ca*)(dog)", "asdlkcat\u0001dogiwod", RegexOptions.None, new string[] { "cat\u0001dog", "cat", "\u0001", "dog" } }; yield return new object[] { engine, null, @"(cat)(\cC*)(dog)", "asdlkcat\u0003dogiwod", RegexOptions.None, new string[] { "cat\u0003dog", "cat", "\u0003", "dog" } }; yield return new object[] { engine, null, @"(cat)(\cc*)(dog)", "asdlkcat\u0003dogiwod", RegexOptions.None, new string[] { "cat\u0003dog", "cat", "\u0003", "dog" } }; yield return new object[] { engine, null, @"(cat)(\cD*)(dog)", "asdlkcat\u0004dogiwod", RegexOptions.None, new string[] { "cat\u0004dog", "cat", "\u0004", "dog" } }; yield return new object[] { engine, null, @"(cat)(\cd*)(dog)", "asdlkcat\u0004dogiwod", RegexOptions.None, new string[] { "cat\u0004dog", "cat", "\u0004", "dog" } }; yield return new object[] { engine, null, @"(cat)(\cX*)(dog)", "asdlkcat\u0018dogiwod", RegexOptions.None, new string[] { "cat\u0018dog", "cat", "\u0018", "dog" } }; yield return new object[] { engine, null, @"(cat)(\cx*)(dog)", "asdlkcat\u0018dogiwod", RegexOptions.None, new string[] { "cat\u0018dog", "cat", "\u0018", "dog" } }; yield return new object[] { engine, null, @"(cat)(\cZ*)(dog)", "asdlkcat\u001adogiwod", RegexOptions.None, new string[] { "cat\u001adog", "cat", "\u001a", "dog" } }; yield return new object[] { engine, null, @"(cat)(\cz*)(dog)", "asdlkcat\u001adogiwod", RegexOptions.None, new string[] { "cat\u001adog", "cat", "\u001a", "dog" } }; if (!PlatformDetection.IsNetFramework) // missing fix for https://github.com/dotnet/runtime/issues/24759 { yield return new object[] { engine, null, @"(cat)(\c[*)(dog)", "asdlkcat\u001bdogiwod", RegexOptions.None, new string[] { "cat\u001bdog", "cat", "\u001b", "dog" } }; } // Atomic Zero-Width Assertions \A \G ^ \Z \z \b \B //\A yield return new object[] { engine, null, @"\Acat\s+dog", "cat \n\n\n dog", RegexOptions.None, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"\Acat\s+dog", "cat \n\n\n dog", RegexOptions.Multiline, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"\A(cat)\s+(dog)", "cat \n\n\n dog", RegexOptions.None, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"\A(cat)\s+(dog)", "cat \n\n\n dog", RegexOptions.Multiline, new string[] { "cat \n\n\n dog", "cat", "dog" } }; //\G yield return new object[] { engine, null, @"\Gcat\s+dog", "cat \n\n\n dog", RegexOptions.None, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"\Gcat\s+dog", "cat \n\n\n dog", RegexOptions.Multiline, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"\Gcat\s+dog", "cat \n\n\n dog", RegexOptions.ECMAScript, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"\G(cat)\s+(dog)", "cat \n\n\n dog", RegexOptions.None, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"\G(cat)\s+(dog)", "cat \n\n\n dog", RegexOptions.Multiline, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"\G(cat)\s+(dog)", "cat \n\n\n dog", RegexOptions.ECMAScript, new string[] { "cat \n\n\n dog", "cat", "dog" } }; //^ yield return new object[] { engine, null, @"^cat\s+dog", "cat \n\n\n dog", RegexOptions.None, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"^cat\s+dog", "cat \n\n\n dog", RegexOptions.Multiline, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"mouse\s\n^cat\s+dog", "mouse\n\ncat \n\n\n dog", RegexOptions.Multiline, new string[] { "mouse\n\ncat \n\n\n dog" } }; yield return new object[] { engine, null, @"^cat\s+dog", "cat \n\n\n dog", RegexOptions.ECMAScript, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"^(cat)\s+(dog)", "cat \n\n\n dog", RegexOptions.None, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"^(cat)\s+(dog)", "cat \n\n\n dog", RegexOptions.Multiline, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(mouse)\s\n^(cat)\s+(dog)", "mouse\n\ncat \n\n\n dog", RegexOptions.Multiline, new string[] { "mouse\n\ncat \n\n\n dog", "mouse", "cat", "dog" } }; yield return new object[] { engine, null, @"^(cat)\s+(dog)", "cat \n\n\n dog", RegexOptions.ECMAScript, new string[] { "cat \n\n\n dog", "cat", "dog" } }; //\Z yield return new object[] { engine, null, @"cat\s+dog\Z", "cat \n\n\n dog", RegexOptions.None, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"cat\s+dog\Z", "cat \n\n\n dog", RegexOptions.Multiline, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"cat\s+dog\Z", "cat \n\n\n dog", RegexOptions.ECMAScript, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"cat\s+dog\Z", "cat \n\n\n dog\n", RegexOptions.None, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"cat\s+dog\Z", "cat \n\n\n dog\n", RegexOptions.Multiline, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"cat\s+dog\Z", "cat \n\n\n dog\n", RegexOptions.ECMAScript, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"(cat)\s+(dog)\Z", "cat \n\n\n dog", RegexOptions.None, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(cat)\s+(dog)\Z", "cat \n\n\n dog", RegexOptions.Multiline, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(cat)\s+(dog)\Z", "cat \n\n\n dog", RegexOptions.ECMAScript, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(cat)\s+(dog)\Z", "cat \n\n\n dog\n", RegexOptions.None, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(cat)\s+(dog)\Z", "cat \n\n\n dog\n", RegexOptions.Multiline, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(cat)\s+(dog)\Z", "cat \n\n\n dog\n", RegexOptions.ECMAScript, new string[] { "cat \n\n\n dog", "cat", "dog" } }; //\z yield return new object[] { engine, null, @"cat\s+dog\z", "cat \n\n\n dog", RegexOptions.None, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"cat\s+dog\z", "cat \n\n\n dog", RegexOptions.Multiline, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"cat\s+dog\z", "cat \n\n\n dog", RegexOptions.ECMAScript, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"(cat)\s+(dog)\z", "cat \n\n\n dog", RegexOptions.None, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(cat)\s+(dog)\z", "cat \n\n\n dog", RegexOptions.Multiline, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(cat)\s+(dog)\z", "cat \n\n\n dog", RegexOptions.ECMAScript, new string[] { "cat \n\n\n dog", "cat", "dog" } }; //\b yield return new object[] { engine, null, @"\bcat\b", "cat", RegexOptions.None, new string[] { "cat" } }; yield return new object[] { engine, null, @"\bcat\b", "dog cat mouse", RegexOptions.None, new string[] { "cat" } }; yield return new object[] { engine, null, @"\bcat\b", "cat", RegexOptions.ECMAScript, new string[] { "cat" } }; yield return new object[] { engine, null, @"\bcat\b", "dog cat mouse", RegexOptions.ECMAScript, new string[] { "cat" } }; yield return new object[] { engine, null, @".*\bcat\b", "cat", RegexOptions.None, new string[] { "cat" } }; yield return new object[] { engine, null, @".*\bcat\b", "dog cat mouse", RegexOptions.None, new string[] { "dog cat" } }; yield return new object[] { engine, null, @".*\bcat\b", "cat", RegexOptions.ECMAScript, new string[] { "cat" } }; yield return new object[] { engine, null, @".*\bcat\b", "dog cat mouse", RegexOptions.ECMAScript, new string[] { "dog cat" } }; yield return new object[] { engine, null, @"\b@cat", "123START123@catEND", RegexOptions.None, new string[] { "@cat" } }; yield return new object[] { engine, null, @"\b\<cat", "123START123<catEND", RegexOptions.None, new string[] { "<cat" } }; yield return new object[] { engine, null, @"\b,cat", "satwe,,,START,catEND", RegexOptions.None, new string[] { ",cat" } }; yield return new object[] { engine, null, @"\b\[cat", "`12START123[catEND", RegexOptions.None, new string[] { "[cat" } }; //\B yield return new object[] { engine, null, @"\Bcat\B", "dogcatmouse", RegexOptions.None, new string[] { "cat" } }; yield return new object[] { engine, null, @"dog\Bcat\B", "dogcatmouse", RegexOptions.None, new string[] { "dogcat" } }; yield return new object[] { engine, null, @".*\Bcat\B", "dogcatmouse", RegexOptions.None, new string[] { "dogcat" } }; yield return new object[] { engine, null, @"\Bcat\B", "dogcatmouse", RegexOptions.ECMAScript, new string[] { "cat" } }; yield return new object[] { engine, null, @"dog\Bcat\B", "dogcatmouse", RegexOptions.ECMAScript, new string[] { "dogcat" } }; yield return new object[] { engine, null, @".*\Bcat\B", "dogcatmouse", RegexOptions.ECMAScript, new string[] { "dogcat" } }; yield return new object[] { engine, null, @"\B@cat", "123START123;@catEND", RegexOptions.None, new string[] { "@cat" } }; yield return new object[] { engine, null, @"\B\<cat", "123START123'<catEND", RegexOptions.None, new string[] { "<cat" } }; yield return new object[] { engine, null, @"\B,cat", "satwe,,,START',catEND", RegexOptions.None, new string[] { ",cat" } }; yield return new object[] { engine, null, @"\B\[cat", "`12START123'[catEND", RegexOptions.None, new string[] { "[cat" } }; // \w matching \p{Lm} (Letter, Modifier) yield return new object[] { engine, null, @"\w+\s+\w+", "cat\u02b0 dog\u02b1", RegexOptions.None, new string[] { "cat\u02b0 dog\u02b1" } }; yield return new object[] { engine, null, @"cat\w+\s+dog\w+", "STARTcat\u30FC dog\u3005END", RegexOptions.None, new string[] { "cat\u30FC dog\u3005END" } }; yield return new object[] { engine, null, @"cat\w+\s+dog\w+", "STARTcat\uff9e dog\uff9fEND", RegexOptions.None, new string[] { "cat\uff9e dog\uff9fEND" } }; yield return new object[] { engine, null, @"(\w+)\s+(\w+)", "cat\u02b0 dog\u02b1", RegexOptions.None, new string[] { "cat\u02b0 dog\u02b1", "cat\u02b0", "dog\u02b1" } }; yield return new object[] { engine, null, @"(cat\w+)\s+(dog\w+)", "STARTcat\u30FC dog\u3005END", RegexOptions.None, new string[] { "cat\u30FC dog\u3005END", "cat\u30FC", "dog\u3005END" } }; yield return new object[] { engine, null, @"(cat\w+)\s+(dog\w+)", "STARTcat\uff9e dog\uff9fEND", RegexOptions.None, new string[] { "cat\uff9e dog\uff9fEND", "cat\uff9e", "dog\uff9fEND" } }; // Positive and negative character classes [a-c]|[^b-c] yield return new object[] { engine, null, @"[^a]|d", "d", RegexOptions.None, new string[] { "d" } }; yield return new object[] { engine, null, @"([^a]|[d])*", "Hello Worlddf", RegexOptions.None, new string[] { "Hello Worlddf", "f" } }; yield return new object[] { engine, null, @"([^{}]|\n)+", "{{{{Hello\n World \n}END", RegexOptions.None, new string[] { "Hello\n World \n", "\n" } }; yield return new object[] { engine, null, @"([a-d]|[^abcd])+", "\tonce\n upon\0 a- ()*&^%#time?", RegexOptions.None, new string[] { "\tonce\n upon\0 a- ()*&^%#time?", "?" } }; yield return new object[] { engine, null, @"([^a]|[a])*", "once upon a time", RegexOptions.None, new string[] { "once upon a time", "e" } }; yield return new object[] { engine, null, @"([a-d]|[^abcd]|[x-z]|^wxyz])+", "\tonce\n upon\0 a- ()*&^%#time?", RegexOptions.None, new string[] { "\tonce\n upon\0 a- ()*&^%#time?", "?" } }; yield return new object[] { engine, null, @"([a-d]|[e-i]|[^e]|wxyz])+", "\tonce\n upon\0 a- ()*&^%#time?", RegexOptions.None, new string[] { "\tonce\n upon\0 a- ()*&^%#time?", "?" } }; // Canonical and noncanonical char class, where one group is in it's // simplest form [a-e] and another is more complex. yield return new object[] { engine, null, @"^(([^b]+ )|(.* ))$", "aaa ", RegexOptions.None, new string[] { "aaa ", "aaa ", "aaa ", "" } }; yield return new object[] { engine, null, @"^(([^b]+ )|(.*))$", "aaa", RegexOptions.None, new string[] { "aaa", "aaa", "", "aaa" } }; yield return new object[] { engine, null, @"^(([^b]+ )|(.* ))$", "bbb ", RegexOptions.None, new string[] { "bbb ", "bbb ", "", "bbb " } }; yield return new object[] { engine, null, @"^(([^b]+ )|(.*))$", "bbb", RegexOptions.None, new string[] { "bbb", "bbb", "", "bbb" } }; yield return new object[] { engine, null, @"^((a*)|(.*))$", "aaa", RegexOptions.None, new string[] { "aaa", "aaa", "aaa", "" } }; yield return new object[] { engine, null, @"^((a*)|(.*))$", "aaabbb", RegexOptions.None, new string[] { "aaabbb", "aaabbb", "", "aaabbb" } }; yield return new object[] { engine, null, @"(([0-9])|([a-z])|([A-Z]))*", "{hello 1234567890 world}", RegexOptions.None, new string[] { "", "", "", "", "" } }; yield return new object[] { engine, null, @"(([0-9])|([a-z])|([A-Z]))+", "{hello 1234567890 world}", RegexOptions.None, new string[] { "hello", "o", "", "o", "" } }; yield return new object[] { engine, null, @"(([0-9])|([a-z])|([A-Z]))*", "{HELLO 1234567890 world}", RegexOptions.None, new string[] { "", "", "", "", "" } }; yield return new object[] { engine, null, @"(([0-9])|([a-z])|([A-Z]))+", "{HELLO 1234567890 world}", RegexOptions.None, new string[] { "HELLO", "O", "", "", "O" } }; yield return new object[] { engine, null, @"(([0-9])|([a-z])|([A-Z]))*", "{1234567890 hello world}", RegexOptions.None, new string[] { "", "", "", "", "" } }; yield return new object[] { engine, null, @"(([0-9])|([a-z])|([A-Z]))+", "{1234567890 hello world}", RegexOptions.None, new string[] { "1234567890", "0", "0", "", "" } }; yield return new object[] { engine, null, @"^(([a-d]*)|([a-z]*))$", "aaabbbcccdddeeefff", RegexOptions.None, new string[] { "aaabbbcccdddeeefff", "aaabbbcccdddeeefff", "", "aaabbbcccdddeeefff" } }; yield return new object[] { engine, null, @"^(([d-f]*)|([c-e]*))$", "dddeeeccceee", RegexOptions.None, new string[] { "dddeeeccceee", "dddeeeccceee", "", "dddeeeccceee" } }; yield return new object[] { engine, null, @"^(([c-e]*)|([d-f]*))$", "dddeeeccceee", RegexOptions.None, new string[] { "dddeeeccceee", "dddeeeccceee", "dddeeeccceee", "" } }; yield return new object[] { engine, null, @"(([a-d]*)|([a-z]*))", "aaabbbcccdddeeefff", RegexOptions.None, new string[] { "aaabbbcccddd", "aaabbbcccddd", "aaabbbcccddd", "" } }; yield return new object[] { engine, null, @"(([d-f]*)|([c-e]*))", "dddeeeccceee", RegexOptions.None, new string[] { "dddeee", "dddeee", "dddeee", "" } }; yield return new object[] { engine, null, @"(([c-e]*)|([d-f]*))", "dddeeeccceee", RegexOptions.None, new string[] { "dddeeeccceee", "dddeeeccceee", "dddeeeccceee", "" } }; yield return new object[] { engine, null, @"(([a-d]*)|(.*))", "aaabbbcccdddeeefff", RegexOptions.None, new string[] { "aaabbbcccddd", "aaabbbcccddd", "aaabbbcccddd", "" } }; yield return new object[] { engine, null, @"(([d-f]*)|(.*))", "dddeeeccceee", RegexOptions.None, new string[] { "dddeee", "dddeee", "dddeee", "" } }; yield return new object[] { engine, null, @"(([c-e]*)|(.*))", "dddeeeccceee", RegexOptions.None, new string[] { "dddeeeccceee", "dddeeeccceee", "dddeeeccceee", "" } }; // \p{Pi} (Punctuation Initial quote) \p{Pf} (Punctuation Final quote) yield return new object[] { engine, null, @"\p{Pi}(\w*)\p{Pf}", "\u00ABCat\u00BB \u00BBDog\u00AB'", RegexOptions.None, new string[] { "\u00ABCat\u00BB", "Cat" } }; yield return new object[] { engine, null, @"\p{Pi}(\w*)\p{Pf}", "\u2018Cat\u2019 \u2019Dog\u2018'", RegexOptions.None, new string[] { "\u2018Cat\u2019", "Cat" } }; // ECMAScript yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\s+\123\s+\234", "asdfcat dog cat23 dog34eia", RegexOptions.ECMAScript, new string[] { "cat dog cat23 dog34", "cat", "dog" } }; // Balanced Matching yield return new object[] { engine, null, @"<div> (?> <div>(?<DEPTH>) | </div> (?<-DEPTH>) | .? )*? (?(DEPTH)(?!)) </div>", "<div>this is some <div>red</div> text</div></div></div>", RegexOptions.IgnorePatternWhitespace, new string[] { "<div>this is some <div>red</div> text</div>", "" } }; yield return new object[] { engine, null, @"( ((?'open'<+)[^<>]*)+ ((?'close-open'>+)[^<>]*)+ )+", "<01deep_01<02deep_01<03deep_01>><02deep_02><02deep_03<03deep_03>>>", RegexOptions.IgnorePatternWhitespace, new string[] { "<01deep_01<02deep_01<03deep_01>><02deep_02><02deep_03<03deep_03>>>", "<02deep_03<03deep_03>>>", "<03deep_03", ">>>", "<", "03deep_03" } }; yield return new object[] { engine, null, @"( (?<start><)? [^<>]? (?<end-start>>)? )*", "<01deep_01<02deep_01<03deep_01>><02deep_02><02deep_03<03deep_03>>>", RegexOptions.IgnorePatternWhitespace, new string[] { "<01deep_01<02deep_01<03deep_01>><02deep_02><02deep_03<03deep_03>>>", "", "", "01deep_01<02deep_01<03deep_01>><02deep_02><02deep_03<03deep_03>>" } }; yield return new object[] { engine, null, @"( (?<start><[^/<>]*>)? [^<>]? (?<end-start></[^/<>]*>)? )*", "<b><a>Cat</a></b>", RegexOptions.IgnorePatternWhitespace, new string[] { "<b><a>Cat</a></b>", "", "", "<a>Cat</a>" } }; yield return new object[] { engine, null, @"( (?<start><(?<TagName>[^/<>]*)>)? [^<>]? (?<end-start></\k<TagName>>)? )*", "<b>cat</b><a>dog</a>", RegexOptions.IgnorePatternWhitespace, new string[] { "<b>cat</b><a>dog</a>", "", "", "a", "dog" } }; // Balanced Matching With Backtracking yield return new object[] { engine, null, @"( (?<start><[^/<>]*>)? .? (?<end-start></[^/<>]*>)? )* (?(start)(?!)) ", "<b><a>Cat</a></b><<<<c>>>><<d><e<f>><g><<<>>>>", RegexOptions.IgnorePatternWhitespace, new string[] { "<b><a>Cat</a></b><<<<c>>>><<d><e<f>><g><<<>>>>", "", "", "<a>Cat" } }; // Character Classes and Lazy quantifier yield return new object[] { engine, null, @"([0-9]+?)([\w]+?)", "55488aheiaheiad", RegexOptions.ECMAScript, new string[] { "55", "5", "5" } }; yield return new object[] { engine, null, @"([0-9]+?)([a-z]+?)", "55488aheiaheiad", RegexOptions.ECMAScript, new string[] { "55488a", "55488", "a" } }; // Miscellaneous/Regression scenarios yield return new object[] { engine, null, @"(?<openingtag>1)(?<content>.*?)(?=2)", "1" + Environment.NewLine + "<Projecaa DefaultTargets=\"x\"/>" + Environment.NewLine + "2", RegexOptions.Singleline | RegexOptions.ExplicitCapture, new string[] { "1" + Environment.NewLine + "<Projecaa DefaultTargets=\"x\"/>" + Environment.NewLine, "1", Environment.NewLine + "<Projecaa DefaultTargets=\"x\"/>"+ Environment.NewLine } }; yield return new object[] { engine, null, @"\G<%#(?<code>.*?)?%>", @"<%# DataBinder.Eval(this, ""MyNumber"") %>", RegexOptions.Singleline, new string[] { @"<%# DataBinder.Eval(this, ""MyNumber"") %>", @" DataBinder.Eval(this, ""MyNumber"") " } }; // Nested Quantifiers yield return new object[] { engine, null, @"^[abcd]{0,0x10}*$", "a{0,0x10}}}", RegexOptions.None, new string[] { "a{0,0x10}}}" } }; // Lazy operator Backtracking yield return new object[] { engine, null, @"http://([a-zA-z0-9\-]*\.?)*?(:[0-9]*)??/", "http://www.msn.com/", RegexOptions.IgnoreCase, new string[] { "http://www.msn.com/", "com", string.Empty } }; yield return new object[] { engine, null, @"http://([a-zA-Z0-9\-]*\.?)*?/", @"http://www.google.com/", RegexOptions.IgnoreCase, new string[] { "http://www.google.com/", "com" } }; yield return new object[] { engine, null, @"([a-z]*?)([\w])", "cat", RegexOptions.IgnoreCase, new string[] { "c", string.Empty, "c" } }; yield return new object[] { engine, null, @"^([a-z]*?)([\w])$", "cat", RegexOptions.IgnoreCase, new string[] { "cat", "ca", "t" } }; // Backtracking yield return new object[] { engine, null, @"([a-z]*)([\w])", "cat", RegexOptions.IgnoreCase, new string[] { "cat", "ca", "t" } }; yield return new object[] { engine, null, @"^([a-z]*)([\w])$", "cat", RegexOptions.IgnoreCase, new string[] { "cat", "ca", "t" } }; // Backtracking with multiple (.*) groups -- important ASP.NET scenario yield return new object[] { engine, null, @"(.*)/(.*).aspx", "/.aspx", RegexOptions.None, new string[] { "/.aspx", string.Empty, string.Empty } }; yield return new object[] { engine, null, @"(.*)/(.*).aspx", "/homepage.aspx", RegexOptions.None, new string[] { "/homepage.aspx", string.Empty, "homepage" } }; yield return new object[] { engine, null, @"(.*)/(.*).aspx", "pages/.aspx", RegexOptions.None, new string[] { "pages/.aspx", "pages", string.Empty } }; yield return new object[] { engine, null, @"(.*)/(.*).aspx", "pages/homepage.aspx", RegexOptions.None, new string[] { "pages/homepage.aspx", "pages", "homepage" } }; yield return new object[] { engine, null, @"(.*)/(.*).aspx", "/pages/homepage.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx", "/pages", "homepage" } }; yield return new object[] { engine, null, @"(.*)/(.*).aspx", "/pages/homepage/index.aspx", RegexOptions.None, new string[] { "/pages/homepage/index.aspx", "/pages/homepage", "index" } }; yield return new object[] { engine, null, @"(.*)/(.*).aspx", "/pages/homepage.aspx/index.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx/index.aspx", "/pages/homepage.aspx", "index" } }; yield return new object[] { engine, null, @"(.*)/(.*)/(.*).aspx", "/pages/homepage.aspx/index.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx/index.aspx", "/pages", "homepage.aspx", "index" } }; // Backtracking with multiple (.+) groups yield return new object[] { engine, null, @"(.+)/(.+).aspx", "pages/homepage.aspx", RegexOptions.None, new string[] { "pages/homepage.aspx", "pages", "homepage" } }; yield return new object[] { engine, null, @"(.+)/(.+).aspx", "/pages/homepage.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx", "/pages", "homepage" } }; yield return new object[] { engine, null, @"(.+)/(.+).aspx", "/pages/homepage/index.aspx", RegexOptions.None, new string[] { "/pages/homepage/index.aspx", "/pages/homepage", "index" } }; yield return new object[] { engine, null, @"(.+)/(.+).aspx", "/pages/homepage.aspx/index.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx/index.aspx", "/pages/homepage.aspx", "index" } }; yield return new object[] { engine, null, @"(.+)/(.+)/(.+).aspx", "/pages/homepage.aspx/index.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx/index.aspx", "/pages", "homepage.aspx", "index" } }; // Backtracking with (.+) group followed by (.*) yield return new object[] { engine, null, @"(.+)/(.*).aspx", "pages/.aspx", RegexOptions.None, new string[] { "pages/.aspx", "pages", string.Empty } }; yield return new object[] { engine, null, @"(.+)/(.*).aspx", "pages/homepage.aspx", RegexOptions.None, new string[] { "pages/homepage.aspx", "pages", "homepage" } }; yield return new object[] { engine, null, @"(.+)/(.*).aspx", "/pages/homepage.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx", "/pages", "homepage" } }; yield return new object[] { engine, null, @"(.+)/(.*).aspx", "/pages/homepage/index.aspx", RegexOptions.None, new string[] { "/pages/homepage/index.aspx", "/pages/homepage", "index" } }; yield return new object[] { engine, null, @"(.+)/(.*).aspx", "/pages/homepage.aspx/index.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx/index.aspx", "/pages/homepage.aspx", "index" } }; yield return new object[] { engine, null, @"(.+)/(.*)/(.*).aspx", "/pages/homepage.aspx/index.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx/index.aspx", "/pages", "homepage.aspx", "index" } }; // Backtracking with (.*) group followed by (.+) yield return new object[] { engine, null, @"(.*)/(.+).aspx", "/homepage.aspx", RegexOptions.None, new string[] { "/homepage.aspx", string.Empty, "homepage" } }; yield return new object[] { engine, null, @"(.*)/(.+).aspx", "pages/homepage.aspx", RegexOptions.None, new string[] { "pages/homepage.aspx", "pages", "homepage" } }; yield return new object[] { engine, null, @"(.*)/(.+).aspx", "/pages/homepage.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx", "/pages", "homepage" } }; yield return new object[] { engine, null, @"(.*)/(.+).aspx", "/pages/homepage/index.aspx", RegexOptions.None, new string[] { "/pages/homepage/index.aspx", "/pages/homepage", "index" } }; yield return new object[] { engine, null, @"(.*)/(.+).aspx", "/pages/homepage.aspx/index.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx/index.aspx", "/pages/homepage.aspx", "index" } }; yield return new object[] { engine, null, @"(.*)/(.+)/(.+).aspx", "/pages/homepage.aspx/index.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx/index.aspx", "/pages", "homepage.aspx", "index" } }; // Captures inside varying constructs with backtracking needing to uncapture yield return new object[] { engine, null, @"a(bc)d|abc(e)", "abce", RegexOptions.None, new string[] { "abce", "", "e" } }; // alternation yield return new object[] { engine, null, @"((ab){2}cd)*", "ababcdababcdababc", RegexOptions.None, new string[] { "ababcdababcd", "ababcd", "ab" } }; // loop yield return new object[] { engine, null, @"(ab(?=(\w)\w))*a", "aba", RegexOptions.None, new string[] { "a", "", "" } }; // positive lookahead in a loop yield return new object[] { engine, null, @"(ab(?=(\w)\w))*a", "ababa", RegexOptions.None, new string[] { "aba", "ab", "a" } }; // positive lookahead in a loop yield return new object[] { engine, null, @"(ab(?=(\w)\w))*a", "abababa", RegexOptions.None, new string[] { "ababa", "ab", "a" } }; // positive lookahead in a loop yield return new object[] { engine, null, @"\w\w(?!(\d)\d)", "aa..", RegexOptions.None, new string[] { "aa", "" } }; // negative lookahead yield return new object[] { engine, null, @"\w\w(?!(\d)\d)", "aa.3", RegexOptions.None, new string[] { "aa", "" } }; // negative lookahead // Quantifiers yield return new object[] { engine, null, @"a*", "", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"a*", "a", RegexOptions.None, new string[] { "a" } }; yield return new object[] { engine, null, @"a*", "aa", RegexOptions.None, new string[] { "aa" } }; yield return new object[] { engine, null, @"a*", "aaa", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"a*?", "", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"a*?", "a", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"a*?", "aa", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"a+?", "aa", RegexOptions.None, new string[] { "a" } }; yield return new object[] { engine, null, @"a{1,", "a{1,", RegexOptions.None, new string[] { "a{1," } }; yield return new object[] { engine, null, @"a{1,3}", "aaaaa", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"a{1,3}?", "aaaaa", RegexOptions.None, new string[] { "a" } }; yield return new object[] { engine, null, @"a{2,2}", "aaaaa", RegexOptions.None, new string[] { "aa" } }; yield return new object[] { engine, null, @"a{2,2}?", "aaaaa", RegexOptions.None, new string[] { "aa" } }; yield return new object[] { engine, null, @".{1,3}", "bb\nba", RegexOptions.None, new string[] { "bb" } }; yield return new object[] { engine, null, @".{1,3}?", "bb\nba", RegexOptions.None, new string[] { "b" } }; yield return new object[] { engine, null, @".{2,2}", "bbb\nba", RegexOptions.None, new string[] { "bb" } }; yield return new object[] { engine, null, @".{2,2}?", "bbb\nba", RegexOptions.None, new string[] { "bb" } }; yield return new object[] { engine, null, @"[abc]{1,3}", "ccaba", RegexOptions.None, new string[] { "cca" } }; yield return new object[] { engine, null, @"[abc]{1,3}?", "ccaba", RegexOptions.None, new string[] { "c" } }; yield return new object[] { engine, null, @"[abc]{2,2}", "ccaba", RegexOptions.None, new string[] { "cc" } }; yield return new object[] { engine, null, @"[abc]{2,2}?", "ccaba", RegexOptions.None, new string[] { "cc" } }; yield return new object[] { engine, null, @"(?:[abc]def){1,3}xyz", "cdefxyz", RegexOptions.None, new string[] { "cdefxyz" } }; yield return new object[] { engine, null, @"(?:[abc]def){1,3}xyz", "adefbdefcdefxyz", RegexOptions.None, new string[] { "adefbdefcdefxyz" } }; yield return new object[] { engine, null, @"(?:[abc]def){1,3}?xyz", "cdefxyz", RegexOptions.None, new string[] { "cdefxyz" } }; yield return new object[] { engine, null, @"(?:[abc]def){1,3}?xyz", "adefbdefcdefxyz", RegexOptions.None, new string[] { "adefbdefcdefxyz" } }; yield return new object[] { engine, null, @"(?:[abc]def){2,2}xyz", "adefbdefcdefxyz", RegexOptions.None, new string[] { "bdefcdefxyz" } }; yield return new object[] { engine, null, @"(?:[abc]def){2,2}?xyz", "adefbdefcdefxyz", RegexOptions.None, new string[] { "bdefcdefxyz" } }; foreach (string prefix in new[] { "", "xyz" }) { yield return new object[] { engine, null, prefix + @"(?:[abc]def){1,3}", prefix + "cdef", RegexOptions.None, new string[] { prefix + "cdef" } }; yield return new object[] { engine, null, prefix + @"(?:[abc]def){1,3}", prefix + "cdefadefbdef", RegexOptions.None, new string[] { prefix + "cdefadefbdef" } }; yield return new object[] { engine, null, prefix + @"(?:[abc]def){1,3}", prefix + "cdefadefbdefadef", RegexOptions.None, new string[] { prefix + "cdefadefbdef" } }; yield return new object[] { engine, null, prefix + @"(?:[abc]def){1,3}?", prefix + "cdef", RegexOptions.None, new string[] { prefix + "cdef" } }; yield return new object[] { engine, null, prefix + @"(?:[abc]def){1,3}?", prefix + "cdefadefbdef", RegexOptions.None, new string[] { prefix + "cdef" } }; yield return new object[] { engine, null, prefix + @"(?:[abc]def){2,2}", prefix + "cdefadefbdefadef", RegexOptions.None, new string[] { prefix + "cdefadef" } }; yield return new object[] { engine, null, prefix + @"(?:[abc]def){2,2}?", prefix + "cdefadefbdefadef", RegexOptions.None, new string[] { prefix + "cdefadef" } }; } yield return new object[] { engine, null, @"(cat){", "cat{", RegexOptions.None, new string[] { "cat{", "cat" } }; yield return new object[] { engine, null, @"(cat){}", "cat{}", RegexOptions.None, new string[] { "cat{}", "cat" } }; yield return new object[] { engine, null, @"(cat){,", "cat{,", RegexOptions.None, new string[] { "cat{,", "cat" } }; yield return new object[] { engine, null, @"(cat){,}", "cat{,}", RegexOptions.None, new string[] { "cat{,}", "cat" } }; yield return new object[] { engine, null, @"(cat){cat}", "cat{cat}", RegexOptions.None, new string[] { "cat{cat}", "cat" } }; yield return new object[] { engine, null, @"(cat){cat,5}", "cat{cat,5}", RegexOptions.None, new string[] { "cat{cat,5}", "cat" } }; yield return new object[] { engine, null, @"(cat){5,dog}", "cat{5,dog}", RegexOptions.None, new string[] { "cat{5,dog}", "cat" } }; yield return new object[] { engine, null, @"(cat){cat,dog}", "cat{cat,dog}", RegexOptions.None, new string[] { "cat{cat,dog}", "cat" } }; yield return new object[] { engine, null, @"(cat){,}?", "cat{,}?", RegexOptions.None, new string[] { "cat{,}", "cat" } }; yield return new object[] { engine, null, @"(cat){cat}?", "cat{cat}?", RegexOptions.None, new string[] { "cat{cat}", "cat" } }; yield return new object[] { engine, null, @"(cat){cat,5}?", "cat{cat,5}?", RegexOptions.None, new string[] { "cat{cat,5}", "cat" } }; yield return new object[] { engine, null, @"(cat){5,dog}?", "cat{5,dog}?", RegexOptions.None, new string[] { "cat{5,dog}", "cat" } }; yield return new object[] { engine, null, @"(cat){cat,dog}?", "cat{cat,dog}?", RegexOptions.None, new string[] { "cat{cat,dog}", "cat" } }; // Atomic subexpressions // Implicitly upgrading (or not) oneloop to be atomic yield return new object[] { engine, null, @"a*b", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*b+", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*b+?", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*(?>b+)", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*[^a]", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*[^a]+", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*[^a]+?", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*(?>[^a]+)", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*bcd", "aaabcd", RegexOptions.None, new string[] { "aaabcd" } }; yield return new object[] { engine, null, @"a*[bcd]", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*[bcd]+", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*[bcd]+?", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*(?>[bcd]+)", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*[bcd]{1,3}", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*([bcd]ab|[bef]cd){1,3}", "aaababecdcac", RegexOptions.ExplicitCapture, new string[] { "aaababecd" } }; yield return new object[] { engine, null, @"a*([bcd]|[aef]){1,3}", "befb", RegexOptions.ExplicitCapture, new string[] { "bef" } }; // can't upgrade yield return new object[] { engine, null, @"a*$", "aaa", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"a*$", "aaa", RegexOptions.Multiline, new string[] { "aaa" } }; yield return new object[] { engine, null, @"a*\b", "aaa bbb", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"a*\b", "aaa bbb", RegexOptions.ECMAScript, new string[] { "aaa" } }; yield return new object[] { engine, null, @"@*\B", "@@@", RegexOptions.None, new string[] { "@@@" } }; yield return new object[] { engine, null, @"@*\B", "@@@", RegexOptions.ECMAScript, new string[] { "@@@" } }; yield return new object[] { engine, null, @"(?:abcd*|efgh)i", "efghi", RegexOptions.None, new string[] { "efghi" } }; yield return new object[] { engine, null, @"(?:abcd|efgh*)i", "efgi", RegexOptions.None, new string[] { "efgi" } }; yield return new object[] { engine, null, @"(?:abcd|efghj{2,}|j[klm]o+)i", "efghjjjjji", RegexOptions.None, new string[] { "efghjjjjji" } }; yield return new object[] { engine, null, @"(?:abcd|efghi{2,}|j[klm]o+)i", "efghiii", RegexOptions.None, new string[] { "efghiii" } }; yield return new object[] { engine, null, @"(?:abcd|efghi{2,}|j[klm]o+)i", "efghiiiiiiii", RegexOptions.None, new string[] { "efghiiiiiiii" } }; yield return new object[] { engine, null, @"a?ba?ba?ba?b", "abbabab", RegexOptions.None, new string[] { "abbabab" } }; yield return new object[] { engine, null, @"a?ba?ba?ba?b", "abBAbab", RegexOptions.IgnoreCase, new string[] { "abBAbab" } }; // Implicitly upgrading (or not) notoneloop to be atomic yield return new object[] { engine, null, @"[^b]*b", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[^b]*b+", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[^b]*b+?", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[^b]*(?>b+)", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[^b]*bac", "aaabac", RegexOptions.None, new string[] { "aaabac" } }; yield return new object[] { engine, null, @"[^b]*", "aaa", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"(?:abc[^b]*|efgh)i", "efghi", RegexOptions.None, new string[] { "efghi" } }; // can't upgrade yield return new object[] { engine, null, @"(?:abcd|efg[^b]*)b", "efgb", RegexOptions.None, new string[] { "efgb" } }; yield return new object[] { engine, null, @"(?:abcd|efg[^b]*)i", "efgi", RegexOptions.None, new string[] { "efgi" } }; // can't upgrade yield return new object[] { engine, null, @"[^a]?a[^a]?a[^a]?a[^a]?a", "baababa", RegexOptions.None, new string[] { "baababa" } }; yield return new object[] { engine, null, @"[^a]?a[^a]?a[^a]?a[^a]?a", "BAababa", RegexOptions.IgnoreCase, new string[] { "BAababa" } }; // Implicitly upgrading (or not) setloop to be atomic yield return new object[] { engine, null, @"[ac]*", "aaa", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"[ac]*b", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*b+", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*b+?", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*(?>b+)", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*[^a]", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*[^a]+", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*[^a]+?", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*(?>[^a]+)", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*bcd", "aaabcd", RegexOptions.None, new string[] { "aaabcd" } }; yield return new object[] { engine, null, @"[ac]*[bd]", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*[bd]+", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*[bd]+?", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*(?>[bd]+)", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*[bd]{1,3}", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*$", "aaa", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"[ac]*$", "aaa", RegexOptions.Multiline, new string[] { "aaa" } }; yield return new object[] { engine, null, @"[ac]*\b", "aaa bbb", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"[ac]*\b", "aaa bbb", RegexOptions.ECMAScript, new string[] { "aaa" } }; yield return new object[] { engine, null, @"[@']*\B", "@@@", RegexOptions.None, new string[] { "@@@" } }; yield return new object[] { engine, null, @"[@']*\B", "@@@", RegexOptions.ECMAScript, new string[] { "@@@" } }; yield return new object[] { engine, null, @".*.", "@@@", RegexOptions.Singleline, new string[] { "@@@" } }; yield return new object[] { engine, null, @"(?:abcd|efg[hij]*)h", "efgh", RegexOptions.None, new string[] { "efgh" } }; // can't upgrade yield return new object[] { engine, null, @"(?:abcd|efg[hij]*)ih", "efgjih", RegexOptions.None, new string[] { "efgjih" } }; // can't upgrade yield return new object[] { engine, null, @"(?:abcd|efg[hij]*)k", "efgjk", RegexOptions.None, new string[] { "efgjk" } }; yield return new object[] { engine, null, @"[ace]?b[ace]?b[ace]?b[ace]?b", "cbbabeb", RegexOptions.None, new string[] { "cbbabeb" } }; yield return new object[] { engine, null, @"[ace]?b[ace]?b[ace]?b[ace]?b", "cBbAbEb", RegexOptions.IgnoreCase, new string[] { "cBbAbEb" } }; yield return new object[] { engine, null, @"a[^wz]*w", "abcdcdcdwz", RegexOptions.None, new string[] { "abcdcdcdw" } }; yield return new object[] { engine, null, @"a[^wyz]*w", "abcdcdcdwz", RegexOptions.None, new string[] { "abcdcdcdw" } }; yield return new object[] { engine, null, @"a[^wyz]*W", "abcdcdcdWz", RegexOptions.IgnoreCase, new string[] { "abcdcdcdW" } }; // Implicitly upgrading (or not) concat loops to be atomic yield return new object[] { engine, null, @"(?:[ab]c[de]f)*", "", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"(?:[ab]c[de]f)*", "acdf", RegexOptions.None, new string[] { "acdf" } }; yield return new object[] { engine, null, @"(?:[ab]c[de]f)*", "acdfbcef", RegexOptions.None, new string[] { "acdfbcef" } }; yield return new object[] { engine, null, @"(?:[ab]c[de]f)*", "cdfbcef", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"(?:[ab]c[de]f)+", "cdfbcef", RegexOptions.None, new string[] { "bcef" } }; yield return new object[] { engine, null, @"(?:[ab]c[de]f)*", "bcefbcdfacfe", RegexOptions.None, new string[] { "bcefbcdf" } }; // Implicitly upgrading (or not) nested loops to be atomic yield return new object[] { engine, null, @"(?:a){3}", "aaaaaaaaa", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"(?:a){3}?", "aaaaaaaaa", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"(?:a{2}){3}", "aaaaaaaaa", RegexOptions.None, new string[] { "aaaaaa" } }; yield return new object[] { engine, null, @"(?:a{2}?){3}?", "aaaaaaaaa", RegexOptions.None, new string[] { "aaaaaa" } }; yield return new object[] { engine, null, @"(?:(?:[ab]c[de]f){3}){2}", "acdfbcdfacefbcefbcefbcdfacdef", RegexOptions.None, new string[] { "acdfbcdfacefbcefbcefbcdf" } }; yield return new object[] { engine, null, @"(?:(?:[ab]c[de]f){3}hello){2}", "aaaaaacdfbcdfacefhellobcefbcefbcdfhellooooo", RegexOptions.None, new string[] { "acdfbcdfacefhellobcefbcefbcdfhello" } }; yield return new object[] { engine, null, @"CN=(.*[^,]+).*", "CN=localhost", RegexOptions.Singleline, new string[] { "CN=localhost", "localhost" } }; // Nested atomic yield return new object[] { engine, null, @"(?>abc[def]gh(i*))", "123abceghiii456", RegexOptions.None, new string[] { "abceghiii", "iii" } }; yield return new object[] { engine, null, @"(?>(?:abc)*)", "abcabcabc", RegexOptions.None, new string[] { "abcabcabc" } }; // Anchoring loops beginning with .* / .+ yield return new object[] { engine, null, @".*", "", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @".*", "\n\n\n\n", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @".*", "\n\n\n\n", RegexOptions.Singleline, new string[] { "\n\n\n\n" } }; yield return new object[] { engine, null, @".*[1a]", "\n\n\n\n1", RegexOptions.None, new string[] { "1" } }; yield return new object[] { engine, null, @"(?s).*(?-s)[1a]", "1\n\n\n\n", RegexOptions.None, new string[] { "1" } }; yield return new object[] { engine, null, @"(?s).*(?-s)[1a]", "\n\n\n\n1", RegexOptions.None, new string[] { "\n\n\n\n1" } }; yield return new object[] { engine, null, @".*|.*|.*", "", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @".*123|abc", "abc\n123", RegexOptions.None, new string[] { "abc" } }; yield return new object[] { engine, null, @".*123|abc", "abc\n123", RegexOptions.Singleline, new string[] { "abc\n123" } }; yield return new object[] { engine, null, @"abc|.*123", "abc\n123", RegexOptions.Singleline, new string[] { "abc" } }; yield return new object[] { engine, null, @".*", "\n", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @".*\n", "\n", RegexOptions.None, new string[] { "\n" } }; yield return new object[] { engine, null, @".*", "\n", RegexOptions.Singleline, new string[] { "\n" } }; yield return new object[] { engine, null, @".*\n", "\n", RegexOptions.Singleline, new string[] { "\n" } }; yield return new object[] { engine, null, @".*", "abc", RegexOptions.None, new string[] { "abc" } }; yield return new object[] { engine, null, @".*abc", "abc", RegexOptions.None, new string[] { "abc" } }; yield return new object[] { engine, null, @".*abc|ghi", "ghi", RegexOptions.None, new string[] { "ghi" } }; yield return new object[] { engine, null, @".*abc|.*ghi", "abcghi", RegexOptions.None, new string[] { "abc" } }; yield return new object[] { engine, null, @".*ghi|.*abc", "abcghi", RegexOptions.None, new string[] { "abcghi" } }; yield return new object[] { engine, null, @".*abc|.*ghi", "bcghi", RegexOptions.None, new string[] { "bcghi" } }; yield return new object[] { engine, null, @".*abc|.+c", " \n \n bc", RegexOptions.None, new string[] { " bc" } }; yield return new object[] { engine, null, @".*abc", "12345 abc", RegexOptions.None, new string[] { "12345 abc" } }; yield return new object[] { engine, null, @".*abc", "12345\n abc", RegexOptions.None, new string[] { " abc" } }; yield return new object[] { engine, null, @".*abc", "12345\n abc", RegexOptions.Singleline, new string[] { "12345\n abc" } }; yield return new object[] { engine, null, @"(.*)abc\1", "\n12345abc12345", RegexOptions.Singleline, new string[] { "12345abc12345", "12345" } }; yield return new object[] { engine, null, @".*\nabc", "\n123\nabc", RegexOptions.None, new string[] { "123\nabc" } }; yield return new object[] { engine, null, @".*\nabc", "\n123\nabc", RegexOptions.Singleline, new string[] { "\n123\nabc" } }; yield return new object[] { engine, null, @".*abc", "abc abc abc \nabc", RegexOptions.None, new string[] { "abc abc abc" } }; yield return new object[] { engine, null, @".*abc", "abc abc abc \nabc", RegexOptions.Singleline, new string[] { "abc abc abc \nabc" } }; yield return new object[] { engine, null, @".*?abc", "abc abc abc \nabc", RegexOptions.None, new string[] { "abc" } }; yield return new object[] { engine, null, @"[^\n]*abc", "123abc\n456abc\n789abc", RegexOptions.None, new string[] { "123abc" } }; yield return new object[] { engine, null, @"[^\n]*abc", "123abc\n456abc\n789abc", RegexOptions.Singleline, new string[] { "123abc" } }; yield return new object[] { engine, null, @"[^\n]*abc", "123ab\n456abc\n789abc", RegexOptions.None, new string[] { "456abc" } }; yield return new object[] { engine, null, @"[^\n]*abc", "123ab\n456abc\n789abc", RegexOptions.Singleline, new string[] { "456abc" } }; yield return new object[] { engine, null, @".+", "a", RegexOptions.None, new string[] { "a" } }; yield return new object[] { engine, null, @".+", "\nabc", RegexOptions.None, new string[] { "abc" } }; yield return new object[] { engine, null, @".+", "\n", RegexOptions.Singleline, new string[] { "\n" } }; yield return new object[] { engine, null, @".+", "\nabc", RegexOptions.Singleline, new string[] { "\nabc" } }; yield return new object[] { engine, null, @".+abc", "aaaabc", RegexOptions.None, new string[] { "aaaabc" } }; yield return new object[] { engine, null, @".+abc", "12345 abc", RegexOptions.None, new string[] { "12345 abc" } }; yield return new object[] { engine, null, @".+abc", "12345\n abc", RegexOptions.None, new string[] { " abc" } }; yield return new object[] { engine, null, @".+abc", "12345\n abc", RegexOptions.Singleline, new string[] { "12345\n abc" } }; yield return new object[] { engine, null, @"(.+)abc\1", "\n12345abc12345", RegexOptions.Singleline, new string[] { "12345abc12345", "12345" } }; // Unanchored .* yield return new object[] { engine, null, @"\A\s*(?<name>\w+)(\s*\((?<arguments>.*)\))?\s*\Z", "Match(Name)", RegexOptions.None, new string[] { "Match(Name)", "(Name)", "Match", "Name" } }; yield return new object[] { engine, null, @"\A\s*(?<name>\w+)(\s*\((?<arguments>.*)\))?\s*\Z", "Match(Na\nme)", RegexOptions.Singleline, new string[] { "Match(Na\nme)", "(Na\nme)", "Match", "Na\nme" } }; foreach (RegexOptions options in new[] { RegexOptions.None, RegexOptions.Singleline }) { yield return new object[] { engine, null, @"abcd.*", @"abcabcd", options, new string[] { "abcd" } }; yield return new object[] { engine, null, @"abcd.*", @"abcabcde", options, new string[] { "abcde" } }; yield return new object[] { engine, null, @"abcd.*", @"abcabcdefg", options, new string[] { "abcdefg" } }; yield return new object[] { engine, null, @"abcd(.*)", @"ababcd", options, new string[] { "abcd", "" } }; yield return new object[] { engine, null, @"abcd(.*)", @"aabcde", options, new string[] { "abcde", "e" } }; yield return new object[] { engine, null, @"abcd(.*)", @"abcabcdefg", options, new string[] { "abcdefg", "efg" } }; yield return new object[] { engine, null, @"abcd(.*)e", @"abcabcdefg", options, new string[] { "abcde", "" } }; yield return new object[] { engine, null, @"abcd(.*)f", @"abcabcdefg", options, new string[] { "abcdef", "e" } }; } // Grouping Constructs yield return new object[] { engine, null, @"()", "cat", RegexOptions.None, new string[] { string.Empty, string.Empty } }; yield return new object[] { engine, null, @"(?<cat>)", "cat", RegexOptions.None, new string[] { string.Empty, string.Empty } }; yield return new object[] { engine, null, @"(?'cat')", "cat", RegexOptions.None, new string[] { string.Empty, string.Empty } }; yield return new object[] { engine, null, @"(?:)", "cat", RegexOptions.None, new string[] { string.Empty } }; yield return new object[] { engine, null, @"(?imn)", "cat", RegexOptions.None, new string[] { string.Empty } }; yield return new object[] { engine, null, @"(?imn)cat", "(?imn)cat", RegexOptions.None, new string[] { "cat" } }; yield return new object[] { engine, null, @"(?=)", "cat", RegexOptions.None, new string[] { string.Empty } }; yield return new object[] { engine, null, @"(?<=)", "cat", RegexOptions.None, new string[] { string.Empty } }; yield return new object[] { engine, null, @"(?>)", "cat", RegexOptions.None, new string[] { string.Empty } }; // Alternation construct yield return new object[] { engine, null, @"(?()|)", "(?()|)", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"(?(cat)|)", "cat", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"(?(cat)|)", "dog", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"(?(cat)catdog|)", "catdog", RegexOptions.None, new string[] { "catdog" } }; yield return new object[] { engine, null, @"(?(cat)cat\w\w\w)*", "catdogcathog", RegexOptions.None, new string[] { "catdogcathog" } }; yield return new object[] { engine, null, @"(?(?=cat)cat\w\w\w)*", "catdogcathog", RegexOptions.None, new string[] { "catdogcathog" } }; yield return new object[] { engine, null, @"(?(cat)catdog|)", "dog", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"(?(cat)dog|)", "dog", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"(?(cat)dog|)", "cat", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"(?(cat)|catdog)", "cat", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"(?(cat)|catdog)", "catdog", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"(?(cat)|dog)", "dog", RegexOptions.None, new string[] { "dog" } }; yield return new object[] { engine, null, @"(?((\w{3}))\1\1|no)", "dogdogdog", RegexOptions.None, new string[] { "dogdog", "dog" } }; yield return new object[] { engine, null, @"(?((\w{3}))\1\1|no)", "no", RegexOptions.None, new string[] { "no", "" } }; // Invalid unicode yield return new object[] { engine, null, "([\u0000-\uFFFF-[azAZ09]]|[\u0000-\uFFFF-[^azAZ09]])+", "azAZBCDE1234567890BCDEFAZza", RegexOptions.None, new string[] { "azAZBCDE1234567890BCDEFAZza", "a" } }; yield return new object[] { engine, null, "[\u0000-\uFFFF-[\u0000-\uFFFF-[\u0000-\uFFFF-[\u0000-\uFFFF-[\u0000-\uFFFF-[a]]]]]]+", "abcxyzABCXYZ123890", RegexOptions.None, new string[] { "bcxyzABCXYZ123890" } }; yield return new object[] { engine, null, "[\u0000-\uFFFF-[\u0000-\uFFFF-[\u0000-\uFFFF-[\u0000-\uFFFF-[\u0000-\uFFFF-[\u0000-\uFFFF-[a]]]]]]]+", "bcxyzABCXYZ123890a", RegexOptions.None, new string[] { "a" } }; yield return new object[] { engine, null, "[\u0000-\uFFFF-[\\p{P}\\p{S}\\p{C}]]+", "!@`';.,$+<>=\x0001\x001FazAZ09", RegexOptions.None, new string[] { "azAZ09" } }; yield return new object[] { engine, null, @"[\uFFFD-\uFFFF]+", "\uFFFC\uFFFD\uFFFE\uFFFF", RegexOptions.IgnoreCase, new string[] { "\uFFFD\uFFFE\uFFFF" } }; yield return new object[] { engine, null, @"[\uFFFC-\uFFFE]+", "\uFFFB\uFFFC\uFFFD\uFFFE\uFFFF", RegexOptions.IgnoreCase, new string[] { "\uFFFC\uFFFD\uFFFE" } }; // Empty Match yield return new object[] { engine, null, @"([a*]*)+?$", "ab", RegexOptions.None, new string[] { "", "" } }; yield return new object[] { engine, null, @"(a*)+?$", "b", RegexOptions.None, new string[] { "", "" } }; } } public static IEnumerable<object[]> Groups_CustomCulture_TestData_enUS() { foreach (RegexEngine engine in RegexHelpers.AvailableEngines) { yield return new object[] { engine, "en-US", "CH", "Ch", RegexOptions.IgnoreCase, new string[] { "Ch" } }; yield return new object[] { engine, "en-US", "cH", "Ch", RegexOptions.IgnoreCase, new string[] { "Ch" } }; yield return new object[] { engine, "en-US", "AA", "Aa", RegexOptions.IgnoreCase, new string[] { "Aa" } }; yield return new object[] { engine, "en-US", "aA", "Aa", RegexOptions.IgnoreCase, new string[] { "Aa" } }; yield return new object[] { engine, "en-US", "\u0130", "\u0049", RegexOptions.IgnoreCase, new string[] { "\u0049" } }; yield return new object[] { engine, "en-US", "\u0130", "\u0069", RegexOptions.IgnoreCase, new string[] { "\u0069" } }; } } public static IEnumerable<object[]> Groups_CustomCulture_TestData_Czech() { foreach (RegexEngine engine in RegexHelpers.AvailableEngines) { yield return new object[] { engine, "cs-CZ", "CH", "Ch", RegexOptions.IgnoreCase, new string[] { "Ch" } }; yield return new object[] { engine, "cs-CZ", "cH", "Ch", RegexOptions.IgnoreCase, new string[] { "Ch" } }; } } public static IEnumerable<object[]> Groups_CustomCulture_TestData_Danish() { foreach (RegexEngine engine in RegexHelpers.AvailableEngines) { yield return new object[] { engine, "da-DK", "AA", "Aa", RegexOptions.IgnoreCase, new string[] { "Aa" } }; yield return new object[] { engine, "da-DK", "aA", "Aa", RegexOptions.IgnoreCase, new string[] { "Aa" } }; } } public static IEnumerable<object[]> Groups_CustomCulture_TestData_Turkish() { foreach (RegexEngine engine in RegexHelpers.AvailableEngines) { yield return new object[] { engine, "tr-TR", "\u0131", "\u0049", RegexOptions.IgnoreCase, new string[] { "\u0049" } }; yield return new object[] { engine, "tr-TR", "\u0130", "\u0069", RegexOptions.IgnoreCase, new string[] { "\u0069" } }; } } public static IEnumerable<object[]> Groups_CustomCulture_TestData_AzeriLatin() { foreach (RegexEngine engine in RegexHelpers.AvailableEngines) { if (PlatformDetection.IsNotBrowser) { yield return new object[] { engine, "az-Latn-AZ", "\u0131", "\u0049", RegexOptions.IgnoreCase, new string[] { "\u0049" } }; yield return new object[] { engine, "az-Latn-AZ", "\u0130", "\u0069", RegexOptions.IgnoreCase, new string[] { "\u0069" } }; } } } [Theory] [MemberData(nameof(Groups_Basic_TestData))] [MemberData(nameof(Groups_CustomCulture_TestData_enUS))] [MemberData(nameof(Groups_CustomCulture_TestData_Czech))] [MemberData(nameof(Groups_CustomCulture_TestData_Danish))] [MemberData(nameof(Groups_CustomCulture_TestData_Turkish))] [MemberData(nameof(Groups_CustomCulture_TestData_AzeriLatin))] [ActiveIssue("https://github.com/dotnet/runtime/issues/56407", TestPlatforms.Android)] [ActiveIssue("https://github.com/dotnet/runtime/issues/36900", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)] public async Task Groups(RegexEngine engine, string cultureName, string pattern, string input, RegexOptions options, string[] expectedGroups) { if (cultureName is null) { CultureInfo culture = CultureInfo.CurrentCulture; cultureName = culture.Equals(CultureInfo.InvariantCulture) ? "en-US" : culture.Name; } using var _ = new ThreadCultureChange(cultureName); Regex regex; try { regex = await RegexHelpers.GetRegexAsync(engine, pattern, options); } catch (NotSupportedException) when (RegexHelpers.IsNonBacktracking(engine)) { // Some constructs are not supported in NonBacktracking mode, such as: if-then-else, lookaround, and backreferences return; } Match match = regex.Match(input); Assert.True(match.Success); Assert.Equal(expectedGroups[0], match.Value); Assert.Equal(expectedGroups.Length, match.Groups.Count); int[] groupNumbers = regex.GetGroupNumbers(); string[] groupNames = regex.GetGroupNames(); for (int i = 0; i < expectedGroups.Length; i++) { Assert.Equal(expectedGroups[i], match.Groups[groupNumbers[i]].Value); Assert.Equal(match.Groups[groupNumbers[i]], match.Groups[groupNames[i]]); Assert.Equal(groupNumbers[i], regex.GroupNumberFromName(groupNames[i])); Assert.Equal(groupNames[i], regex.GroupNameFromNumber(groupNumbers[i])); } } [Fact] public void Synchronized_NullGroup_Throws() { AssertExtensions.Throws<ArgumentNullException>("inner", () => Group.Synchronized(null)); } [Theory] [InlineData(@"(cat)([\v]*)(dog)", "cat\v\v\vdog")] [InlineData("abc", "def")] // no match public void Synchronized_ValidGroup_Success(string pattern, string input) { Match match = Regex.Match(input, pattern); Group synchronizedGroup = Group.Synchronized(match.Groups[0]); Assert.NotNull(synchronizedGroup); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Globalization; using System.Tests; using System.Threading.Tasks; using Xunit; namespace System.Text.RegularExpressions.Tests { public class RegexGroupTests { public static IEnumerable<object[]> Groups_Basic_TestData() { foreach (RegexEngine engine in RegexHelpers.AvailableEngines) { // (A - B) B is a subset of A(ie B only contains chars that are in A) yield return new object[] { engine, null, "[abcd-[d]]+", "dddaabbccddd", RegexOptions.None, new string[] { "aabbcc" } }; yield return new object[] { engine, null, @"[\d-[357]]+", "33312468955", RegexOptions.None, new string[] { "124689" } }; yield return new object[] { engine, null, @"[\d-[357]]+", "51246897", RegexOptions.None, new string[] { "124689" } }; yield return new object[] { engine, null, @"[\d-[357]]+", "3312468977", RegexOptions.None, new string[] { "124689" } }; yield return new object[] { engine, null, @"[\w-[b-y]]+", "bbbaaaABCD09zzzyyy", RegexOptions.None, new string[] { "aaaABCD09zzz" } }; yield return new object[] { engine, null, @"[\w-[\d]]+", "0AZaz9", RegexOptions.None, new string[] { "AZaz" } }; yield return new object[] { engine, null, @"[\w-[\p{Ll}]]+", "a09AZz", RegexOptions.None, new string[] { "09AZ" } }; yield return new object[] { engine, null, @"[\d-[13579]]+", "1024689", RegexOptions.ECMAScript, new string[] { "02468" } }; yield return new object[] { engine, null, @"[\d-[13579]]+", "\x066102468\x0660", RegexOptions.ECMAScript, new string[] { "02468" } }; yield return new object[] { engine, null, @"[\d-[13579]]+", "\x066102468\x0660", RegexOptions.None, new string[] { "\x066102468\x0660" } }; yield return new object[] { engine, null, @"[\p{Ll}-[ae-z]]+", "aaabbbcccdddeee", RegexOptions.None, new string[] { "bbbcccddd" } }; yield return new object[] { engine, null, @"[\p{Nd}-[2468]]+", "20135798", RegexOptions.None, new string[] { "013579" } }; yield return new object[] { engine, null, @"[\P{Lu}-[ae-z]]+", "aaabbbcccdddeee", RegexOptions.None, new string[] { "bbbcccddd" } }; yield return new object[] { engine, null, @"[\P{Nd}-[\p{Ll}]]+", "az09AZ'[]", RegexOptions.None, new string[] { "AZ'[]" } }; // (A - B) B is a superset of A (ie B contains chars that are in A plus other chars that are not in A) yield return new object[] { engine, null, "[abcd-[def]]+", "fedddaabbccddd", RegexOptions.None, new string[] { "aabbcc" } }; yield return new object[] { engine, null, @"[\d-[357a-z]]+", "az33312468955", RegexOptions.None, new string[] { "124689" } }; yield return new object[] { engine, null, @"[\d-[de357fgA-Z]]+", "AZ51246897", RegexOptions.None, new string[] { "124689" } }; yield return new object[] { engine, null, @"[\d-[357\p{Ll}]]+", "az3312468977", RegexOptions.None, new string[] { "124689" } }; yield return new object[] { engine, null, @"[\w-[b-y\s]]+", " \tbbbaaaABCD09zzzyyy", RegexOptions.None, new string[] { "aaaABCD09zzz" } }; yield return new object[] { engine, null, @"[\w-[\d\p{Po}]]+", "!#0AZaz9", RegexOptions.None, new string[] { "AZaz" } }; yield return new object[] { engine, null, @"[\w-[\p{Ll}\s]]+", "a09AZz", RegexOptions.None, new string[] { "09AZ" } }; yield return new object[] { engine, null, @"[\d-[13579a-zA-Z]]+", "AZ1024689", RegexOptions.ECMAScript, new string[] { "02468" } }; yield return new object[] { engine, null, @"[\d-[13579abcd]]+", "abcd\x066102468\x0660", RegexOptions.ECMAScript, new string[] { "02468" } }; yield return new object[] { engine, null, @"[\d-[13579\s]]+", " \t\x066102468\x0660", RegexOptions.None, new string[] { "\x066102468\x0660" } }; yield return new object[] { engine, null, @"[\w-[b-y\p{Po}]]+", "!#bbbaaaABCD09zzzyyy", RegexOptions.None, new string[] { "aaaABCD09zzz" } }; yield return new object[] { engine, null, @"[\w-[b-y!.,]]+", "!.,bbbaaaABCD09zzzyyy", RegexOptions.None, new string[] { "aaaABCD09zzz" } }; yield return new object[] { engine, null, "[\\w-[b-y\x00-\x0F]]+", "\0bbbaaaABCD09zzzyyy", RegexOptions.None, new string[] { "aaaABCD09zzz" } }; yield return new object[] { engine, null, @"[\p{Ll}-[ae-z0-9]]+", "09aaabbbcccdddeee", RegexOptions.None, new string[] { "bbbcccddd" } }; yield return new object[] { engine, null, @"[\p{Nd}-[2468az]]+", "az20135798", RegexOptions.None, new string[] { "013579" } }; yield return new object[] { engine, null, @"[\P{Lu}-[ae-zA-Z]]+", "AZaaabbbcccdddeee", RegexOptions.None, new string[] { "bbbcccddd" } }; yield return new object[] { engine, null, @"[\P{Nd}-[\p{Ll}0123456789]]+", "09az09AZ'[]", RegexOptions.None, new string[] { "AZ'[]" } }; // (A - B) B only contains chars that are not in A yield return new object[] { engine, null, "[abc-[defg]]+", "dddaabbccddd", RegexOptions.None, new string[] { "aabbcc" } }; yield return new object[] { engine, null, @"[\d-[abc]]+", "abc09abc", RegexOptions.None, new string[] { "09" } }; yield return new object[] { engine, null, @"[\d-[a-zA-Z]]+", "az09AZ", RegexOptions.None, new string[] { "09" } }; yield return new object[] { engine, null, @"[\d-[\p{Ll}]]+", "az09az", RegexOptions.None, new string[] { "09" } }; yield return new object[] { engine, null, @"[\w-[\x00-\x0F]]+", "bbbaaaABYZ09zzzyyy", RegexOptions.None, new string[] { "bbbaaaABYZ09zzzyyy" } }; yield return new object[] { engine, null, @"[\w-[\s]]+", "0AZaz9", RegexOptions.None, new string[] { "0AZaz9" } }; yield return new object[] { engine, null, @"[\w-[\W]]+", "0AZaz9", RegexOptions.None, new string[] { "0AZaz9" } }; yield return new object[] { engine, null, @"[\w-[\p{Po}]]+", "#a09AZz!", RegexOptions.None, new string[] { "a09AZz" } }; yield return new object[] { engine, null, @"[\d-[\D]]+", "azAZ1024689", RegexOptions.ECMAScript, new string[] { "1024689" } }; yield return new object[] { engine, null, @"[\d-[a-zA-Z]]+", "azAZ\x066102468\x0660", RegexOptions.ECMAScript, new string[] { "02468" } }; yield return new object[] { engine, null, @"[\d-[\p{Ll}]]+", "\x066102468\x0660", RegexOptions.None, new string[] { "\x066102468\x0660" } }; yield return new object[] { engine, null, @"[a-zA-Z0-9-[\s]]+", " \tazAZ09", RegexOptions.None, new string[] { "azAZ09" } }; yield return new object[] { engine, null, @"[a-zA-Z0-9-[\W]]+", "bbbaaaABCD09zzzyyy", RegexOptions.None, new string[] { "bbbaaaABCD09zzzyyy" } }; yield return new object[] { engine, null, @"[a-zA-Z0-9-[^a-zA-Z0-9]]+", "bbbaaaABCD09zzzyyy", RegexOptions.None, new string[] { "bbbaaaABCD09zzzyyy" } }; yield return new object[] { engine, null, @"[\p{Ll}-[A-Z]]+", "AZaz09", RegexOptions.None, new string[] { "az" } }; yield return new object[] { engine, null, @"[\p{Nd}-[a-z]]+", "az09", RegexOptions.None, new string[] { "09" } }; yield return new object[] { engine, null, @"[\P{Lu}-[\p{Lu}]]+", "AZazAZ", RegexOptions.None, new string[] { "az" } }; yield return new object[] { engine, null, @"[\P{Lu}-[A-Z]]+", "AZazAZ", RegexOptions.None, new string[] { "az" } }; yield return new object[] { engine, null, @"[\P{Nd}-[\p{Nd}]]+", "azAZ09", RegexOptions.None, new string[] { "azAZ" } }; yield return new object[] { engine, null, @"[\P{Nd}-[2-8]]+", "1234567890azAZ1234567890", RegexOptions.None, new string[] { "azAZ" } }; // Alternating construct yield return new object[] { engine, null, @"([ ]|[\w-[0-9]])+", "09az AZ90", RegexOptions.None, new string[] { "az AZ", "Z" } }; yield return new object[] { engine, null, @"([0-9-[02468]]|[0-9-[13579]])+", "az1234567890za", RegexOptions.None, new string[] { "1234567890", "0" } }; yield return new object[] { engine, null, @"([^0-9-[a-zAE-Z]]|[\w-[a-zAF-Z]])+", "azBCDE1234567890BCDEFza", RegexOptions.None, new string[] { "BCDE1234567890BCDE", "E" } }; yield return new object[] { engine, null, @"([\p{Ll}-[aeiou]]|[^\w-[\s]])+", "aeiobcdxyz!@#aeio", RegexOptions.None, new string[] { "bcdxyz!@#", "#" } }; yield return new object[] { engine, null, @"(?:hello|hi){1,3}", "hello", RegexOptions.None, new string[] { "hello" } }; yield return new object[] { engine, null, @"(hello|hi){1,3}", "hellohihey", RegexOptions.None, new string[] { "hellohi", "hi" } }; yield return new object[] { engine, null, @"(?:hello|hi){1,3}", "hellohihey", RegexOptions.None, new string[] { "hellohi" } }; yield return new object[] { engine, null, @"(?:hello|hi){2,2}", "hellohihey", RegexOptions.None, new string[] { "hellohi" } }; yield return new object[] { engine, null, @"(?:hello|hi){2,2}?", "hellohihihello", RegexOptions.None, new string[] { "hellohi" } }; yield return new object[] { engine, null, @"(?:abc|def|ghi|hij|klm|no){1,4}", "this is a test nonoabcxyz this is only a test", RegexOptions.None, new string[] { "nonoabc" } }; yield return new object[] { engine, null, @"xyz(abc|def)xyz", "abcxyzdefxyzabc", RegexOptions.None, new string[] { "xyzdefxyz", "def" } }; yield return new object[] { engine, null, @"abc|(?:def|ghi)", "ghi", RegexOptions.None, new string[] { "ghi" } }; yield return new object[] { engine, null, @"abc|(def|ghi)", "def", RegexOptions.None, new string[] { "def", "def" } }; // Multiple character classes using character class subtraction yield return new object[] { engine, null, @"98[\d-[9]][\d-[8]][\d-[0]]", "98911 98881 98870 98871", RegexOptions.None, new string[] { "98871" } }; yield return new object[] { engine, null, @"m[\w-[^aeiou]][\w-[^aeiou]]t", "mbbt mect meet", RegexOptions.None, new string[] { "meet" } }; // Negation with character class subtraction yield return new object[] { engine, null, "[abcdef-[^bce]]+", "adfbcefda", RegexOptions.None, new string[] { "bce" } }; yield return new object[] { engine, null, "[^cde-[ag]]+", "agbfxyzga", RegexOptions.None, new string[] { "bfxyz" } }; // Misc The idea here is come up with real world examples of char class subtraction. Things that // would be difficult to define without it yield return new object[] { engine, null, @"[\p{L}-[^\p{Lu}]]+", "09',.abcxyzABCXYZ", RegexOptions.None, new string[] { "ABCXYZ" } }; yield return new object[] { engine, null, @"[\p{IsGreek}-[\P{Lu}]]+", "\u0390\u03FE\u0386\u0388\u03EC\u03EE\u0400", RegexOptions.None, new string[] { "\u03FE\u0386\u0388\u03EC\u03EE" } }; yield return new object[] { engine, null, @"[\p{IsBasicLatin}-[G-L]]+", "GAFMZL", RegexOptions.None, new string[] { "AFMZ" } }; yield return new object[] { engine, null, "[a-zA-Z-[aeiouAEIOU]]+", "aeiouAEIOUbcdfghjklmnpqrstvwxyz", RegexOptions.None, new string[] { "bcdfghjklmnpqrstvwxyz" } }; // The following is an overly complex way of matching an ip address using char class subtraction yield return new object[] { engine, null, @"^ (?<octet>^ ( ( (?<Octet2xx>[\d-[013-9]]) | [\d-[2-9]] ) (?(Octet2xx) ( (?<Octet25x>[\d-[01-46-9]]) | [\d-[5-9]] ) ( (?(Octet25x) [\d-[6-9]] | [\d] ) ) | [\d]{2} ) ) | ([\d][\d]) | [\d] )$" , "255", RegexOptions.IgnorePatternWhitespace, new string[] { "255", "255", "2", "5", "5", "", "255", "2", "5" } }; // Character Class Substraction yield return new object[] { engine, null, @"[abcd\-d-[bc]]+", "bbbaaa---dddccc", RegexOptions.None, new string[] { "aaa---ddd" } }; yield return new object[] { engine, null, @"[^a-f-[\x00-\x60\u007B-\uFFFF]]+", "aaafffgggzzz{{{", RegexOptions.None, new string[] { "gggzzz" } }; yield return new object[] { engine, null, @"[\[\]a-f-[[]]+", "gggaaafff]]][[[", RegexOptions.None, new string[] { "aaafff]]]" } }; yield return new object[] { engine, null, @"[\[\]a-f-[]]]+", "gggaaafff[[[]]]", RegexOptions.None, new string[] { "aaafff[[[" } }; yield return new object[] { engine, null, @"[ab\-\[cd-[-[]]]]", "a]]", RegexOptions.None, new string[] { "a]]" } }; yield return new object[] { engine, null, @"[ab\-\[cd-[-[]]]]", "b]]", RegexOptions.None, new string[] { "b]]" } }; yield return new object[] { engine, null, @"[ab\-\[cd-[-[]]]]", "c]]", RegexOptions.None, new string[] { "c]]" } }; yield return new object[] { engine, null, @"[ab\-\[cd-[-[]]]]", "d]]", RegexOptions.None, new string[] { "d]]" } }; yield return new object[] { engine, null, @"[ab\-\[cd-[[]]]]", "a]]", RegexOptions.None, new string[] { "a]]" } }; yield return new object[] { engine, null, @"[ab\-\[cd-[[]]]]", "b]]", RegexOptions.None, new string[] { "b]]" } }; yield return new object[] { engine, null, @"[ab\-\[cd-[[]]]]", "c]]", RegexOptions.None, new string[] { "c]]" } }; yield return new object[] { engine, null, @"[ab\-\[cd-[[]]]]", "d]]", RegexOptions.None, new string[] { "d]]" } }; yield return new object[] { engine, null, @"[ab\-\[cd-[[]]]]", "-]]", RegexOptions.None, new string[] { "-]]" } }; yield return new object[] { engine, null, @"[a-[c-e]]+", "bbbaaaccc", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"[a-[c-e]]+", "```aaaccc", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"[a-d\--[bc]]+", "cccaaa--dddbbb", RegexOptions.None, new string[] { "aaa--ddd" } }; // Not Character class substraction yield return new object[] { engine, null, @"[\0- [bc]+", "!!!\0\0\t\t [[[[bbbcccaaa", RegexOptions.None, new string[] { "\0\0\t\t [[[[bbbccc" } }; yield return new object[] { engine, null, "[[abcd]-[bc]]+", "a-b]", RegexOptions.None, new string[] { "a-b]" } }; yield return new object[] { engine, null, "[-[e-g]+", "ddd[[[---eeefffggghhh", RegexOptions.None, new string[] { "[[[---eeefffggg" } }; yield return new object[] { engine, null, "[-e-g]+", "ddd---eeefffggghhh", RegexOptions.None, new string[] { "---eeefffggg" } }; yield return new object[] { engine, null, "[a-e - m-p]+", "---a b c d e m n o p---", RegexOptions.None, new string[] { "a b c d e m n o p" } }; yield return new object[] { engine, null, "[^-[bc]]", "b] c] -] aaaddd]", RegexOptions.None, new string[] { "d]" } }; yield return new object[] { engine, null, "[^-[bc]]", "b] c] -] aaa]ddd]", RegexOptions.None, new string[] { "a]" } }; // Make sure we correctly handle \- yield return new object[] { engine, null, @"[a\-[bc]+", "```bbbaaa---[[[cccddd", RegexOptions.None, new string[] { "bbbaaa---[[[ccc" } }; yield return new object[] { engine, null, @"[a\-[\-\-bc]+", "```bbbaaa---[[[cccddd", RegexOptions.None, new string[] { "bbbaaa---[[[ccc" } }; yield return new object[] { engine, null, @"[a\-\[\-\[\-bc]+", "```bbbaaa---[[[cccddd", RegexOptions.None, new string[] { "bbbaaa---[[[ccc" } }; yield return new object[] { engine, null, @"[abc\--[b]]+", "[[[```bbbaaa---cccddd", RegexOptions.None, new string[] { "aaa---ccc" } }; yield return new object[] { engine, null, @"[abc\-z-[b]]+", "```aaaccc---zzzbbb", RegexOptions.None, new string[] { "aaaccc---zzz" } }; yield return new object[] { engine, null, @"[a-d\-[b]+", "```aaabbbcccddd----[[[[]]]", RegexOptions.None, new string[] { "aaabbbcccddd----[[[[" } }; yield return new object[] { engine, null, @"[abcd\-d\-[bc]+", "bbbaaa---[[[dddccc", RegexOptions.None, new string[] { "bbbaaa---[[[dddccc" } }; // Everything works correctly with option RegexOptions.IgnorePatternWhitespace yield return new object[] { engine, null, "[a - c - [ b ] ]+", "dddaaa ccc [[[[ bbb ]]]", RegexOptions.IgnorePatternWhitespace, new string[] { " ]]]" } }; yield return new object[] { engine, null, "[a - c - [ b ] +", "dddaaa ccc [[[[ bbb ]]]", RegexOptions.IgnorePatternWhitespace, new string[] { "aaa ccc [[[[ bbb " } }; // Unicode Char Classes yield return new object[] { engine, null, @"(\p{Lu}\w*)\s(\p{Lu}\w*)", "Hello World", RegexOptions.None, new string[] { "Hello World", "Hello", "World" } }; yield return new object[] { engine, null, @"(\p{Lu}\p{Ll}*)\s(\p{Lu}\p{Ll}*)", "Hello World", RegexOptions.None, new string[] { "Hello World", "Hello", "World" } }; yield return new object[] { engine, null, @"(\P{Ll}\p{Ll}*)\s(\P{Ll}\p{Ll}*)", "Hello World", RegexOptions.None, new string[] { "Hello World", "Hello", "World" } }; yield return new object[] { engine, null, @"(\P{Lu}+\p{Lu})\s(\P{Lu}+\p{Lu})", "hellO worlD", RegexOptions.None, new string[] { "hellO worlD", "hellO", "worlD" } }; yield return new object[] { engine, null, @"(\p{Lt}\w*)\s(\p{Lt}*\w*)", "\u01C5ello \u01C5orld", RegexOptions.None, new string[] { "\u01C5ello \u01C5orld", "\u01C5ello", "\u01C5orld" } }; yield return new object[] { engine, null, @"(\P{Lt}\w*)\s(\P{Lt}*\w*)", "Hello World", RegexOptions.None, new string[] { "Hello World", "Hello", "World" } }; // Character ranges IgnoreCase yield return new object[] { engine, null, @"[@-D]+", "eE?@ABCDabcdeE", RegexOptions.IgnoreCase, new string[] { "@ABCDabcd" } }; yield return new object[] { engine, null, @"[>-D]+", "eE=>?@ABCDabcdeE", RegexOptions.IgnoreCase, new string[] { ">?@ABCDabcd" } }; yield return new object[] { engine, null, @"[\u0554-\u0557]+", "\u0583\u0553\u0554\u0555\u0556\u0584\u0585\u0586\u0557\u0558", RegexOptions.IgnoreCase, new string[] { "\u0554\u0555\u0556\u0584\u0585\u0586\u0557" } }; yield return new object[] { engine, null, @"[X-\]]+", "wWXYZxyz[\\]^", RegexOptions.IgnoreCase, new string[] { "XYZxyz[\\]" } }; yield return new object[] { engine, null, @"[X-\u0533]+", "\u0551\u0554\u0560AXYZaxyz\u0531\u0532\u0533\u0561\u0562\u0563\u0564", RegexOptions.IgnoreCase, new string[] { "AXYZaxyz\u0531\u0532\u0533\u0561\u0562\u0563" } }; yield return new object[] { engine, null, @"[X-a]+", "wWAXYZaxyz", RegexOptions.IgnoreCase, new string[] { "AXYZaxyz" } }; yield return new object[] { engine, null, @"[X-c]+", "wWABCXYZabcxyz", RegexOptions.IgnoreCase, new string[] { "ABCXYZabcxyz" } }; yield return new object[] { engine, null, @"[X-\u00C0]+", "\u00C1\u00E1\u00C0\u00E0wWABCXYZabcxyz", RegexOptions.IgnoreCase, new string[] { "\u00C0\u00E0wWABCXYZabcxyz" } }; yield return new object[] { engine, null, @"[\u0100\u0102\u0104]+", "\u00FF \u0100\u0102\u0104\u0101\u0103\u0105\u0106", RegexOptions.IgnoreCase, new string[] { "\u0100\u0102\u0104\u0101\u0103\u0105" } }; yield return new object[] { engine, null, @"[B-D\u0130]+", "aAeE\u0129\u0131\u0068 BCDbcD\u0130\u0069\u0070", RegexOptions.IgnoreCase, new string[] { "BCDbcD\u0130\u0069" } }; yield return new object[] { engine, null, @"[\u013B\u013D\u013F]+", "\u013A\u013B\u013D\u013F\u013C\u013E\u0140\u0141", RegexOptions.IgnoreCase, new string[] { "\u013B\u013D\u013F\u013C\u013E\u0140" } }; // Escape Chars yield return new object[] { engine, null, "(Cat)\r(Dog)", "Cat\rDog", RegexOptions.None, new string[] { "Cat\rDog", "Cat", "Dog" } }; yield return new object[] { engine, null, "(Cat)\t(Dog)", "Cat\tDog", RegexOptions.None, new string[] { "Cat\tDog", "Cat", "Dog" } }; yield return new object[] { engine, null, "(Cat)\f(Dog)", "Cat\fDog", RegexOptions.None, new string[] { "Cat\fDog", "Cat", "Dog" } }; // Miscellaneous { witout matching } yield return new object[] { engine, null, @"{5", "hello {5 world", RegexOptions.None, new string[] { "{5" } }; yield return new object[] { engine, null, @"{5,", "hello {5, world", RegexOptions.None, new string[] { "{5," } }; yield return new object[] { engine, null, @"{5,6", "hello {5,6 world", RegexOptions.None, new string[] { "{5,6" } }; // Miscellaneous inline options yield return new object[] { engine, null, @"(?n:(?<cat>cat)(\s+)(?<dog>dog))", "cat dog", RegexOptions.None, new string[] { "cat dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(?n:(cat)(\s+)(dog))", "cat dog", RegexOptions.None, new string[] { "cat dog" } }; yield return new object[] { engine, null, @"(?n:(cat)(?<SpaceChars>\s+)(dog))", "cat dog", RegexOptions.None, new string[] { "cat dog", " " } }; yield return new object[] { engine, null, @"(?x: (?<cat>cat) # Cat statement (\s+) # Whitespace chars (?<dog>dog # Dog statement ))", "cat dog", RegexOptions.None, new string[] { "cat dog", " ", "cat", "dog" } }; yield return new object[] { engine, null, @"(?+i:cat)", "CAT", RegexOptions.None, new string[] { "CAT" } }; // \d, \D, \s, \S, \w, \W, \P, \p inside character range yield return new object[] { engine, null, @"cat([\d]*)dog", "hello123cat230927dog1412d", RegexOptions.None, new string[] { "cat230927dog", "230927" } }; yield return new object[] { engine, null, @"([\D]*)dog", "65498catdog58719", RegexOptions.None, new string[] { "catdog", "cat" } }; yield return new object[] { engine, null, @"cat([\s]*)dog", "wiocat dog3270", RegexOptions.None, new string[] { "cat dog", " " } }; yield return new object[] { engine, null, @"cat([\S]*)", "sfdcatdog 3270", RegexOptions.None, new string[] { "catdog", "dog" } }; yield return new object[] { engine, null, @"cat([\w]*)", "sfdcatdog 3270", RegexOptions.None, new string[] { "catdog", "dog" } }; yield return new object[] { engine, null, @"cat([\W]*)dog", "wiocat dog3270", RegexOptions.None, new string[] { "cat dog", " " } }; yield return new object[] { engine, null, @"([\p{Lu}]\w*)\s([\p{Lu}]\w*)", "Hello World", RegexOptions.None, new string[] { "Hello World", "Hello", "World" } }; yield return new object[] { engine, null, @"([\P{Ll}][\p{Ll}]*)\s([\P{Ll}][\p{Ll}]*)", "Hello World", RegexOptions.None, new string[] { "Hello World", "Hello", "World" } }; // \x, \u, \a, \b, \e, \f, \n, \r, \t, \v, \c, inside character range yield return new object[] { engine, null, @"(cat)([\x41]*)(dog)", "catAAAdog", RegexOptions.None, new string[] { "catAAAdog", "cat", "AAA", "dog" } }; yield return new object[] { engine, null, @"(cat)([\u0041]*)(dog)", "catAAAdog", RegexOptions.None, new string[] { "catAAAdog", "cat", "AAA", "dog" } }; yield return new object[] { engine, null, @"(cat)([\a]*)(dog)", "cat\a\a\adog", RegexOptions.None, new string[] { "cat\a\a\adog", "cat", "\a\a\a", "dog" } }; yield return new object[] { engine, null, @"(cat)([\b]*)(dog)", "cat\b\b\bdog", RegexOptions.None, new string[] { "cat\b\b\bdog", "cat", "\b\b\b", "dog" } }; yield return new object[] { engine, null, @"(cat)([\e]*)(dog)", "cat\u001B\u001B\u001Bdog", RegexOptions.None, new string[] { "cat\u001B\u001B\u001Bdog", "cat", "\u001B\u001B\u001B", "dog" } }; yield return new object[] { engine, null, @"(cat)([\f]*)(dog)", "cat\f\f\fdog", RegexOptions.None, new string[] { "cat\f\f\fdog", "cat", "\f\f\f", "dog" } }; yield return new object[] { engine, null, @"(cat)([\r]*)(dog)", "cat\r\r\rdog", RegexOptions.None, new string[] { "cat\r\r\rdog", "cat", "\r\r\r", "dog" } }; yield return new object[] { engine, null, @"(cat)([\v]*)(dog)", "cat\v\v\vdog", RegexOptions.None, new string[] { "cat\v\v\vdog", "cat", "\v\v\v", "dog" } }; // \d, \D, \s, \S, \w, \W, \P, \p inside character range ([0-5]) with ECMA Option yield return new object[] { engine, null, @"cat([\d]*)dog", "hello123cat230927dog1412d", RegexOptions.ECMAScript, new string[] { "cat230927dog", "230927" } }; yield return new object[] { engine, null, @"([\D]*)dog", "65498catdog58719", RegexOptions.ECMAScript, new string[] { "catdog", "cat" } }; yield return new object[] { engine, null, @"cat([\s]*)dog", "wiocat dog3270", RegexOptions.ECMAScript, new string[] { "cat dog", " " } }; yield return new object[] { engine, null, @"cat([\S]*)", "sfdcatdog 3270", RegexOptions.ECMAScript, new string[] { "catdog", "dog" } }; yield return new object[] { engine, null, @"cat([\w]*)", "sfdcatdog 3270", RegexOptions.ECMAScript, new string[] { "catdog", "dog" } }; yield return new object[] { engine, null, @"cat([\W]*)dog", "wiocat dog3270", RegexOptions.ECMAScript, new string[] { "cat dog", " " } }; yield return new object[] { engine, null, @"([\p{Lu}]\w*)\s([\p{Lu}]\w*)", "Hello World", RegexOptions.ECMAScript, new string[] { "Hello World", "Hello", "World" } }; yield return new object[] { engine, null, @"([\P{Ll}][\p{Ll}]*)\s([\P{Ll}][\p{Ll}]*)", "Hello World", RegexOptions.ECMAScript, new string[] { "Hello World", "Hello", "World" } }; // \d, \D, \s, \S, \w, \W, \P, \p outside character range ([0-5]) with ECMA Option yield return new object[] { engine, null, @"(cat)\d*dog", "hello123cat230927dog1412d", RegexOptions.ECMAScript, new string[] { "cat230927dog", "cat" } }; yield return new object[] { engine, null, @"\D*(dog)", "65498catdog58719", RegexOptions.ECMAScript, new string[] { "catdog", "dog" } }; yield return new object[] { engine, null, @"(cat)\s*(dog)", "wiocat dog3270", RegexOptions.ECMAScript, new string[] { "cat dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(cat)\S*", "sfdcatdog 3270", RegexOptions.ECMAScript, new string[] { "catdog", "cat" } }; yield return new object[] { engine, null, @"(cat)\w*", "sfdcatdog 3270", RegexOptions.ECMAScript, new string[] { "catdog", "cat" } }; yield return new object[] { engine, null, @"(cat)\W*(dog)", "wiocat dog3270", RegexOptions.ECMAScript, new string[] { "cat dog", "cat", "dog" } }; yield return new object[] { engine, null, @"\p{Lu}(\w*)\s\p{Lu}(\w*)", "Hello World", RegexOptions.ECMAScript, new string[] { "Hello World", "ello", "orld" } }; yield return new object[] { engine, null, @"\P{Ll}\p{Ll}*\s\P{Ll}\p{Ll}*", "Hello World", RegexOptions.ECMAScript, new string[] { "Hello World" } }; // Use < in a group yield return new object[] { engine, null, @"cat(?<dog121>dog)", "catcatdogdogcat", RegexOptions.None, new string[] { "catdog", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s*(?<cat>dog)", "catcat dogdogcat", RegexOptions.None, new string[] { "cat dog", "dog" } }; yield return new object[] { engine, null, @"(?<1>cat)\s*(?<1>dog)", "catcat dogdogcat", RegexOptions.None, new string[] { "cat dog", "dog" } }; yield return new object[] { engine, null, @"(?<2048>cat)\s*(?<2048>dog)", "catcat dogdogcat", RegexOptions.None, new string[] { "cat dog", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\w+(?<dog-cat>dog)", "cat_Hello_World_dog", RegexOptions.None, new string[] { "cat_Hello_World_dog", "", "_Hello_World_" } }; yield return new object[] { engine, null, @"(?<cat>cat)\w+(?<-cat>dog)", "cat_Hello_World_dog", RegexOptions.None, new string[] { "cat_Hello_World_dog", "" } }; yield return new object[] { engine, null, @"(?<cat>cat)\w+(?<cat-cat>dog)", "cat_Hello_World_dog", RegexOptions.None, new string[] { "cat_Hello_World_dog", "_Hello_World_" } }; yield return new object[] { engine, null, @"(?<1>cat)\w+(?<dog-1>dog)", "cat_Hello_World_dog", RegexOptions.None, new string[] { "cat_Hello_World_dog", "", "_Hello_World_" } }; yield return new object[] { engine, null, @"(?<cat>cat)\w+(?<2-cat>dog)", "cat_Hello_World_dog", RegexOptions.None, new string[] { "cat_Hello_World_dog", "", "_Hello_World_" } }; yield return new object[] { engine, null, @"(?<1>cat)\w+(?<2-1>dog)", "cat_Hello_World_dog", RegexOptions.None, new string[] { "cat_Hello_World_dog", "", "_Hello_World_" } }; // Quantifiers yield return new object[] { engine, null, @"(?<cat>cat){", "STARTcat{", RegexOptions.None, new string[] { "cat{", "cat" } }; yield return new object[] { engine, null, @"(?<cat>cat){fdsa", "STARTcat{fdsa", RegexOptions.None, new string[] { "cat{fdsa", "cat" } }; yield return new object[] { engine, null, @"(?<cat>cat){1", "STARTcat{1", RegexOptions.None, new string[] { "cat{1", "cat" } }; yield return new object[] { engine, null, @"(?<cat>cat){1END", "STARTcat{1END", RegexOptions.None, new string[] { "cat{1END", "cat" } }; yield return new object[] { engine, null, @"(?<cat>cat){1,", "STARTcat{1,", RegexOptions.None, new string[] { "cat{1,", "cat" } }; yield return new object[] { engine, null, @"(?<cat>cat){1,END", "STARTcat{1,END", RegexOptions.None, new string[] { "cat{1,END", "cat" } }; yield return new object[] { engine, null, @"(?<cat>cat){1,2", "STARTcat{1,2", RegexOptions.None, new string[] { "cat{1,2", "cat" } }; yield return new object[] { engine, null, @"(?<cat>cat){1,2END", "STARTcat{1,2END", RegexOptions.None, new string[] { "cat{1,2END", "cat" } }; // Use IgnorePatternWhitespace yield return new object[] { engine, null, @"(cat) #cat \s+ #followed by 1 or more whitespace (dog) #followed by dog ", "cat dog", RegexOptions.IgnorePatternWhitespace, new string[] { "cat dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(cat) #cat \s+ #followed by 1 or more whitespace (dog) #followed by dog", "cat dog", RegexOptions.IgnorePatternWhitespace, new string[] { "cat dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(cat) (?#cat) \s+ (?#followed by 1 or more whitespace) (dog) (?#followed by dog)", "cat dog", RegexOptions.IgnorePatternWhitespace, new string[] { "cat dog", "cat", "dog" } }; // Back Reference yield return new object[] { engine, null, @"(?<cat>cat)(?<dog>dog)\k<cat>", "asdfcatdogcatdog", RegexOptions.None, new string[] { "catdogcat", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\k<cat>", "asdfcat dogcat dog", RegexOptions.None, new string[] { "cat dogcat", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\k'cat'", "asdfcat dogcat dog", RegexOptions.None, new string[] { "cat dogcat", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\<cat>", "asdfcat dogcat dog", RegexOptions.None, new string[] { "cat dogcat", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\'cat'", "asdfcat dogcat dog", RegexOptions.None, new string[] { "cat dogcat", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\k<1>", "asdfcat dogcat dog", RegexOptions.None, new string[] { "cat dogcat", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\k'1'", "asdfcat dogcat dog", RegexOptions.None, new string[] { "cat dogcat", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\<1>", "asdfcat dogcat dog", RegexOptions.None, new string[] { "cat dogcat", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\'1'", "asdfcat dogcat dog", RegexOptions.None, new string[] { "cat dogcat", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\1", "asdfcat dogcat dog", RegexOptions.None, new string[] { "cat dogcat", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\1", "asdfcat dogcat dog", RegexOptions.ECMAScript, new string[] { "cat dogcat", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\k<dog>", "asdfcat dogdog dog", RegexOptions.None, new string[] { "cat dogdog", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\2", "asdfcat dogdog dog", RegexOptions.None, new string[] { "cat dogdog", "cat", "dog" } }; yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\2", "asdfcat dogdog dog", RegexOptions.ECMAScript, new string[] { "cat dogdog", "cat", "dog" } }; // Octal yield return new object[] { engine, null, @"(cat)(\077)", "hellocat?dogworld", RegexOptions.None, new string[] { "cat?", "cat", "?" } }; yield return new object[] { engine, null, @"(cat)(\77)", "hellocat?dogworld", RegexOptions.None, new string[] { "cat?", "cat", "?" } }; yield return new object[] { engine, null, @"(cat)(\176)", "hellocat~dogworld", RegexOptions.None, new string[] { "cat~", "cat", "~" } }; yield return new object[] { engine, null, @"(cat)(\400)", "hellocat\0dogworld", RegexOptions.None, new string[] { "cat\0", "cat", "\0" } }; yield return new object[] { engine, null, @"(cat)(\300)", "hellocat\u00C0dogworld", RegexOptions.None, new string[] { "cat\u00C0", "cat", "\u00C0" } }; yield return new object[] { engine, null, @"(cat)(\477)", "hellocat\u003Fdogworld", RegexOptions.None, new string[] { "cat\u003F", "cat", "\u003F" } }; yield return new object[] { engine, null, @"(cat)(\777)", "hellocat\u00FFdogworld", RegexOptions.None, new string[] { "cat\u00FF", "cat", "\u00FF" } }; yield return new object[] { engine, null, @"(cat)(\7770)", "hellocat\u00FF0dogworld", RegexOptions.None, new string[] { "cat\u00FF0", "cat", "\u00FF0" } }; yield return new object[] { engine, null, @"(cat)(\077)", "hellocat?dogworld", RegexOptions.ECMAScript, new string[] { "cat?", "cat", "?" } }; yield return new object[] { engine, null, @"(cat)(\77)", "hellocat?dogworld", RegexOptions.ECMAScript, new string[] { "cat?", "cat", "?" } }; yield return new object[] { engine, null, @"(cat)(\7)", "hellocat\adogworld", RegexOptions.ECMAScript, new string[] { "cat\a", "cat", "\a" } }; yield return new object[] { engine, null, @"(cat)(\40)", "hellocat dogworld", RegexOptions.ECMAScript, new string[] { "cat ", "cat", " " } }; yield return new object[] { engine, null, @"(cat)(\040)", "hellocat dogworld", RegexOptions.ECMAScript, new string[] { "cat ", "cat", " " } }; yield return new object[] { engine, null, @"(cat)(\176)", "hellocatcat76dogworld", RegexOptions.ECMAScript, new string[] { "catcat76", "cat", "cat76" } }; yield return new object[] { engine, null, @"(cat)(\377)", "hellocat\u00FFdogworld", RegexOptions.ECMAScript, new string[] { "cat\u00FF", "cat", "\u00FF" } }; yield return new object[] { engine, null, @"(cat)(\400)", "hellocat 0Fdogworld", RegexOptions.ECMAScript, new string[] { "cat 0", "cat", " 0" } }; // Decimal yield return new object[] { engine, null, @"(cat)\s+(?<2147483646>dog)", "asdlkcat dogiwod", RegexOptions.None, new string[] { "cat dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(cat)\s+(?<2147483647>dog)", "asdlkcat dogiwod", RegexOptions.None, new string[] { "cat dog", "cat", "dog" } }; // Hex yield return new object[] { engine, null, @"(cat)(\x2a*)(dog)", "asdlkcat***dogiwod", RegexOptions.None, new string[] { "cat***dog", "cat", "***", "dog" } }; yield return new object[] { engine, null, @"(cat)(\x2b*)(dog)", "asdlkcat+++dogiwod", RegexOptions.None, new string[] { "cat+++dog", "cat", "+++", "dog" } }; yield return new object[] { engine, null, @"(cat)(\x2c*)(dog)", "asdlkcat,,,dogiwod", RegexOptions.None, new string[] { "cat,,,dog", "cat", ",,,", "dog" } }; yield return new object[] { engine, null, @"(cat)(\x2d*)(dog)", "asdlkcat---dogiwod", RegexOptions.None, new string[] { "cat---dog", "cat", "---", "dog" } }; yield return new object[] { engine, null, @"(cat)(\x2e*)(dog)", "asdlkcat...dogiwod", RegexOptions.None, new string[] { "cat...dog", "cat", "...", "dog" } }; yield return new object[] { engine, null, @"(cat)(\x2f*)(dog)", "asdlkcat///dogiwod", RegexOptions.None, new string[] { "cat///dog", "cat", "///", "dog" } }; yield return new object[] { engine, null, @"(cat)(\x2A*)(dog)", "asdlkcat***dogiwod", RegexOptions.None, new string[] { "cat***dog", "cat", "***", "dog" } }; yield return new object[] { engine, null, @"(cat)(\x2B*)(dog)", "asdlkcat+++dogiwod", RegexOptions.None, new string[] { "cat+++dog", "cat", "+++", "dog" } }; yield return new object[] { engine, null, @"(cat)(\x2C*)(dog)", "asdlkcat,,,dogiwod", RegexOptions.None, new string[] { "cat,,,dog", "cat", ",,,", "dog" } }; yield return new object[] { engine, null, @"(cat)(\x2D*)(dog)", "asdlkcat---dogiwod", RegexOptions.None, new string[] { "cat---dog", "cat", "---", "dog" } }; yield return new object[] { engine, null, @"(cat)(\x2E*)(dog)", "asdlkcat...dogiwod", RegexOptions.None, new string[] { "cat...dog", "cat", "...", "dog" } }; yield return new object[] { engine, null, @"(cat)(\x2F*)(dog)", "asdlkcat///dogiwod", RegexOptions.None, new string[] { "cat///dog", "cat", "///", "dog" } }; // ScanControl yield return new object[] { engine, null, @"(cat)(\c@*)(dog)", "asdlkcat\0\0dogiwod", RegexOptions.None, new string[] { "cat\0\0dog", "cat", "\0\0", "dog" } }; yield return new object[] { engine, null, @"(cat)(\cA*)(dog)", "asdlkcat\u0001dogiwod", RegexOptions.None, new string[] { "cat\u0001dog", "cat", "\u0001", "dog" } }; yield return new object[] { engine, null, @"(cat)(\ca*)(dog)", "asdlkcat\u0001dogiwod", RegexOptions.None, new string[] { "cat\u0001dog", "cat", "\u0001", "dog" } }; yield return new object[] { engine, null, @"(cat)(\cC*)(dog)", "asdlkcat\u0003dogiwod", RegexOptions.None, new string[] { "cat\u0003dog", "cat", "\u0003", "dog" } }; yield return new object[] { engine, null, @"(cat)(\cc*)(dog)", "asdlkcat\u0003dogiwod", RegexOptions.None, new string[] { "cat\u0003dog", "cat", "\u0003", "dog" } }; yield return new object[] { engine, null, @"(cat)(\cD*)(dog)", "asdlkcat\u0004dogiwod", RegexOptions.None, new string[] { "cat\u0004dog", "cat", "\u0004", "dog" } }; yield return new object[] { engine, null, @"(cat)(\cd*)(dog)", "asdlkcat\u0004dogiwod", RegexOptions.None, new string[] { "cat\u0004dog", "cat", "\u0004", "dog" } }; yield return new object[] { engine, null, @"(cat)(\cX*)(dog)", "asdlkcat\u0018dogiwod", RegexOptions.None, new string[] { "cat\u0018dog", "cat", "\u0018", "dog" } }; yield return new object[] { engine, null, @"(cat)(\cx*)(dog)", "asdlkcat\u0018dogiwod", RegexOptions.None, new string[] { "cat\u0018dog", "cat", "\u0018", "dog" } }; yield return new object[] { engine, null, @"(cat)(\cZ*)(dog)", "asdlkcat\u001adogiwod", RegexOptions.None, new string[] { "cat\u001adog", "cat", "\u001a", "dog" } }; yield return new object[] { engine, null, @"(cat)(\cz*)(dog)", "asdlkcat\u001adogiwod", RegexOptions.None, new string[] { "cat\u001adog", "cat", "\u001a", "dog" } }; if (!PlatformDetection.IsNetFramework) // `\c[` was not handled in .NET Framework. See https://github.com/dotnet/runtime/issues/24759. { yield return new object[] { engine, null, @"(cat)(\c[*)(dog)", "asdlkcat\u001bdogiwod", RegexOptions.None, new string[] { "cat\u001bdog", "cat", "\u001b", "dog" } }; } // Atomic Zero-Width Assertions \A \G ^ \Z \z \b \B //\A yield return new object[] { engine, null, @"\Acat\s+dog", "cat \n\n\n dog", RegexOptions.None, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"\Acat\s+dog", "cat \n\n\n dog", RegexOptions.Multiline, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"\A(cat)\s+(dog)", "cat \n\n\n dog", RegexOptions.None, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"\A(cat)\s+(dog)", "cat \n\n\n dog", RegexOptions.Multiline, new string[] { "cat \n\n\n dog", "cat", "dog" } }; //\G yield return new object[] { engine, null, @"\Gcat\s+dog", "cat \n\n\n dog", RegexOptions.None, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"\Gcat\s+dog", "cat \n\n\n dog", RegexOptions.Multiline, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"\Gcat\s+dog", "cat \n\n\n dog", RegexOptions.ECMAScript, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"\G(cat)\s+(dog)", "cat \n\n\n dog", RegexOptions.None, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"\G(cat)\s+(dog)", "cat \n\n\n dog", RegexOptions.Multiline, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"\G(cat)\s+(dog)", "cat \n\n\n dog", RegexOptions.ECMAScript, new string[] { "cat \n\n\n dog", "cat", "dog" } }; //^ yield return new object[] { engine, null, @"^cat\s+dog", "cat \n\n\n dog", RegexOptions.None, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"^cat\s+dog", "cat \n\n\n dog", RegexOptions.Multiline, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"mouse\s\n^cat\s+dog", "mouse\n\ncat \n\n\n dog", RegexOptions.Multiline, new string[] { "mouse\n\ncat \n\n\n dog" } }; yield return new object[] { engine, null, @"^cat\s+dog", "cat \n\n\n dog", RegexOptions.ECMAScript, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"^(cat)\s+(dog)", "cat \n\n\n dog", RegexOptions.None, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"^(cat)\s+(dog)", "cat \n\n\n dog", RegexOptions.Multiline, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(mouse)\s\n^(cat)\s+(dog)", "mouse\n\ncat \n\n\n dog", RegexOptions.Multiline, new string[] { "mouse\n\ncat \n\n\n dog", "mouse", "cat", "dog" } }; yield return new object[] { engine, null, @"^(cat)\s+(dog)", "cat \n\n\n dog", RegexOptions.ECMAScript, new string[] { "cat \n\n\n dog", "cat", "dog" } }; //\Z yield return new object[] { engine, null, @"cat\s+dog\Z", "cat \n\n\n dog", RegexOptions.None, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"cat\s+dog\Z", "cat \n\n\n dog", RegexOptions.Multiline, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"cat\s+dog\Z", "cat \n\n\n dog", RegexOptions.ECMAScript, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"cat\s+dog\Z", "cat \n\n\n dog\n", RegexOptions.None, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"cat\s+dog\Z", "cat \n\n\n dog\n", RegexOptions.Multiline, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"cat\s+dog\Z", "cat \n\n\n dog\n", RegexOptions.ECMAScript, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"(cat)\s+(dog)\Z", "cat \n\n\n dog", RegexOptions.None, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(cat)\s+(dog)\Z", "cat \n\n\n dog", RegexOptions.Multiline, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(cat)\s+(dog)\Z", "cat \n\n\n dog", RegexOptions.ECMAScript, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(cat)\s+(dog)\Z", "cat \n\n\n dog\n", RegexOptions.None, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(cat)\s+(dog)\Z", "cat \n\n\n dog\n", RegexOptions.Multiline, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(cat)\s+(dog)\Z", "cat \n\n\n dog\n", RegexOptions.ECMAScript, new string[] { "cat \n\n\n dog", "cat", "dog" } }; //\z yield return new object[] { engine, null, @"cat\s+dog\z", "cat \n\n\n dog", RegexOptions.None, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"cat\s+dog\z", "cat \n\n\n dog", RegexOptions.Multiline, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"cat\s+dog\z", "cat \n\n\n dog", RegexOptions.ECMAScript, new string[] { "cat \n\n\n dog" } }; yield return new object[] { engine, null, @"(cat)\s+(dog)\z", "cat \n\n\n dog", RegexOptions.None, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(cat)\s+(dog)\z", "cat \n\n\n dog", RegexOptions.Multiline, new string[] { "cat \n\n\n dog", "cat", "dog" } }; yield return new object[] { engine, null, @"(cat)\s+(dog)\z", "cat \n\n\n dog", RegexOptions.ECMAScript, new string[] { "cat \n\n\n dog", "cat", "dog" } }; //\b yield return new object[] { engine, null, @"\bcat\b", "cat", RegexOptions.None, new string[] { "cat" } }; yield return new object[] { engine, null, @"\bcat\b", "dog cat mouse", RegexOptions.None, new string[] { "cat" } }; yield return new object[] { engine, null, @"\bcat\b", "cat", RegexOptions.ECMAScript, new string[] { "cat" } }; yield return new object[] { engine, null, @"\bcat\b", "dog cat mouse", RegexOptions.ECMAScript, new string[] { "cat" } }; yield return new object[] { engine, null, @".*\bcat\b", "cat", RegexOptions.None, new string[] { "cat" } }; yield return new object[] { engine, null, @".*\bcat\b", "dog cat mouse", RegexOptions.None, new string[] { "dog cat" } }; yield return new object[] { engine, null, @".*\bcat\b", "cat", RegexOptions.ECMAScript, new string[] { "cat" } }; yield return new object[] { engine, null, @".*\bcat\b", "dog cat mouse", RegexOptions.ECMAScript, new string[] { "dog cat" } }; yield return new object[] { engine, null, @"\b@cat", "123START123@catEND", RegexOptions.None, new string[] { "@cat" } }; yield return new object[] { engine, null, @"\b\<cat", "123START123<catEND", RegexOptions.None, new string[] { "<cat" } }; yield return new object[] { engine, null, @"\b,cat", "satwe,,,START,catEND", RegexOptions.None, new string[] { ",cat" } }; yield return new object[] { engine, null, @"\b\[cat", "`12START123[catEND", RegexOptions.None, new string[] { "[cat" } }; //\B yield return new object[] { engine, null, @"\Bcat\B", "dogcatmouse", RegexOptions.None, new string[] { "cat" } }; yield return new object[] { engine, null, @"dog\Bcat\B", "dogcatmouse", RegexOptions.None, new string[] { "dogcat" } }; yield return new object[] { engine, null, @".*\Bcat\B", "dogcatmouse", RegexOptions.None, new string[] { "dogcat" } }; yield return new object[] { engine, null, @"\Bcat\B", "dogcatmouse", RegexOptions.ECMAScript, new string[] { "cat" } }; yield return new object[] { engine, null, @"dog\Bcat\B", "dogcatmouse", RegexOptions.ECMAScript, new string[] { "dogcat" } }; yield return new object[] { engine, null, @".*\Bcat\B", "dogcatmouse", RegexOptions.ECMAScript, new string[] { "dogcat" } }; yield return new object[] { engine, null, @"\B@cat", "123START123;@catEND", RegexOptions.None, new string[] { "@cat" } }; yield return new object[] { engine, null, @"\B\<cat", "123START123'<catEND", RegexOptions.None, new string[] { "<cat" } }; yield return new object[] { engine, null, @"\B,cat", "satwe,,,START',catEND", RegexOptions.None, new string[] { ",cat" } }; yield return new object[] { engine, null, @"\B\[cat", "`12START123'[catEND", RegexOptions.None, new string[] { "[cat" } }; // \w matching \p{Lm} (Letter, Modifier) yield return new object[] { engine, null, @"\w+\s+\w+", "cat\u02b0 dog\u02b1", RegexOptions.None, new string[] { "cat\u02b0 dog\u02b1" } }; yield return new object[] { engine, null, @"cat\w+\s+dog\w+", "STARTcat\u30FC dog\u3005END", RegexOptions.None, new string[] { "cat\u30FC dog\u3005END" } }; yield return new object[] { engine, null, @"cat\w+\s+dog\w+", "STARTcat\uff9e dog\uff9fEND", RegexOptions.None, new string[] { "cat\uff9e dog\uff9fEND" } }; yield return new object[] { engine, null, @"(\w+)\s+(\w+)", "cat\u02b0 dog\u02b1", RegexOptions.None, new string[] { "cat\u02b0 dog\u02b1", "cat\u02b0", "dog\u02b1" } }; yield return new object[] { engine, null, @"(cat\w+)\s+(dog\w+)", "STARTcat\u30FC dog\u3005END", RegexOptions.None, new string[] { "cat\u30FC dog\u3005END", "cat\u30FC", "dog\u3005END" } }; yield return new object[] { engine, null, @"(cat\w+)\s+(dog\w+)", "STARTcat\uff9e dog\uff9fEND", RegexOptions.None, new string[] { "cat\uff9e dog\uff9fEND", "cat\uff9e", "dog\uff9fEND" } }; // Positive and negative character classes [a-c]|[^b-c] yield return new object[] { engine, null, @"[^a]|d", "d", RegexOptions.None, new string[] { "d" } }; yield return new object[] { engine, null, @"([^a]|[d])*", "Hello Worlddf", RegexOptions.None, new string[] { "Hello Worlddf", "f" } }; yield return new object[] { engine, null, @"([^{}]|\n)+", "{{{{Hello\n World \n}END", RegexOptions.None, new string[] { "Hello\n World \n", "\n" } }; yield return new object[] { engine, null, @"([a-d]|[^abcd])+", "\tonce\n upon\0 a- ()*&^%#time?", RegexOptions.None, new string[] { "\tonce\n upon\0 a- ()*&^%#time?", "?" } }; yield return new object[] { engine, null, @"([^a]|[a])*", "once upon a time", RegexOptions.None, new string[] { "once upon a time", "e" } }; yield return new object[] { engine, null, @"([a-d]|[^abcd]|[x-z]|^wxyz])+", "\tonce\n upon\0 a- ()*&^%#time?", RegexOptions.None, new string[] { "\tonce\n upon\0 a- ()*&^%#time?", "?" } }; yield return new object[] { engine, null, @"([a-d]|[e-i]|[^e]|wxyz])+", "\tonce\n upon\0 a- ()*&^%#time?", RegexOptions.None, new string[] { "\tonce\n upon\0 a- ()*&^%#time?", "?" } }; // Canonical and noncanonical char class, where one group is in it's // simplest form [a-e] and another is more complex. yield return new object[] { engine, null, @"^(([^b]+ )|(.* ))$", "aaa ", RegexOptions.None, new string[] { "aaa ", "aaa ", "aaa ", "" } }; yield return new object[] { engine, null, @"^(([^b]+ )|(.*))$", "aaa", RegexOptions.None, new string[] { "aaa", "aaa", "", "aaa" } }; yield return new object[] { engine, null, @"^(([^b]+ )|(.* ))$", "bbb ", RegexOptions.None, new string[] { "bbb ", "bbb ", "", "bbb " } }; yield return new object[] { engine, null, @"^(([^b]+ )|(.*))$", "bbb", RegexOptions.None, new string[] { "bbb", "bbb", "", "bbb" } }; yield return new object[] { engine, null, @"^((a*)|(.*))$", "aaa", RegexOptions.None, new string[] { "aaa", "aaa", "aaa", "" } }; yield return new object[] { engine, null, @"^((a*)|(.*))$", "aaabbb", RegexOptions.None, new string[] { "aaabbb", "aaabbb", "", "aaabbb" } }; yield return new object[] { engine, null, @"(([0-9])|([a-z])|([A-Z]))*", "{hello 1234567890 world}", RegexOptions.None, new string[] { "", "", "", "", "" } }; yield return new object[] { engine, null, @"(([0-9])|([a-z])|([A-Z]))+", "{hello 1234567890 world}", RegexOptions.None, new string[] { "hello", "o", "", "o", "" } }; yield return new object[] { engine, null, @"(([0-9])|([a-z])|([A-Z]))*", "{HELLO 1234567890 world}", RegexOptions.None, new string[] { "", "", "", "", "" } }; yield return new object[] { engine, null, @"(([0-9])|([a-z])|([A-Z]))+", "{HELLO 1234567890 world}", RegexOptions.None, new string[] { "HELLO", "O", "", "", "O" } }; yield return new object[] { engine, null, @"(([0-9])|([a-z])|([A-Z]))*", "{1234567890 hello world}", RegexOptions.None, new string[] { "", "", "", "", "" } }; yield return new object[] { engine, null, @"(([0-9])|([a-z])|([A-Z]))+", "{1234567890 hello world}", RegexOptions.None, new string[] { "1234567890", "0", "0", "", "" } }; yield return new object[] { engine, null, @"^(([a-d]*)|([a-z]*))$", "aaabbbcccdddeeefff", RegexOptions.None, new string[] { "aaabbbcccdddeeefff", "aaabbbcccdddeeefff", "", "aaabbbcccdddeeefff" } }; yield return new object[] { engine, null, @"^(([d-f]*)|([c-e]*))$", "dddeeeccceee", RegexOptions.None, new string[] { "dddeeeccceee", "dddeeeccceee", "", "dddeeeccceee" } }; yield return new object[] { engine, null, @"^(([c-e]*)|([d-f]*))$", "dddeeeccceee", RegexOptions.None, new string[] { "dddeeeccceee", "dddeeeccceee", "dddeeeccceee", "" } }; yield return new object[] { engine, null, @"(([a-d]*)|([a-z]*))", "aaabbbcccdddeeefff", RegexOptions.None, new string[] { "aaabbbcccddd", "aaabbbcccddd", "aaabbbcccddd", "" } }; yield return new object[] { engine, null, @"(([d-f]*)|([c-e]*))", "dddeeeccceee", RegexOptions.None, new string[] { "dddeee", "dddeee", "dddeee", "" } }; yield return new object[] { engine, null, @"(([c-e]*)|([d-f]*))", "dddeeeccceee", RegexOptions.None, new string[] { "dddeeeccceee", "dddeeeccceee", "dddeeeccceee", "" } }; yield return new object[] { engine, null, @"(([a-d]*)|(.*))", "aaabbbcccdddeeefff", RegexOptions.None, new string[] { "aaabbbcccddd", "aaabbbcccddd", "aaabbbcccddd", "" } }; yield return new object[] { engine, null, @"(([d-f]*)|(.*))", "dddeeeccceee", RegexOptions.None, new string[] { "dddeee", "dddeee", "dddeee", "" } }; yield return new object[] { engine, null, @"(([c-e]*)|(.*))", "dddeeeccceee", RegexOptions.None, new string[] { "dddeeeccceee", "dddeeeccceee", "dddeeeccceee", "" } }; // \p{Pi} (Punctuation Initial quote) \p{Pf} (Punctuation Final quote) yield return new object[] { engine, null, @"\p{Pi}(\w*)\p{Pf}", "\u00ABCat\u00BB \u00BBDog\u00AB'", RegexOptions.None, new string[] { "\u00ABCat\u00BB", "Cat" } }; yield return new object[] { engine, null, @"\p{Pi}(\w*)\p{Pf}", "\u2018Cat\u2019 \u2019Dog\u2018'", RegexOptions.None, new string[] { "\u2018Cat\u2019", "Cat" } }; // ECMAScript yield return new object[] { engine, null, @"(?<cat>cat)\s+(?<dog>dog)\s+\123\s+\234", "asdfcat dog cat23 dog34eia", RegexOptions.ECMAScript, new string[] { "cat dog cat23 dog34", "cat", "dog" } }; // Balanced Matching yield return new object[] { engine, null, @"<div> (?> <div>(?<DEPTH>) | </div> (?<-DEPTH>) | .? )*? (?(DEPTH)(?!)) </div>", "<div>this is some <div>red</div> text</div></div></div>", RegexOptions.IgnorePatternWhitespace, new string[] { "<div>this is some <div>red</div> text</div>", "" } }; yield return new object[] { engine, null, @"( ((?'open'<+)[^<>]*)+ ((?'close-open'>+)[^<>]*)+ )+", "<01deep_01<02deep_01<03deep_01>><02deep_02><02deep_03<03deep_03>>>", RegexOptions.IgnorePatternWhitespace, new string[] { "<01deep_01<02deep_01<03deep_01>><02deep_02><02deep_03<03deep_03>>>", "<02deep_03<03deep_03>>>", "<03deep_03", ">>>", "<", "03deep_03" } }; yield return new object[] { engine, null, @"( (?<start><)? [^<>]? (?<end-start>>)? )*", "<01deep_01<02deep_01<03deep_01>><02deep_02><02deep_03<03deep_03>>>", RegexOptions.IgnorePatternWhitespace, new string[] { "<01deep_01<02deep_01<03deep_01>><02deep_02><02deep_03<03deep_03>>>", "", "", "01deep_01<02deep_01<03deep_01>><02deep_02><02deep_03<03deep_03>>" } }; yield return new object[] { engine, null, @"( (?<start><[^/<>]*>)? [^<>]? (?<end-start></[^/<>]*>)? )*", "<b><a>Cat</a></b>", RegexOptions.IgnorePatternWhitespace, new string[] { "<b><a>Cat</a></b>", "", "", "<a>Cat</a>" } }; yield return new object[] { engine, null, @"( (?<start><(?<TagName>[^/<>]*)>)? [^<>]? (?<end-start></\k<TagName>>)? )*", "<b>cat</b><a>dog</a>", RegexOptions.IgnorePatternWhitespace, new string[] { "<b>cat</b><a>dog</a>", "", "", "a", "dog" } }; // Balanced Matching With Backtracking yield return new object[] { engine, null, @"( (?<start><[^/<>]*>)? .? (?<end-start></[^/<>]*>)? )* (?(start)(?!)) ", "<b><a>Cat</a></b><<<<c>>>><<d><e<f>><g><<<>>>>", RegexOptions.IgnorePatternWhitespace, new string[] { "<b><a>Cat</a></b><<<<c>>>><<d><e<f>><g><<<>>>>", "", "", "<a>Cat" } }; // Character Classes and Lazy quantifier yield return new object[] { engine, null, @"([0-9]+?)([\w]+?)", "55488aheiaheiad", RegexOptions.ECMAScript, new string[] { "55", "5", "5" } }; yield return new object[] { engine, null, @"([0-9]+?)([a-z]+?)", "55488aheiaheiad", RegexOptions.ECMAScript, new string[] { "55488a", "55488", "a" } }; // Miscellaneous/Regression scenarios yield return new object[] { engine, null, @"(?<openingtag>1)(?<content>.*?)(?=2)", "1" + Environment.NewLine + "<Projecaa DefaultTargets=\"x\"/>" + Environment.NewLine + "2", RegexOptions.Singleline | RegexOptions.ExplicitCapture, new string[] { "1" + Environment.NewLine + "<Projecaa DefaultTargets=\"x\"/>" + Environment.NewLine, "1", Environment.NewLine + "<Projecaa DefaultTargets=\"x\"/>"+ Environment.NewLine } }; yield return new object[] { engine, null, @"\G<%#(?<code>.*?)?%>", @"<%# DataBinder.Eval(this, ""MyNumber"") %>", RegexOptions.Singleline, new string[] { @"<%# DataBinder.Eval(this, ""MyNumber"") %>", @" DataBinder.Eval(this, ""MyNumber"") " } }; // Nested Quantifiers yield return new object[] { engine, null, @"^[abcd]{0,0x10}*$", "a{0,0x10}}}", RegexOptions.None, new string[] { "a{0,0x10}}}" } }; // Lazy operator Backtracking yield return new object[] { engine, null, @"http://([a-zA-z0-9\-]*\.?)*?(:[0-9]*)??/", "http://www.msn.com/", RegexOptions.IgnoreCase, new string[] { "http://www.msn.com/", "com", string.Empty } }; yield return new object[] { engine, null, @"http://([a-zA-Z0-9\-]*\.?)*?/", @"http://www.google.com/", RegexOptions.IgnoreCase, new string[] { "http://www.google.com/", "com" } }; yield return new object[] { engine, null, @"([a-z]*?)([\w])", "cat", RegexOptions.IgnoreCase, new string[] { "c", string.Empty, "c" } }; yield return new object[] { engine, null, @"^([a-z]*?)([\w])$", "cat", RegexOptions.IgnoreCase, new string[] { "cat", "ca", "t" } }; // Backtracking yield return new object[] { engine, null, @"([a-z]*)([\w])", "cat", RegexOptions.IgnoreCase, new string[] { "cat", "ca", "t" } }; yield return new object[] { engine, null, @"^([a-z]*)([\w])$", "cat", RegexOptions.IgnoreCase, new string[] { "cat", "ca", "t" } }; // Backtracking with multiple (.*) groups -- important ASP.NET scenario yield return new object[] { engine, null, @"(.*)/(.*).aspx", "/.aspx", RegexOptions.None, new string[] { "/.aspx", string.Empty, string.Empty } }; yield return new object[] { engine, null, @"(.*)/(.*).aspx", "/homepage.aspx", RegexOptions.None, new string[] { "/homepage.aspx", string.Empty, "homepage" } }; yield return new object[] { engine, null, @"(.*)/(.*).aspx", "pages/.aspx", RegexOptions.None, new string[] { "pages/.aspx", "pages", string.Empty } }; yield return new object[] { engine, null, @"(.*)/(.*).aspx", "pages/homepage.aspx", RegexOptions.None, new string[] { "pages/homepage.aspx", "pages", "homepage" } }; yield return new object[] { engine, null, @"(.*)/(.*).aspx", "/pages/homepage.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx", "/pages", "homepage" } }; yield return new object[] { engine, null, @"(.*)/(.*).aspx", "/pages/homepage/index.aspx", RegexOptions.None, new string[] { "/pages/homepage/index.aspx", "/pages/homepage", "index" } }; yield return new object[] { engine, null, @"(.*)/(.*).aspx", "/pages/homepage.aspx/index.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx/index.aspx", "/pages/homepage.aspx", "index" } }; yield return new object[] { engine, null, @"(.*)/(.*)/(.*).aspx", "/pages/homepage.aspx/index.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx/index.aspx", "/pages", "homepage.aspx", "index" } }; // Backtracking with multiple (.+) groups yield return new object[] { engine, null, @"(.+)/(.+).aspx", "pages/homepage.aspx", RegexOptions.None, new string[] { "pages/homepage.aspx", "pages", "homepage" } }; yield return new object[] { engine, null, @"(.+)/(.+).aspx", "/pages/homepage.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx", "/pages", "homepage" } }; yield return new object[] { engine, null, @"(.+)/(.+).aspx", "/pages/homepage/index.aspx", RegexOptions.None, new string[] { "/pages/homepage/index.aspx", "/pages/homepage", "index" } }; yield return new object[] { engine, null, @"(.+)/(.+).aspx", "/pages/homepage.aspx/index.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx/index.aspx", "/pages/homepage.aspx", "index" } }; yield return new object[] { engine, null, @"(.+)/(.+)/(.+).aspx", "/pages/homepage.aspx/index.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx/index.aspx", "/pages", "homepage.aspx", "index" } }; // Backtracking with (.+) group followed by (.*) yield return new object[] { engine, null, @"(.+)/(.*).aspx", "pages/.aspx", RegexOptions.None, new string[] { "pages/.aspx", "pages", string.Empty } }; yield return new object[] { engine, null, @"(.+)/(.*).aspx", "pages/homepage.aspx", RegexOptions.None, new string[] { "pages/homepage.aspx", "pages", "homepage" } }; yield return new object[] { engine, null, @"(.+)/(.*).aspx", "/pages/homepage.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx", "/pages", "homepage" } }; yield return new object[] { engine, null, @"(.+)/(.*).aspx", "/pages/homepage/index.aspx", RegexOptions.None, new string[] { "/pages/homepage/index.aspx", "/pages/homepage", "index" } }; yield return new object[] { engine, null, @"(.+)/(.*).aspx", "/pages/homepage.aspx/index.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx/index.aspx", "/pages/homepage.aspx", "index" } }; yield return new object[] { engine, null, @"(.+)/(.*)/(.*).aspx", "/pages/homepage.aspx/index.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx/index.aspx", "/pages", "homepage.aspx", "index" } }; // Backtracking with (.*) group followed by (.+) yield return new object[] { engine, null, @"(.*)/(.+).aspx", "/homepage.aspx", RegexOptions.None, new string[] { "/homepage.aspx", string.Empty, "homepage" } }; yield return new object[] { engine, null, @"(.*)/(.+).aspx", "pages/homepage.aspx", RegexOptions.None, new string[] { "pages/homepage.aspx", "pages", "homepage" } }; yield return new object[] { engine, null, @"(.*)/(.+).aspx", "/pages/homepage.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx", "/pages", "homepage" } }; yield return new object[] { engine, null, @"(.*)/(.+).aspx", "/pages/homepage/index.aspx", RegexOptions.None, new string[] { "/pages/homepage/index.aspx", "/pages/homepage", "index" } }; yield return new object[] { engine, null, @"(.*)/(.+).aspx", "/pages/homepage.aspx/index.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx/index.aspx", "/pages/homepage.aspx", "index" } }; yield return new object[] { engine, null, @"(.*)/(.+)/(.+).aspx", "/pages/homepage.aspx/index.aspx", RegexOptions.None, new string[] { "/pages/homepage.aspx/index.aspx", "/pages", "homepage.aspx", "index" } }; // Captures inside varying constructs with backtracking needing to uncapture yield return new object[] { engine, null, @"a(bc)d|abc(e)", "abce", RegexOptions.None, new string[] { "abce", "", "e" } }; // alternation yield return new object[] { engine, null, @"((ab){2}cd)*", "ababcdababcdababc", RegexOptions.None, new string[] { "ababcdababcd", "ababcd", "ab" } }; // loop yield return new object[] { engine, null, @"(ab(?=(\w)\w))*a", "aba", RegexOptions.None, new string[] { "a", "", "" } }; // positive lookahead in a loop yield return new object[] { engine, null, @"(ab(?=(\w)\w))*a", "ababa", RegexOptions.None, new string[] { "aba", "ab", "a" } }; // positive lookahead in a loop yield return new object[] { engine, null, @"(ab(?=(\w)\w))*a", "abababa", RegexOptions.None, new string[] { "ababa", "ab", "a" } }; // positive lookahead in a loop yield return new object[] { engine, null, @"\w\w(?!(\d)\d)", "aa..", RegexOptions.None, new string[] { "aa", "" } }; // negative lookahead yield return new object[] { engine, null, @"\w\w(?!(\d)\d)", "aa.3", RegexOptions.None, new string[] { "aa", "" } }; // negative lookahead // Quantifiers yield return new object[] { engine, null, @"a*", "", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"a*", "a", RegexOptions.None, new string[] { "a" } }; yield return new object[] { engine, null, @"a*", "aa", RegexOptions.None, new string[] { "aa" } }; yield return new object[] { engine, null, @"a*", "aaa", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"a*?", "", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"a*?", "a", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"a*?", "aa", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"a+?", "aa", RegexOptions.None, new string[] { "a" } }; yield return new object[] { engine, null, @"a{1,", "a{1,", RegexOptions.None, new string[] { "a{1," } }; yield return new object[] { engine, null, @"a{1,3}", "aaaaa", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"a{1,3}?", "aaaaa", RegexOptions.None, new string[] { "a" } }; yield return new object[] { engine, null, @"a{2,2}", "aaaaa", RegexOptions.None, new string[] { "aa" } }; yield return new object[] { engine, null, @"a{2,2}?", "aaaaa", RegexOptions.None, new string[] { "aa" } }; yield return new object[] { engine, null, @".{1,3}", "bb\nba", RegexOptions.None, new string[] { "bb" } }; yield return new object[] { engine, null, @".{1,3}?", "bb\nba", RegexOptions.None, new string[] { "b" } }; yield return new object[] { engine, null, @".{2,2}", "bbb\nba", RegexOptions.None, new string[] { "bb" } }; yield return new object[] { engine, null, @".{2,2}?", "bbb\nba", RegexOptions.None, new string[] { "bb" } }; yield return new object[] { engine, null, @"[abc]{1,3}", "ccaba", RegexOptions.None, new string[] { "cca" } }; yield return new object[] { engine, null, @"[abc]{1,3}?", "ccaba", RegexOptions.None, new string[] { "c" } }; yield return new object[] { engine, null, @"[abc]{2,2}", "ccaba", RegexOptions.None, new string[] { "cc" } }; yield return new object[] { engine, null, @"[abc]{2,2}?", "ccaba", RegexOptions.None, new string[] { "cc" } }; yield return new object[] { engine, null, @"(?:[abc]def){1,3}xyz", "cdefxyz", RegexOptions.None, new string[] { "cdefxyz" } }; yield return new object[] { engine, null, @"(?:[abc]def){1,3}xyz", "adefbdefcdefxyz", RegexOptions.None, new string[] { "adefbdefcdefxyz" } }; yield return new object[] { engine, null, @"(?:[abc]def){1,3}?xyz", "cdefxyz", RegexOptions.None, new string[] { "cdefxyz" } }; yield return new object[] { engine, null, @"(?:[abc]def){1,3}?xyz", "adefbdefcdefxyz", RegexOptions.None, new string[] { "adefbdefcdefxyz" } }; yield return new object[] { engine, null, @"(?:[abc]def){2,2}xyz", "adefbdefcdefxyz", RegexOptions.None, new string[] { "bdefcdefxyz" } }; yield return new object[] { engine, null, @"(?:[abc]def){2,2}?xyz", "adefbdefcdefxyz", RegexOptions.None, new string[] { "bdefcdefxyz" } }; foreach (string prefix in new[] { "", "xyz" }) { yield return new object[] { engine, null, prefix + @"(?:[abc]def){1,3}", prefix + "cdef", RegexOptions.None, new string[] { prefix + "cdef" } }; yield return new object[] { engine, null, prefix + @"(?:[abc]def){1,3}", prefix + "cdefadefbdef", RegexOptions.None, new string[] { prefix + "cdefadefbdef" } }; yield return new object[] { engine, null, prefix + @"(?:[abc]def){1,3}", prefix + "cdefadefbdefadef", RegexOptions.None, new string[] { prefix + "cdefadefbdef" } }; yield return new object[] { engine, null, prefix + @"(?:[abc]def){1,3}?", prefix + "cdef", RegexOptions.None, new string[] { prefix + "cdef" } }; yield return new object[] { engine, null, prefix + @"(?:[abc]def){1,3}?", prefix + "cdefadefbdef", RegexOptions.None, new string[] { prefix + "cdef" } }; yield return new object[] { engine, null, prefix + @"(?:[abc]def){2,2}", prefix + "cdefadefbdefadef", RegexOptions.None, new string[] { prefix + "cdefadef" } }; yield return new object[] { engine, null, prefix + @"(?:[abc]def){2,2}?", prefix + "cdefadefbdefadef", RegexOptions.None, new string[] { prefix + "cdefadef" } }; } yield return new object[] { engine, null, @"(cat){", "cat{", RegexOptions.None, new string[] { "cat{", "cat" } }; yield return new object[] { engine, null, @"(cat){}", "cat{}", RegexOptions.None, new string[] { "cat{}", "cat" } }; yield return new object[] { engine, null, @"(cat){,", "cat{,", RegexOptions.None, new string[] { "cat{,", "cat" } }; yield return new object[] { engine, null, @"(cat){,}", "cat{,}", RegexOptions.None, new string[] { "cat{,}", "cat" } }; yield return new object[] { engine, null, @"(cat){cat}", "cat{cat}", RegexOptions.None, new string[] { "cat{cat}", "cat" } }; yield return new object[] { engine, null, @"(cat){cat,5}", "cat{cat,5}", RegexOptions.None, new string[] { "cat{cat,5}", "cat" } }; yield return new object[] { engine, null, @"(cat){5,dog}", "cat{5,dog}", RegexOptions.None, new string[] { "cat{5,dog}", "cat" } }; yield return new object[] { engine, null, @"(cat){cat,dog}", "cat{cat,dog}", RegexOptions.None, new string[] { "cat{cat,dog}", "cat" } }; yield return new object[] { engine, null, @"(cat){,}?", "cat{,}?", RegexOptions.None, new string[] { "cat{,}", "cat" } }; yield return new object[] { engine, null, @"(cat){cat}?", "cat{cat}?", RegexOptions.None, new string[] { "cat{cat}", "cat" } }; yield return new object[] { engine, null, @"(cat){cat,5}?", "cat{cat,5}?", RegexOptions.None, new string[] { "cat{cat,5}", "cat" } }; yield return new object[] { engine, null, @"(cat){5,dog}?", "cat{5,dog}?", RegexOptions.None, new string[] { "cat{5,dog}", "cat" } }; yield return new object[] { engine, null, @"(cat){cat,dog}?", "cat{cat,dog}?", RegexOptions.None, new string[] { "cat{cat,dog}", "cat" } }; // Atomic subexpressions // Implicitly upgrading (or not) oneloop to be atomic yield return new object[] { engine, null, @"a*b", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*b+", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*b+?", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*(?>b+)", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*[^a]", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*[^a]+", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*[^a]+?", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*(?>[^a]+)", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*bcd", "aaabcd", RegexOptions.None, new string[] { "aaabcd" } }; yield return new object[] { engine, null, @"a*[bcd]", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*[bcd]+", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*[bcd]+?", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*(?>[bcd]+)", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*[bcd]{1,3}", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"a*([bcd]ab|[bef]cd){1,3}", "aaababecdcac", RegexOptions.ExplicitCapture, new string[] { "aaababecd" } }; yield return new object[] { engine, null, @"a*([bcd]|[aef]){1,3}", "befb", RegexOptions.ExplicitCapture, new string[] { "bef" } }; // can't upgrade yield return new object[] { engine, null, @"a*$", "aaa", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"a*$", "aaa", RegexOptions.Multiline, new string[] { "aaa" } }; yield return new object[] { engine, null, @"a*\b", "aaa bbb", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"a*\b", "aaa bbb", RegexOptions.ECMAScript, new string[] { "aaa" } }; yield return new object[] { engine, null, @"@*\B", "@@@", RegexOptions.None, new string[] { "@@@" } }; yield return new object[] { engine, null, @"@*\B", "@@@", RegexOptions.ECMAScript, new string[] { "@@@" } }; yield return new object[] { engine, null, @"(?:abcd*|efgh)i", "efghi", RegexOptions.None, new string[] { "efghi" } }; yield return new object[] { engine, null, @"(?:abcd|efgh*)i", "efgi", RegexOptions.None, new string[] { "efgi" } }; yield return new object[] { engine, null, @"(?:abcd|efghj{2,}|j[klm]o+)i", "efghjjjjji", RegexOptions.None, new string[] { "efghjjjjji" } }; yield return new object[] { engine, null, @"(?:abcd|efghi{2,}|j[klm]o+)i", "efghiii", RegexOptions.None, new string[] { "efghiii" } }; yield return new object[] { engine, null, @"(?:abcd|efghi{2,}|j[klm]o+)i", "efghiiiiiiii", RegexOptions.None, new string[] { "efghiiiiiiii" } }; yield return new object[] { engine, null, @"a?ba?ba?ba?b", "abbabab", RegexOptions.None, new string[] { "abbabab" } }; yield return new object[] { engine, null, @"a?ba?ba?ba?b", "abBAbab", RegexOptions.IgnoreCase, new string[] { "abBAbab" } }; // Implicitly upgrading (or not) notoneloop to be atomic yield return new object[] { engine, null, @"[^b]*b", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[^b]*b+", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[^b]*b+?", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[^b]*(?>b+)", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[^b]*bac", "aaabac", RegexOptions.None, new string[] { "aaabac" } }; yield return new object[] { engine, null, @"[^b]*", "aaa", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"(?:abc[^b]*|efgh)i", "efghi", RegexOptions.None, new string[] { "efghi" } }; // can't upgrade yield return new object[] { engine, null, @"(?:abcd|efg[^b]*)b", "efgb", RegexOptions.None, new string[] { "efgb" } }; yield return new object[] { engine, null, @"(?:abcd|efg[^b]*)i", "efgi", RegexOptions.None, new string[] { "efgi" } }; // can't upgrade yield return new object[] { engine, null, @"[^a]?a[^a]?a[^a]?a[^a]?a", "baababa", RegexOptions.None, new string[] { "baababa" } }; yield return new object[] { engine, null, @"[^a]?a[^a]?a[^a]?a[^a]?a", "BAababa", RegexOptions.IgnoreCase, new string[] { "BAababa" } }; // Implicitly upgrading (or not) setloop to be atomic yield return new object[] { engine, null, @"[ac]*", "aaa", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"[ac]*b", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*b+", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*b+?", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*(?>b+)", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*[^a]", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*[^a]+", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*[^a]+?", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*(?>[^a]+)", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*bcd", "aaabcd", RegexOptions.None, new string[] { "aaabcd" } }; yield return new object[] { engine, null, @"[ac]*[bd]", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*[bd]+", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*[bd]+?", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*(?>[bd]+)", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*[bd]{1,3}", "aaab", RegexOptions.None, new string[] { "aaab" } }; yield return new object[] { engine, null, @"[ac]*$", "aaa", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"[ac]*$", "aaa", RegexOptions.Multiline, new string[] { "aaa" } }; yield return new object[] { engine, null, @"[ac]*\b", "aaa bbb", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"[ac]*\b", "aaa bbb", RegexOptions.ECMAScript, new string[] { "aaa" } }; yield return new object[] { engine, null, @"[@']*\B", "@@@", RegexOptions.None, new string[] { "@@@" } }; yield return new object[] { engine, null, @"[@']*\B", "@@@", RegexOptions.ECMAScript, new string[] { "@@@" } }; yield return new object[] { engine, null, @".*.", "@@@", RegexOptions.Singleline, new string[] { "@@@" } }; yield return new object[] { engine, null, @"(?:abcd|efg[hij]*)h", "efgh", RegexOptions.None, new string[] { "efgh" } }; // can't upgrade yield return new object[] { engine, null, @"(?:abcd|efg[hij]*)ih", "efgjih", RegexOptions.None, new string[] { "efgjih" } }; // can't upgrade yield return new object[] { engine, null, @"(?:abcd|efg[hij]*)k", "efgjk", RegexOptions.None, new string[] { "efgjk" } }; yield return new object[] { engine, null, @"[ace]?b[ace]?b[ace]?b[ace]?b", "cbbabeb", RegexOptions.None, new string[] { "cbbabeb" } }; yield return new object[] { engine, null, @"[ace]?b[ace]?b[ace]?b[ace]?b", "cBbAbEb", RegexOptions.IgnoreCase, new string[] { "cBbAbEb" } }; yield return new object[] { engine, null, @"a[^wz]*w", "abcdcdcdwz", RegexOptions.None, new string[] { "abcdcdcdw" } }; yield return new object[] { engine, null, @"a[^wyz]*w", "abcdcdcdwz", RegexOptions.None, new string[] { "abcdcdcdw" } }; yield return new object[] { engine, null, @"a[^wyz]*W", "abcdcdcdWz", RegexOptions.IgnoreCase, new string[] { "abcdcdcdW" } }; // Implicitly upgrading (or not) concat loops to be atomic yield return new object[] { engine, null, @"(?:[ab]c[de]f)*", "", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"(?:[ab]c[de]f)*", "acdf", RegexOptions.None, new string[] { "acdf" } }; yield return new object[] { engine, null, @"(?:[ab]c[de]f)*", "acdfbcef", RegexOptions.None, new string[] { "acdfbcef" } }; yield return new object[] { engine, null, @"(?:[ab]c[de]f)*", "cdfbcef", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"(?:[ab]c[de]f)+", "cdfbcef", RegexOptions.None, new string[] { "bcef" } }; yield return new object[] { engine, null, @"(?:[ab]c[de]f)*", "bcefbcdfacfe", RegexOptions.None, new string[] { "bcefbcdf" } }; // Implicitly upgrading (or not) nested loops to be atomic yield return new object[] { engine, null, @"(?:a){3}", "aaaaaaaaa", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"(?:a){3}?", "aaaaaaaaa", RegexOptions.None, new string[] { "aaa" } }; yield return new object[] { engine, null, @"(?:a{2}){3}", "aaaaaaaaa", RegexOptions.None, new string[] { "aaaaaa" } }; yield return new object[] { engine, null, @"(?:a{2}?){3}?", "aaaaaaaaa", RegexOptions.None, new string[] { "aaaaaa" } }; yield return new object[] { engine, null, @"(?:(?:[ab]c[de]f){3}){2}", "acdfbcdfacefbcefbcefbcdfacdef", RegexOptions.None, new string[] { "acdfbcdfacefbcefbcefbcdf" } }; yield return new object[] { engine, null, @"(?:(?:[ab]c[de]f){3}hello){2}", "aaaaaacdfbcdfacefhellobcefbcefbcdfhellooooo", RegexOptions.None, new string[] { "acdfbcdfacefhellobcefbcefbcdfhello" } }; yield return new object[] { engine, null, @"CN=(.*[^,]+).*", "CN=localhost", RegexOptions.Singleline, new string[] { "CN=localhost", "localhost" } }; // Nested atomic yield return new object[] { engine, null, @"(?>abc[def]gh(i*))", "123abceghiii456", RegexOptions.None, new string[] { "abceghiii", "iii" } }; yield return new object[] { engine, null, @"(?>(?:abc)*)", "abcabcabc", RegexOptions.None, new string[] { "abcabcabc" } }; // Anchoring loops beginning with .* / .+ yield return new object[] { engine, null, @".*", "", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @".*", "\n\n\n\n", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @".*", "\n\n\n\n", RegexOptions.Singleline, new string[] { "\n\n\n\n" } }; yield return new object[] { engine, null, @".*[1a]", "\n\n\n\n1", RegexOptions.None, new string[] { "1" } }; yield return new object[] { engine, null, @"(?s).*(?-s)[1a]", "1\n\n\n\n", RegexOptions.None, new string[] { "1" } }; yield return new object[] { engine, null, @"(?s).*(?-s)[1a]", "\n\n\n\n1", RegexOptions.None, new string[] { "\n\n\n\n1" } }; yield return new object[] { engine, null, @".*|.*|.*", "", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @".*123|abc", "abc\n123", RegexOptions.None, new string[] { "abc" } }; yield return new object[] { engine, null, @".*123|abc", "abc\n123", RegexOptions.Singleline, new string[] { "abc\n123" } }; yield return new object[] { engine, null, @"abc|.*123", "abc\n123", RegexOptions.Singleline, new string[] { "abc" } }; yield return new object[] { engine, null, @".*", "\n", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @".*\n", "\n", RegexOptions.None, new string[] { "\n" } }; yield return new object[] { engine, null, @".*", "\n", RegexOptions.Singleline, new string[] { "\n" } }; yield return new object[] { engine, null, @".*\n", "\n", RegexOptions.Singleline, new string[] { "\n" } }; yield return new object[] { engine, null, @".*", "abc", RegexOptions.None, new string[] { "abc" } }; yield return new object[] { engine, null, @".*abc", "abc", RegexOptions.None, new string[] { "abc" } }; yield return new object[] { engine, null, @".*abc|ghi", "ghi", RegexOptions.None, new string[] { "ghi" } }; yield return new object[] { engine, null, @".*abc|.*ghi", "abcghi", RegexOptions.None, new string[] { "abc" } }; yield return new object[] { engine, null, @".*ghi|.*abc", "abcghi", RegexOptions.None, new string[] { "abcghi" } }; yield return new object[] { engine, null, @".*abc|.*ghi", "bcghi", RegexOptions.None, new string[] { "bcghi" } }; yield return new object[] { engine, null, @".*abc|.+c", " \n \n bc", RegexOptions.None, new string[] { " bc" } }; yield return new object[] { engine, null, @".*abc", "12345 abc", RegexOptions.None, new string[] { "12345 abc" } }; yield return new object[] { engine, null, @".*abc", "12345\n abc", RegexOptions.None, new string[] { " abc" } }; yield return new object[] { engine, null, @".*abc", "12345\n abc", RegexOptions.Singleline, new string[] { "12345\n abc" } }; yield return new object[] { engine, null, @"(.*)abc\1", "\n12345abc12345", RegexOptions.Singleline, new string[] { "12345abc12345", "12345" } }; yield return new object[] { engine, null, @".*\nabc", "\n123\nabc", RegexOptions.None, new string[] { "123\nabc" } }; yield return new object[] { engine, null, @".*\nabc", "\n123\nabc", RegexOptions.Singleline, new string[] { "\n123\nabc" } }; yield return new object[] { engine, null, @".*abc", "abc abc abc \nabc", RegexOptions.None, new string[] { "abc abc abc" } }; yield return new object[] { engine, null, @".*abc", "abc abc abc \nabc", RegexOptions.Singleline, new string[] { "abc abc abc \nabc" } }; yield return new object[] { engine, null, @".*?abc", "abc abc abc \nabc", RegexOptions.None, new string[] { "abc" } }; yield return new object[] { engine, null, @"[^\n]*abc", "123abc\n456abc\n789abc", RegexOptions.None, new string[] { "123abc" } }; yield return new object[] { engine, null, @"[^\n]*abc", "123abc\n456abc\n789abc", RegexOptions.Singleline, new string[] { "123abc" } }; yield return new object[] { engine, null, @"[^\n]*abc", "123ab\n456abc\n789abc", RegexOptions.None, new string[] { "456abc" } }; yield return new object[] { engine, null, @"[^\n]*abc", "123ab\n456abc\n789abc", RegexOptions.Singleline, new string[] { "456abc" } }; yield return new object[] { engine, null, @".+", "a", RegexOptions.None, new string[] { "a" } }; yield return new object[] { engine, null, @".+", "\nabc", RegexOptions.None, new string[] { "abc" } }; yield return new object[] { engine, null, @".+", "\n", RegexOptions.Singleline, new string[] { "\n" } }; yield return new object[] { engine, null, @".+", "\nabc", RegexOptions.Singleline, new string[] { "\nabc" } }; yield return new object[] { engine, null, @".+abc", "aaaabc", RegexOptions.None, new string[] { "aaaabc" } }; yield return new object[] { engine, null, @".+abc", "12345 abc", RegexOptions.None, new string[] { "12345 abc" } }; yield return new object[] { engine, null, @".+abc", "12345\n abc", RegexOptions.None, new string[] { " abc" } }; yield return new object[] { engine, null, @".+abc", "12345\n abc", RegexOptions.Singleline, new string[] { "12345\n abc" } }; yield return new object[] { engine, null, @"(.+)abc\1", "\n12345abc12345", RegexOptions.Singleline, new string[] { "12345abc12345", "12345" } }; // Unanchored .* yield return new object[] { engine, null, @"\A\s*(?<name>\w+)(\s*\((?<arguments>.*)\))?\s*\Z", "Match(Name)", RegexOptions.None, new string[] { "Match(Name)", "(Name)", "Match", "Name" } }; yield return new object[] { engine, null, @"\A\s*(?<name>\w+)(\s*\((?<arguments>.*)\))?\s*\Z", "Match(Na\nme)", RegexOptions.Singleline, new string[] { "Match(Na\nme)", "(Na\nme)", "Match", "Na\nme" } }; foreach (RegexOptions options in new[] { RegexOptions.None, RegexOptions.Singleline }) { yield return new object[] { engine, null, @"abcd.*", @"abcabcd", options, new string[] { "abcd" } }; yield return new object[] { engine, null, @"abcd.*", @"abcabcde", options, new string[] { "abcde" } }; yield return new object[] { engine, null, @"abcd.*", @"abcabcdefg", options, new string[] { "abcdefg" } }; yield return new object[] { engine, null, @"abcd(.*)", @"ababcd", options, new string[] { "abcd", "" } }; yield return new object[] { engine, null, @"abcd(.*)", @"aabcde", options, new string[] { "abcde", "e" } }; yield return new object[] { engine, null, @"abcd(.*)", @"abcabcdefg", options, new string[] { "abcdefg", "efg" } }; yield return new object[] { engine, null, @"abcd(.*)e", @"abcabcdefg", options, new string[] { "abcde", "" } }; yield return new object[] { engine, null, @"abcd(.*)f", @"abcabcdefg", options, new string[] { "abcdef", "e" } }; } // Grouping Constructs yield return new object[] { engine, null, @"()", "cat", RegexOptions.None, new string[] { string.Empty, string.Empty } }; yield return new object[] { engine, null, @"(?<cat>)", "cat", RegexOptions.None, new string[] { string.Empty, string.Empty } }; yield return new object[] { engine, null, @"(?'cat')", "cat", RegexOptions.None, new string[] { string.Empty, string.Empty } }; yield return new object[] { engine, null, @"(?:)", "cat", RegexOptions.None, new string[] { string.Empty } }; yield return new object[] { engine, null, @"(?imn)", "cat", RegexOptions.None, new string[] { string.Empty } }; yield return new object[] { engine, null, @"(?imn)cat", "(?imn)cat", RegexOptions.None, new string[] { "cat" } }; yield return new object[] { engine, null, @"(?=)", "cat", RegexOptions.None, new string[] { string.Empty } }; yield return new object[] { engine, null, @"(?<=)", "cat", RegexOptions.None, new string[] { string.Empty } }; yield return new object[] { engine, null, @"(?>)", "cat", RegexOptions.None, new string[] { string.Empty } }; // Alternation construct yield return new object[] { engine, null, @"(?()|)", "(?()|)", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"(?(cat)|)", "cat", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"(?(cat)|)", "dog", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"(?(cat)catdog|)", "catdog", RegexOptions.None, new string[] { "catdog" } }; yield return new object[] { engine, null, @"(?(cat)cat\w\w\w)*", "catdogcathog", RegexOptions.None, new string[] { "catdogcathog" } }; yield return new object[] { engine, null, @"(?(?=cat)cat\w\w\w)*", "catdogcathog", RegexOptions.None, new string[] { "catdogcathog" } }; yield return new object[] { engine, null, @"(?(cat)catdog|)", "dog", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"(?(cat)dog|)", "dog", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"(?(cat)dog|)", "cat", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"(?(cat)|catdog)", "cat", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"(?(cat)|catdog)", "catdog", RegexOptions.None, new string[] { "" } }; yield return new object[] { engine, null, @"(?(cat)|dog)", "dog", RegexOptions.None, new string[] { "dog" } }; yield return new object[] { engine, null, @"(?((\w{3}))\1\1|no)", "dogdogdog", RegexOptions.None, new string[] { "dogdog", "dog" } }; yield return new object[] { engine, null, @"(?((\w{3}))\1\1|no)", "no", RegexOptions.None, new string[] { "no", "" } }; // Invalid unicode yield return new object[] { engine, null, "([\u0000-\uFFFF-[azAZ09]]|[\u0000-\uFFFF-[^azAZ09]])+", "azAZBCDE1234567890BCDEFAZza", RegexOptions.None, new string[] { "azAZBCDE1234567890BCDEFAZza", "a" } }; yield return new object[] { engine, null, "[\u0000-\uFFFF-[\u0000-\uFFFF-[\u0000-\uFFFF-[\u0000-\uFFFF-[\u0000-\uFFFF-[a]]]]]]+", "abcxyzABCXYZ123890", RegexOptions.None, new string[] { "bcxyzABCXYZ123890" } }; yield return new object[] { engine, null, "[\u0000-\uFFFF-[\u0000-\uFFFF-[\u0000-\uFFFF-[\u0000-\uFFFF-[\u0000-\uFFFF-[\u0000-\uFFFF-[a]]]]]]]+", "bcxyzABCXYZ123890a", RegexOptions.None, new string[] { "a" } }; yield return new object[] { engine, null, "[\u0000-\uFFFF-[\\p{P}\\p{S}\\p{C}]]+", "!@`';.,$+<>=\x0001\x001FazAZ09", RegexOptions.None, new string[] { "azAZ09" } }; yield return new object[] { engine, null, @"[\uFFFD-\uFFFF]+", "\uFFFC\uFFFD\uFFFE\uFFFF", RegexOptions.IgnoreCase, new string[] { "\uFFFD\uFFFE\uFFFF" } }; yield return new object[] { engine, null, @"[\uFFFC-\uFFFE]+", "\uFFFB\uFFFC\uFFFD\uFFFE\uFFFF", RegexOptions.IgnoreCase, new string[] { "\uFFFC\uFFFD\uFFFE" } }; // Empty Match yield return new object[] { engine, null, @"([a*]*)+?$", "ab", RegexOptions.None, new string[] { "", "" } }; yield return new object[] { engine, null, @"(a*)+?$", "b", RegexOptions.None, new string[] { "", "" } }; } } public static IEnumerable<object[]> Groups_CustomCulture_TestData_enUS() { foreach (RegexEngine engine in RegexHelpers.AvailableEngines) { yield return new object[] { engine, "en-US", "CH", "Ch", RegexOptions.IgnoreCase, new string[] { "Ch" } }; yield return new object[] { engine, "en-US", "cH", "Ch", RegexOptions.IgnoreCase, new string[] { "Ch" } }; yield return new object[] { engine, "en-US", "AA", "Aa", RegexOptions.IgnoreCase, new string[] { "Aa" } }; yield return new object[] { engine, "en-US", "aA", "Aa", RegexOptions.IgnoreCase, new string[] { "Aa" } }; yield return new object[] { engine, "en-US", "\u0130", "\u0049", RegexOptions.IgnoreCase, new string[] { "\u0049" } }; yield return new object[] { engine, "en-US", "\u0130", "\u0069", RegexOptions.IgnoreCase, new string[] { "\u0069" } }; } } public static IEnumerable<object[]> Groups_CustomCulture_TestData_Czech() { foreach (RegexEngine engine in RegexHelpers.AvailableEngines) { yield return new object[] { engine, "cs-CZ", "CH", "Ch", RegexOptions.IgnoreCase, new string[] { "Ch" } }; yield return new object[] { engine, "cs-CZ", "cH", "Ch", RegexOptions.IgnoreCase, new string[] { "Ch" } }; } } public static IEnumerable<object[]> Groups_CustomCulture_TestData_Danish() { foreach (RegexEngine engine in RegexHelpers.AvailableEngines) { yield return new object[] { engine, "da-DK", "AA", "Aa", RegexOptions.IgnoreCase, new string[] { "Aa" } }; yield return new object[] { engine, "da-DK", "aA", "Aa", RegexOptions.IgnoreCase, new string[] { "Aa" } }; } } public static IEnumerable<object[]> Groups_CustomCulture_TestData_Turkish() { foreach (RegexEngine engine in RegexHelpers.AvailableEngines) { yield return new object[] { engine, "tr-TR", "\u0131", "\u0049", RegexOptions.IgnoreCase, new string[] { "\u0049" } }; yield return new object[] { engine, "tr-TR", "\u0130", "\u0069", RegexOptions.IgnoreCase, new string[] { "\u0069" } }; } } public static IEnumerable<object[]> Groups_CustomCulture_TestData_AzeriLatin() { foreach (RegexEngine engine in RegexHelpers.AvailableEngines) { if (PlatformDetection.IsNotBrowser) { yield return new object[] { engine, "az-Latn-AZ", "\u0131", "\u0049", RegexOptions.IgnoreCase, new string[] { "\u0049" } }; yield return new object[] { engine, "az-Latn-AZ", "\u0130", "\u0069", RegexOptions.IgnoreCase, new string[] { "\u0069" } }; } } } [Theory] [MemberData(nameof(Groups_Basic_TestData))] [MemberData(nameof(Groups_CustomCulture_TestData_enUS))] [MemberData(nameof(Groups_CustomCulture_TestData_Czech))] [MemberData(nameof(Groups_CustomCulture_TestData_Danish))] [MemberData(nameof(Groups_CustomCulture_TestData_Turkish))] [MemberData(nameof(Groups_CustomCulture_TestData_AzeriLatin))] [ActiveIssue("https://github.com/dotnet/runtime/issues/56407", TestPlatforms.Android)] [ActiveIssue("https://github.com/dotnet/runtime/issues/36900", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)] public async Task Groups(RegexEngine engine, string cultureName, string pattern, string input, RegexOptions options, string[] expectedGroups) { if (cultureName is null) { CultureInfo culture = CultureInfo.CurrentCulture; cultureName = culture.Equals(CultureInfo.InvariantCulture) ? "en-US" : culture.Name; } using var _ = new ThreadCultureChange(cultureName); Regex regex; try { regex = await RegexHelpers.GetRegexAsync(engine, pattern, options); } catch (NotSupportedException) when (RegexHelpers.IsNonBacktracking(engine)) { // Some constructs are not supported in NonBacktracking mode, such as: if-then-else, lookaround, and backreferences return; } Match match = regex.Match(input); Assert.True(match.Success); Assert.Equal(expectedGroups[0], match.Value); Assert.Equal(expectedGroups.Length, match.Groups.Count); int[] groupNumbers = regex.GetGroupNumbers(); string[] groupNames = regex.GetGroupNames(); for (int i = 0; i < expectedGroups.Length; i++) { Assert.Equal(expectedGroups[i], match.Groups[groupNumbers[i]].Value); Assert.Equal(match.Groups[groupNumbers[i]], match.Groups[groupNames[i]]); Assert.Equal(groupNumbers[i], regex.GroupNumberFromName(groupNames[i])); Assert.Equal(groupNames[i], regex.GroupNameFromNumber(groupNumbers[i])); } } [Fact] public void Synchronized_NullGroup_Throws() { AssertExtensions.Throws<ArgumentNullException>("inner", () => Group.Synchronized(null)); } [Theory] [InlineData(@"(cat)([\v]*)(dog)", "cat\v\v\vdog")] [InlineData("abc", "def")] // no match public void Synchronized_ValidGroup_Success(string pattern, string input) { Match match = Regex.Match(input, pattern); Group synchronizedGroup = Group.Synchronized(match.Groups[0]); Assert.NotNull(synchronizedGroup); } } }
1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/libraries/Microsoft.CSharp/tests/UserDefinedShortCircuitOperators.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; namespace Microsoft.CSharp.RuntimeBinder.Tests { public class UserDefinedShortCircuitOperators { private class NumTypeBitwiseOpsOnly { public int Value; public static NumTypeBitwiseOpsOnly operator &(NumTypeBitwiseOpsOnly x, NumTypeBitwiseOpsOnly y) => new NumTypeBitwiseOpsOnly{ Value = x.Value & y.Value }; public static NumTypeBitwiseOpsOnly operator |(NumTypeBitwiseOpsOnly x, NumTypeBitwiseOpsOnly y) => new NumTypeBitwiseOpsOnly{ Value = x.Value | y.Value }; } private class NumTypeBitwiseAndBoolCast { public int Value; public static NumTypeBitwiseAndBoolCast operator &(NumTypeBitwiseAndBoolCast x, NumTypeBitwiseAndBoolCast y) => new NumTypeBitwiseAndBoolCast { Value = x.Value & y.Value }; public static NumTypeBitwiseAndBoolCast operator |(NumTypeBitwiseAndBoolCast x, NumTypeBitwiseAndBoolCast y) => new NumTypeBitwiseAndBoolCast { Value = x.Value | y.Value }; public static implicit operator bool(NumTypeBitwiseAndBoolCast val) => val.Value != 0; } private class NumTypeBitwiseAndTruthiness { public int Value; public static NumTypeBitwiseAndTruthiness operator &(NumTypeBitwiseAndTruthiness x, NumTypeBitwiseAndTruthiness y) => new NumTypeBitwiseAndTruthiness { Value = x.Value & y.Value }; public static NumTypeBitwiseAndTruthiness operator |(NumTypeBitwiseAndTruthiness x, NumTypeBitwiseAndTruthiness y) => new NumTypeBitwiseAndTruthiness { Value = x.Value | y.Value }; public static bool operator true(NumTypeBitwiseAndTruthiness val) => val.Value != 0; public static bool operator false(NumTypeBitwiseAndTruthiness val) => val.Value == 0; } private class NumTypeBitwiseTruthinessAndBoolCast { public int Value; public static NumTypeBitwiseTruthinessAndBoolCast operator &(NumTypeBitwiseTruthinessAndBoolCast x, NumTypeBitwiseTruthinessAndBoolCast y) => new NumTypeBitwiseTruthinessAndBoolCast { Value = x.Value & y.Value }; public static NumTypeBitwiseTruthinessAndBoolCast operator |(NumTypeBitwiseTruthinessAndBoolCast x, NumTypeBitwiseTruthinessAndBoolCast y) => new NumTypeBitwiseTruthinessAndBoolCast { Value = x.Value | y.Value }; public static implicit operator bool(NumTypeBitwiseTruthinessAndBoolCast val) => val.Value != 0; public static bool operator true(NumTypeBitwiseTruthinessAndBoolCast val) => val.Value != 0; public static bool operator false(NumTypeBitwiseTruthinessAndBoolCast val) => val.Value == 0; } [Fact] public void CannotShortCircuitWithoutBoolOperators() { dynamic x = new NumTypeBitwiseOpsOnly { Value = -1 }; dynamic y = new NumTypeBitwiseOpsOnly { Value = 0 }; Assert.Throws<RuntimeBinderException>(() => x && x); Assert.Throws<RuntimeBinderException>(() => x && y); Assert.Throws<RuntimeBinderException>(() => y && x); Assert.Throws<RuntimeBinderException>(() => y && y); Assert.Throws<RuntimeBinderException>(() => x || x); Assert.Throws<RuntimeBinderException>(() => x || y); Assert.Throws<RuntimeBinderException>(() => y || x); Assert.Throws<RuntimeBinderException>(() => y || y); } [Fact] public void CannotShortCircuitWithBoolCast() { dynamic x = new NumTypeBitwiseAndBoolCast { Value = -1 }; dynamic y = new NumTypeBitwiseAndBoolCast { Value = 0 }; Assert.Throws<RuntimeBinderException>(() => x && x); Assert.Throws<RuntimeBinderException>(() => x && y); // Because the expression is evaluated dynamically, if casting the first operand to bool // gives the short-circuiting answer, then that is the result, even though with static // compilation this would result in CS0218, because the short-circuiting short-circuits // the check that would throw! Assert.Equal(0, (y && x).Value); Assert.Equal(0, (y && y).Value); Assert.Equal(-1, (x || x).Value); Assert.Equal(-1, (x || y).Value); Assert.Throws<RuntimeBinderException>(() => y || x); Assert.Throws<RuntimeBinderException>(() => y || y); } [Fact] public void CannotShortCircuitWithTruthiness() { dynamic x = new NumTypeBitwiseAndTruthiness { Value = -1 }; dynamic y = new NumTypeBitwiseAndTruthiness { Value = 0 }; Assert.Equal(-1, (x && x).Value); Assert.Equal(0, (x && y).Value); Assert.Equal(0, (y && x).Value); Assert.Equal(0, (y && y).Value); Assert.Equal(-1, (x || x).Value); Assert.Equal(-1, (x || y).Value); Assert.Equal(-1, (y || x).Value); Assert.Equal(0, (y || y).Value); } [Fact] public void CannotShortCircuitWithTruthinessAndBoolCast() { dynamic x = new NumTypeBitwiseTruthinessAndBoolCast { Value = -1 }; dynamic y = new NumTypeBitwiseTruthinessAndBoolCast { Value = 0 }; Assert.Equal(-1, (x && x).Value); Assert.Equal(0, (x && y).Value); Assert.Equal(0, (y && x).Value); Assert.Equal(0, (y && y).Value); Assert.Equal(-1, (x || x).Value); Assert.Equal(-1, (x || y).Value); Assert.Equal(-1, (y || x).Value); Assert.Equal(0, (y || y).Value); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; namespace Microsoft.CSharp.RuntimeBinder.Tests { public class UserDefinedShortCircuitOperators { private class NumTypeBitwiseOpsOnly { public int Value; public static NumTypeBitwiseOpsOnly operator &(NumTypeBitwiseOpsOnly x, NumTypeBitwiseOpsOnly y) => new NumTypeBitwiseOpsOnly{ Value = x.Value & y.Value }; public static NumTypeBitwiseOpsOnly operator |(NumTypeBitwiseOpsOnly x, NumTypeBitwiseOpsOnly y) => new NumTypeBitwiseOpsOnly{ Value = x.Value | y.Value }; } private class NumTypeBitwiseAndBoolCast { public int Value; public static NumTypeBitwiseAndBoolCast operator &(NumTypeBitwiseAndBoolCast x, NumTypeBitwiseAndBoolCast y) => new NumTypeBitwiseAndBoolCast { Value = x.Value & y.Value }; public static NumTypeBitwiseAndBoolCast operator |(NumTypeBitwiseAndBoolCast x, NumTypeBitwiseAndBoolCast y) => new NumTypeBitwiseAndBoolCast { Value = x.Value | y.Value }; public static implicit operator bool(NumTypeBitwiseAndBoolCast val) => val.Value != 0; } private class NumTypeBitwiseAndTruthiness { public int Value; public static NumTypeBitwiseAndTruthiness operator &(NumTypeBitwiseAndTruthiness x, NumTypeBitwiseAndTruthiness y) => new NumTypeBitwiseAndTruthiness { Value = x.Value & y.Value }; public static NumTypeBitwiseAndTruthiness operator |(NumTypeBitwiseAndTruthiness x, NumTypeBitwiseAndTruthiness y) => new NumTypeBitwiseAndTruthiness { Value = x.Value | y.Value }; public static bool operator true(NumTypeBitwiseAndTruthiness val) => val.Value != 0; public static bool operator false(NumTypeBitwiseAndTruthiness val) => val.Value == 0; } private class NumTypeBitwiseTruthinessAndBoolCast { public int Value; public static NumTypeBitwiseTruthinessAndBoolCast operator &(NumTypeBitwiseTruthinessAndBoolCast x, NumTypeBitwiseTruthinessAndBoolCast y) => new NumTypeBitwiseTruthinessAndBoolCast { Value = x.Value & y.Value }; public static NumTypeBitwiseTruthinessAndBoolCast operator |(NumTypeBitwiseTruthinessAndBoolCast x, NumTypeBitwiseTruthinessAndBoolCast y) => new NumTypeBitwiseTruthinessAndBoolCast { Value = x.Value | y.Value }; public static implicit operator bool(NumTypeBitwiseTruthinessAndBoolCast val) => val.Value != 0; public static bool operator true(NumTypeBitwiseTruthinessAndBoolCast val) => val.Value != 0; public static bool operator false(NumTypeBitwiseTruthinessAndBoolCast val) => val.Value == 0; } [Fact] public void CannotShortCircuitWithoutBoolOperators() { dynamic x = new NumTypeBitwiseOpsOnly { Value = -1 }; dynamic y = new NumTypeBitwiseOpsOnly { Value = 0 }; Assert.Throws<RuntimeBinderException>(() => x && x); Assert.Throws<RuntimeBinderException>(() => x && y); Assert.Throws<RuntimeBinderException>(() => y && x); Assert.Throws<RuntimeBinderException>(() => y && y); Assert.Throws<RuntimeBinderException>(() => x || x); Assert.Throws<RuntimeBinderException>(() => x || y); Assert.Throws<RuntimeBinderException>(() => y || x); Assert.Throws<RuntimeBinderException>(() => y || y); } [Fact] public void CannotShortCircuitWithBoolCast() { dynamic x = new NumTypeBitwiseAndBoolCast { Value = -1 }; dynamic y = new NumTypeBitwiseAndBoolCast { Value = 0 }; Assert.Throws<RuntimeBinderException>(() => x && x); Assert.Throws<RuntimeBinderException>(() => x && y); // Because the expression is evaluated dynamically, if casting the first operand to bool // gives the short-circuiting answer, then that is the result, even though with static // compilation this would result in CS0218, because the short-circuiting short-circuits // the check that would throw! Assert.Equal(0, (y && x).Value); Assert.Equal(0, (y && y).Value); Assert.Equal(-1, (x || x).Value); Assert.Equal(-1, (x || y).Value); Assert.Throws<RuntimeBinderException>(() => y || x); Assert.Throws<RuntimeBinderException>(() => y || y); } [Fact] public void CannotShortCircuitWithTruthiness() { dynamic x = new NumTypeBitwiseAndTruthiness { Value = -1 }; dynamic y = new NumTypeBitwiseAndTruthiness { Value = 0 }; Assert.Equal(-1, (x && x).Value); Assert.Equal(0, (x && y).Value); Assert.Equal(0, (y && x).Value); Assert.Equal(0, (y && y).Value); Assert.Equal(-1, (x || x).Value); Assert.Equal(-1, (x || y).Value); Assert.Equal(-1, (y || x).Value); Assert.Equal(0, (y || y).Value); } [Fact] public void CannotShortCircuitWithTruthinessAndBoolCast() { dynamic x = new NumTypeBitwiseTruthinessAndBoolCast { Value = -1 }; dynamic y = new NumTypeBitwiseTruthinessAndBoolCast { Value = 0 }; Assert.Equal(-1, (x && x).Value); Assert.Equal(0, (x && y).Value); Assert.Equal(0, (y && x).Value); Assert.Equal(0, (y && y).Value); Assert.Equal(-1, (x || x).Value); Assert.Equal(-1, (x || y).Value); Assert.Equal(-1, (y || x).Value); Assert.Equal(0, (y || y).Value); } } }
-1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/AddHighNarrowingLower.Vector64.Int32.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void AddHighNarrowingLower_Vector64_Int32() { var test = new SimpleBinaryOpTest__AddHighNarrowingLower_Vector64_Int32(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleBinaryOpTest__AddHighNarrowingLower_Vector64_Int32 { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Int64[] inArray1, Int64[] inArray2, Int32[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int64>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Int64>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int32>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Int64, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Int64, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector128<Int64> _fld1; public Vector128<Int64> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref testStruct._fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref testStruct._fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__AddHighNarrowingLower_Vector64_Int32 testClass) { var result = AdvSimd.AddHighNarrowingLower(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__AddHighNarrowingLower_Vector64_Int32 testClass) { fixed (Vector128<Int64>* pFld1 = &_fld1) fixed (Vector128<Int64>* pFld2 = &_fld2) { var result = AdvSimd.AddHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(pFld1)), AdvSimd.LoadVector128((Int64*)(pFld2)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64); private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<Int32>>() / sizeof(Int32); private static Int64[] _data1 = new Int64[Op1ElementCount]; private static Int64[] _data2 = new Int64[Op2ElementCount]; private static Vector128<Int64> _clsVar1; private static Vector128<Int64> _clsVar2; private Vector128<Int64> _fld1; private Vector128<Int64> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__AddHighNarrowingLower_Vector64_Int32() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); } public SimpleBinaryOpTest__AddHighNarrowingLower_Vector64_Int32() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } _dataTable = new DataTable(_data1, _data2, new Int32[RetElementCount], LargestVectorSize); } public bool IsSupported => AdvSimd.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = AdvSimd.AddHighNarrowingLower( Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Int64>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = AdvSimd.AddHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Int64*)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.AddHighNarrowingLower), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Int64>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Int32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.AddHighNarrowingLower), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Int64*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Int32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.AddHighNarrowingLower( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<Int64>* pClsVar1 = &_clsVar1) fixed (Vector128<Int64>* pClsVar2 = &_clsVar2) { var result = AdvSimd.AddHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(pClsVar1)), AdvSimd.LoadVector128((Int64*)(pClsVar2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Int64>>(_dataTable.inArray2Ptr); var result = AdvSimd.AddHighNarrowingLower(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((Int64*)(_dataTable.inArray2Ptr)); var result = AdvSimd.AddHighNarrowingLower(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__AddHighNarrowingLower_Vector64_Int32(); var result = AdvSimd.AddHighNarrowingLower(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleBinaryOpTest__AddHighNarrowingLower_Vector64_Int32(); fixed (Vector128<Int64>* pFld1 = &test._fld1) fixed (Vector128<Int64>* pFld2 = &test._fld2) { var result = AdvSimd.AddHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(pFld1)), AdvSimd.LoadVector128((Int64*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.AddHighNarrowingLower(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<Int64>* pFld1 = &_fld1) fixed (Vector128<Int64>* pFld2 = &_fld2) { var result = AdvSimd.AddHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(pFld1)), AdvSimd.LoadVector128((Int64*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = AdvSimd.AddHighNarrowingLower(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = AdvSimd.AddHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(&test._fld1)), AdvSimd.LoadVector128((Int64*)(&test._fld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector128<Int64> op1, Vector128<Int64> op2, void* result, [CallerMemberName] string method = "") { Int64[] inArray1 = new Int64[Op1ElementCount]; Int64[] inArray2 = new Int64[Op2ElementCount]; Int32[] outArray = new Int32[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Int32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Int64[] inArray1 = new Int64[Op1ElementCount]; Int64[] inArray2 = new Int64[Op2ElementCount]; Int32[] outArray = new Int32[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Int64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Int64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Int32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Int64[] left, Int64[] right, Int32[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.AddHighNarrowing(left[i], right[i]) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.AddHighNarrowingLower)}<Int32>(Vector128<Int64>, Vector128<Int64>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void AddHighNarrowingLower_Vector64_Int32() { var test = new SimpleBinaryOpTest__AddHighNarrowingLower_Vector64_Int32(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleBinaryOpTest__AddHighNarrowingLower_Vector64_Int32 { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Int64[] inArray1, Int64[] inArray2, Int32[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int64>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Int64>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int32>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Int64, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Int64, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector128<Int64> _fld1; public Vector128<Int64> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref testStruct._fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref testStruct._fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__AddHighNarrowingLower_Vector64_Int32 testClass) { var result = AdvSimd.AddHighNarrowingLower(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__AddHighNarrowingLower_Vector64_Int32 testClass) { fixed (Vector128<Int64>* pFld1 = &_fld1) fixed (Vector128<Int64>* pFld2 = &_fld2) { var result = AdvSimd.AddHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(pFld1)), AdvSimd.LoadVector128((Int64*)(pFld2)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64); private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<Int32>>() / sizeof(Int32); private static Int64[] _data1 = new Int64[Op1ElementCount]; private static Int64[] _data2 = new Int64[Op2ElementCount]; private static Vector128<Int64> _clsVar1; private static Vector128<Int64> _clsVar2; private Vector128<Int64> _fld1; private Vector128<Int64> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__AddHighNarrowingLower_Vector64_Int32() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); } public SimpleBinaryOpTest__AddHighNarrowingLower_Vector64_Int32() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } _dataTable = new DataTable(_data1, _data2, new Int32[RetElementCount], LargestVectorSize); } public bool IsSupported => AdvSimd.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = AdvSimd.AddHighNarrowingLower( Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Int64>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = AdvSimd.AddHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Int64*)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.AddHighNarrowingLower), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Int64>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Int32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.AddHighNarrowingLower), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Int64*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Int32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.AddHighNarrowingLower( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<Int64>* pClsVar1 = &_clsVar1) fixed (Vector128<Int64>* pClsVar2 = &_clsVar2) { var result = AdvSimd.AddHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(pClsVar1)), AdvSimd.LoadVector128((Int64*)(pClsVar2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Int64>>(_dataTable.inArray2Ptr); var result = AdvSimd.AddHighNarrowingLower(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((Int64*)(_dataTable.inArray2Ptr)); var result = AdvSimd.AddHighNarrowingLower(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__AddHighNarrowingLower_Vector64_Int32(); var result = AdvSimd.AddHighNarrowingLower(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleBinaryOpTest__AddHighNarrowingLower_Vector64_Int32(); fixed (Vector128<Int64>* pFld1 = &test._fld1) fixed (Vector128<Int64>* pFld2 = &test._fld2) { var result = AdvSimd.AddHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(pFld1)), AdvSimd.LoadVector128((Int64*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.AddHighNarrowingLower(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<Int64>* pFld1 = &_fld1) fixed (Vector128<Int64>* pFld2 = &_fld2) { var result = AdvSimd.AddHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(pFld1)), AdvSimd.LoadVector128((Int64*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = AdvSimd.AddHighNarrowingLower(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = AdvSimd.AddHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(&test._fld1)), AdvSimd.LoadVector128((Int64*)(&test._fld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector128<Int64> op1, Vector128<Int64> op2, void* result, [CallerMemberName] string method = "") { Int64[] inArray1 = new Int64[Op1ElementCount]; Int64[] inArray2 = new Int64[Op2ElementCount]; Int32[] outArray = new Int32[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Int32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Int64[] inArray1 = new Int64[Op1ElementCount]; Int64[] inArray2 = new Int64[Op2ElementCount]; Int32[] outArray = new Int32[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Int64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Int64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Int32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Int64[] left, Int64[] right, Int32[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.AddHighNarrowing(left[i], right[i]) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.AddHighNarrowingLower)}<Int32>(Vector128<Int64>, Vector128<Int64>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/tests/JIT/HardwareIntrinsics/General/Vector64/Subtract.Int16.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; namespace JIT.HardwareIntrinsics.General { public static partial class Program { private static void SubtractInt16() { var test = new VectorBinaryOpTest__SubtractInt16(); // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorBinaryOpTest__SubtractInt16 { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Int16[] inArray1, Int16[] inArray2, Int16[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int16>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Int16>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int16>(); if ((alignment != 32 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Int16, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Int16, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector64<Int16> _fld1; public Vector64<Int16> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref testStruct._fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref testStruct._fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>()); return testStruct; } public void RunStructFldScenario(VectorBinaryOpTest__SubtractInt16 testClass) { var result = Vector64.Subtract(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } private static readonly int LargestVectorSize = 8; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector64<Int16>>() / sizeof(Int16); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector64<Int16>>() / sizeof(Int16); private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<Int16>>() / sizeof(Int16); private static Int16[] _data1 = new Int16[Op1ElementCount]; private static Int16[] _data2 = new Int16[Op2ElementCount]; private static Vector64<Int16> _clsVar1; private static Vector64<Int16> _clsVar2; private Vector64<Int16> _fld1; private Vector64<Int16> _fld2; private DataTable _dataTable; static VectorBinaryOpTest__SubtractInt16() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>()); } public VectorBinaryOpTest__SubtractInt16() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } _dataTable = new DataTable(_data1, _data2, new Int16[RetElementCount], LargestVectorSize); } public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Vector64.Subtract( Unsafe.Read<Vector64<Int16>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<Int16>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var method = typeof(Vector64).GetMethod(nameof(Vector64.Subtract), new Type[] { typeof(Vector64<Int16>), typeof(Vector64<Int16>) }); if (method is null) { method = typeof(Vector64).GetMethod(nameof(Vector64.Subtract), 1, new Type[] { typeof(Vector64<>).MakeGenericType(Type.MakeGenericMethodParameter(0)), typeof(Vector64<>).MakeGenericType(Type.MakeGenericMethodParameter(0)) }); } if (method.IsGenericMethodDefinition) { method = method.MakeGenericMethod(typeof(Int16)); } var result = method.Invoke(null, new object[] { Unsafe.Read<Vector64<Int16>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<Int16>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Int16>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Vector64.Subtract( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector64<Int16>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector64<Int16>>(_dataTable.inArray2Ptr); var result = Vector64.Subtract(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new VectorBinaryOpTest__SubtractInt16(); var result = Vector64.Subtract(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Vector64.Subtract(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Vector64.Subtract(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } private void ValidateResult(Vector64<Int16> op1, Vector64<Int16> op2, void* result, [CallerMemberName] string method = "") { Int16[] inArray1 = new Int16[Op1ElementCount]; Int16[] inArray2 = new Int16[Op2ElementCount]; Int16[] outArray = new Int16[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Int16>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Int16[] inArray1 = new Int16[Op1ElementCount]; Int16[] inArray2 = new Int16[Op2ElementCount]; Int16[] outArray = new Int16[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector64<Int16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector64<Int16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Int16>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Int16[] left, Int16[] right, Int16[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (result[0] != (short)(left[0] - right[0])) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (result[i] != (short)(left[i] - right[i])) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Vector64)}.{nameof(Vector64.Subtract)}<Int16>(Vector64<Int16>, Vector64<Int16>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; namespace JIT.HardwareIntrinsics.General { public static partial class Program { private static void SubtractInt16() { var test = new VectorBinaryOpTest__SubtractInt16(); // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorBinaryOpTest__SubtractInt16 { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Int16[] inArray1, Int16[] inArray2, Int16[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int16>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Int16>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int16>(); if ((alignment != 32 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Int16, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Int16, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector64<Int16> _fld1; public Vector64<Int16> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref testStruct._fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref testStruct._fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>()); return testStruct; } public void RunStructFldScenario(VectorBinaryOpTest__SubtractInt16 testClass) { var result = Vector64.Subtract(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } private static readonly int LargestVectorSize = 8; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector64<Int16>>() / sizeof(Int16); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector64<Int16>>() / sizeof(Int16); private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<Int16>>() / sizeof(Int16); private static Int16[] _data1 = new Int16[Op1ElementCount]; private static Int16[] _data2 = new Int16[Op2ElementCount]; private static Vector64<Int16> _clsVar1; private static Vector64<Int16> _clsVar2; private Vector64<Int16> _fld1; private Vector64<Int16> _fld2; private DataTable _dataTable; static VectorBinaryOpTest__SubtractInt16() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>()); } public VectorBinaryOpTest__SubtractInt16() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Int16>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } _dataTable = new DataTable(_data1, _data2, new Int16[RetElementCount], LargestVectorSize); } public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Vector64.Subtract( Unsafe.Read<Vector64<Int16>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<Int16>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var method = typeof(Vector64).GetMethod(nameof(Vector64.Subtract), new Type[] { typeof(Vector64<Int16>), typeof(Vector64<Int16>) }); if (method is null) { method = typeof(Vector64).GetMethod(nameof(Vector64.Subtract), 1, new Type[] { typeof(Vector64<>).MakeGenericType(Type.MakeGenericMethodParameter(0)), typeof(Vector64<>).MakeGenericType(Type.MakeGenericMethodParameter(0)) }); } if (method.IsGenericMethodDefinition) { method = method.MakeGenericMethod(typeof(Int16)); } var result = method.Invoke(null, new object[] { Unsafe.Read<Vector64<Int16>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<Int16>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Int16>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Vector64.Subtract( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector64<Int16>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector64<Int16>>(_dataTable.inArray2Ptr); var result = Vector64.Subtract(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new VectorBinaryOpTest__SubtractInt16(); var result = Vector64.Subtract(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Vector64.Subtract(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Vector64.Subtract(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } private void ValidateResult(Vector64<Int16> op1, Vector64<Int16> op2, void* result, [CallerMemberName] string method = "") { Int16[] inArray1 = new Int16[Op1ElementCount]; Int16[] inArray2 = new Int16[Op2ElementCount]; Int16[] outArray = new Int16[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Int16>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Int16[] inArray1 = new Int16[Op1ElementCount]; Int16[] inArray2 = new Int16[Op2ElementCount]; Int16[] outArray = new Int16[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector64<Int16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector64<Int16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Int16>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Int16[] left, Int16[] right, Int16[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (result[0] != (short)(left[0] - right[0])) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (result[i] != (short)(left[i] - right[i])) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Vector64)}.{nameof(Vector64.Subtract)}<Int16>(Vector64<Int16>, Vector64<Int16>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/libraries/System.Net.Http.WinHttpHandler/tests/UnitTests/FakeMarshal.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Net.Http.WinHttpHandlerUnitTests; namespace System.Net.Http { public static class Marshal { public static int GetLastWin32Error() { if (TestControl.LastWin32Error != 0) { return TestControl.LastWin32Error; } return System.Runtime.InteropServices.Marshal.GetLastWin32Error(); } public static IntPtr AllocHGlobal(int cb) { return System.Runtime.InteropServices.Marshal.AllocHGlobal(cb); } public static void FreeHGlobal(IntPtr hglobal) { System.Runtime.InteropServices.Marshal.FreeHGlobal(hglobal); } public static string PtrToStringUni(IntPtr ptr) { return System.Runtime.InteropServices.Marshal.PtrToStringUni(ptr); } public static IntPtr StringToHGlobalUni(string s) { return System.Runtime.InteropServices.Marshal.StringToHGlobalUni(s); } public static void Copy(IntPtr source, byte[] destination, int startIndex, int length) { System.Runtime.InteropServices.Marshal.Copy(source, destination, startIndex, length); } public static int SizeOf<T>() { return System.Runtime.InteropServices.Marshal.SizeOf<T>(); } public static IntPtr UnsafeAddrOfPinnedArrayElement<T>(T[] arr, int index) { return System.Runtime.InteropServices.Marshal.UnsafeAddrOfPinnedArrayElement<T>(arr, index); } public static T PtrToStructure<T>(IntPtr ptr) { return System.Runtime.InteropServices.Marshal.PtrToStructure<T>(ptr); } public static void WriteByte(IntPtr ptr, int ofs, byte val) { System.Runtime.InteropServices.Marshal.WriteByte(ptr, ofs, val); } public static string PtrToStringAnsi(IntPtr ptr, int len) { return System.Runtime.InteropServices.Marshal.PtrToStringAnsi(ptr, len); } public static void StructureToPtr<T>(T structure, IntPtr ptr, bool fDeleteOld) { System.Runtime.InteropServices.Marshal.StructureToPtr<T>(structure, ptr, fDeleteOld); } public static int SizeOf<T>(T structure) { return System.Runtime.InteropServices.Marshal.SizeOf<T>(structure); } public static int ReadInt32(IntPtr ptr) { return System.Runtime.InteropServices.Marshal.ReadInt32(ptr); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Net.Http.WinHttpHandlerUnitTests; namespace System.Net.Http { public static class Marshal { public static int GetLastWin32Error() { if (TestControl.LastWin32Error != 0) { return TestControl.LastWin32Error; } return System.Runtime.InteropServices.Marshal.GetLastWin32Error(); } public static IntPtr AllocHGlobal(int cb) { return System.Runtime.InteropServices.Marshal.AllocHGlobal(cb); } public static void FreeHGlobal(IntPtr hglobal) { System.Runtime.InteropServices.Marshal.FreeHGlobal(hglobal); } public static string PtrToStringUni(IntPtr ptr) { return System.Runtime.InteropServices.Marshal.PtrToStringUni(ptr); } public static IntPtr StringToHGlobalUni(string s) { return System.Runtime.InteropServices.Marshal.StringToHGlobalUni(s); } public static void Copy(IntPtr source, byte[] destination, int startIndex, int length) { System.Runtime.InteropServices.Marshal.Copy(source, destination, startIndex, length); } public static int SizeOf<T>() { return System.Runtime.InteropServices.Marshal.SizeOf<T>(); } public static IntPtr UnsafeAddrOfPinnedArrayElement<T>(T[] arr, int index) { return System.Runtime.InteropServices.Marshal.UnsafeAddrOfPinnedArrayElement<T>(arr, index); } public static T PtrToStructure<T>(IntPtr ptr) { return System.Runtime.InteropServices.Marshal.PtrToStructure<T>(ptr); } public static void WriteByte(IntPtr ptr, int ofs, byte val) { System.Runtime.InteropServices.Marshal.WriteByte(ptr, ofs, val); } public static string PtrToStringAnsi(IntPtr ptr, int len) { return System.Runtime.InteropServices.Marshal.PtrToStringAnsi(ptr, len); } public static void StructureToPtr<T>(T structure, IntPtr ptr, bool fDeleteOld) { System.Runtime.InteropServices.Marshal.StructureToPtr<T>(structure, ptr, fDeleteOld); } public static int SizeOf<T>(T structure) { return System.Runtime.InteropServices.Marshal.SizeOf<T>(structure); } public static int ReadInt32(IntPtr ptr) { return System.Runtime.InteropServices.Marshal.ReadInt32(ptr); } } }
-1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/tests/JIT/HardwareIntrinsics/X86/Bmi1.X64/AndNot.UInt64.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; namespace JIT.HardwareIntrinsics.X86 { public static partial class Program { private static void AndNotUInt64() { var test = new ScalarBinaryOpTest__AndNotUInt64(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.ReadUnaligned test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.ReadUnaligned test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.ReadUnaligned test.RunLclVarScenario_UnsafeRead(); // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class ScalarBinaryOpTest__AndNotUInt64 { private struct TestStruct { public UInt64 _fld1; public UInt64 _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); testStruct._fld1 = TestLibrary.Generator.GetUInt64(); testStruct._fld2 = TestLibrary.Generator.GetUInt64(); return testStruct; } public void RunStructFldScenario(ScalarBinaryOpTest__AndNotUInt64 testClass) { var result = Bmi1.X64.AndNot(_fld1, _fld2); testClass.ValidateResult(_fld1, _fld2, result); } } private static UInt64 _data1; private static UInt64 _data2; private static UInt64 _clsVar1; private static UInt64 _clsVar2; private UInt64 _fld1; private UInt64 _fld2; static ScalarBinaryOpTest__AndNotUInt64() { _clsVar1 = TestLibrary.Generator.GetUInt64(); _clsVar2 = TestLibrary.Generator.GetUInt64(); } public ScalarBinaryOpTest__AndNotUInt64() { Succeeded = true; _fld1 = TestLibrary.Generator.GetUInt64(); _fld2 = TestLibrary.Generator.GetUInt64(); _data1 = TestLibrary.Generator.GetUInt64(); _data2 = TestLibrary.Generator.GetUInt64(); } public bool IsSupported => Bmi1.X64.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Bmi1.X64.AndNot( Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data1)), Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data2)) ); ValidateResult(_data1, _data2, result); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(Bmi1.X64).GetMethod(nameof(Bmi1.X64.AndNot), new Type[] { typeof(UInt64), typeof(UInt64) }) .Invoke(null, new object[] { Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data1)), Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data2)) }); ValidateResult(_data1, _data2, (UInt64)result); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Bmi1.X64.AndNot( _clsVar1, _clsVar2 ); ValidateResult(_clsVar1, _clsVar2, result); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var data1 = Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data1)); var data2 = Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data2)); var result = Bmi1.X64.AndNot(data1, data2); ValidateResult(data1, data2, result); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new ScalarBinaryOpTest__AndNotUInt64(); var result = Bmi1.X64.AndNot(test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, result); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Bmi1.X64.AndNot(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Bmi1.X64.AndNot(test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, result); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(UInt64 left, UInt64 right, UInt64 result, [CallerMemberName] string method = "") { var isUnexpectedResult = false; isUnexpectedResult = ((~left & right) != result); if (isUnexpectedResult) { TestLibrary.TestFramework.LogInformation($"{nameof(Bmi1.X64)}.{nameof(Bmi1.X64.AndNot)}<UInt64>(UInt64, UInt64): AndNot failed:"); TestLibrary.TestFramework.LogInformation($" left: {left}"); TestLibrary.TestFramework.LogInformation($" right: {right}"); TestLibrary.TestFramework.LogInformation($" result: {result}"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; namespace JIT.HardwareIntrinsics.X86 { public static partial class Program { private static void AndNotUInt64() { var test = new ScalarBinaryOpTest__AndNotUInt64(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.ReadUnaligned test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.ReadUnaligned test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.ReadUnaligned test.RunLclVarScenario_UnsafeRead(); // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class ScalarBinaryOpTest__AndNotUInt64 { private struct TestStruct { public UInt64 _fld1; public UInt64 _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); testStruct._fld1 = TestLibrary.Generator.GetUInt64(); testStruct._fld2 = TestLibrary.Generator.GetUInt64(); return testStruct; } public void RunStructFldScenario(ScalarBinaryOpTest__AndNotUInt64 testClass) { var result = Bmi1.X64.AndNot(_fld1, _fld2); testClass.ValidateResult(_fld1, _fld2, result); } } private static UInt64 _data1; private static UInt64 _data2; private static UInt64 _clsVar1; private static UInt64 _clsVar2; private UInt64 _fld1; private UInt64 _fld2; static ScalarBinaryOpTest__AndNotUInt64() { _clsVar1 = TestLibrary.Generator.GetUInt64(); _clsVar2 = TestLibrary.Generator.GetUInt64(); } public ScalarBinaryOpTest__AndNotUInt64() { Succeeded = true; _fld1 = TestLibrary.Generator.GetUInt64(); _fld2 = TestLibrary.Generator.GetUInt64(); _data1 = TestLibrary.Generator.GetUInt64(); _data2 = TestLibrary.Generator.GetUInt64(); } public bool IsSupported => Bmi1.X64.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Bmi1.X64.AndNot( Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data1)), Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data2)) ); ValidateResult(_data1, _data2, result); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(Bmi1.X64).GetMethod(nameof(Bmi1.X64.AndNot), new Type[] { typeof(UInt64), typeof(UInt64) }) .Invoke(null, new object[] { Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data1)), Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data2)) }); ValidateResult(_data1, _data2, (UInt64)result); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Bmi1.X64.AndNot( _clsVar1, _clsVar2 ); ValidateResult(_clsVar1, _clsVar2, result); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var data1 = Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data1)); var data2 = Unsafe.ReadUnaligned<UInt64>(ref Unsafe.As<UInt64, byte>(ref _data2)); var result = Bmi1.X64.AndNot(data1, data2); ValidateResult(data1, data2, result); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new ScalarBinaryOpTest__AndNotUInt64(); var result = Bmi1.X64.AndNot(test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, result); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Bmi1.X64.AndNot(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Bmi1.X64.AndNot(test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, result); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(UInt64 left, UInt64 right, UInt64 result, [CallerMemberName] string method = "") { var isUnexpectedResult = false; isUnexpectedResult = ((~left & right) != result); if (isUnexpectedResult) { TestLibrary.TestFramework.LogInformation($"{nameof(Bmi1.X64)}.{nameof(Bmi1.X64.AndNot)}<UInt64>(UInt64, UInt64): AndNot failed:"); TestLibrary.TestFramework.LogInformation($" left: {left}"); TestLibrary.TestFramework.LogInformation($" right: {right}"); TestLibrary.TestFramework.LogInformation($" result: {result}"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/libraries/Common/src/Interop/Windows/User32/Interop.IsWindowVisible.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Runtime.InteropServices; internal static partial class Interop { internal static partial class User32 { [GeneratedDllImport(Libraries.User32)] public static partial BOOL IsWindowVisible(IntPtr hWnd); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Runtime.InteropServices; internal static partial class Interop { internal static partial class User32 { [GeneratedDllImport(Libraries.User32)] public static partial BOOL IsWindowVisible(IntPtr hWnd); } }
-1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/libraries/System.Text.Encoding/tests/NegativeEncodingTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using Xunit; namespace System.Text.Tests { public static class NegativeEncodingTests { public static IEnumerable<object[]> Encodings_TestData() { yield return new object[] { new UnicodeEncoding(false, false) }; yield return new object[] { new UnicodeEncoding(true, false) }; yield return new object[] { new UnicodeEncoding(true, true) }; yield return new object[] { new UnicodeEncoding(true, true) }; yield return new object[] { Encoding.BigEndianUnicode }; yield return new object[] { Encoding.Unicode }; yield return new object[] { new UTF7Encoding(true) }; yield return new object[] { new UTF7Encoding(false) }; yield return new object[] { Encoding.UTF7 }; yield return new object[] { new UTF8Encoding(true, true) }; yield return new object[] { new UTF8Encoding(false, true) }; yield return new object[] { new UTF8Encoding(true, false) }; yield return new object[] { new UTF8Encoding(false, false) }; yield return new object[] { Encoding.UTF8 }; yield return new object[] { new ASCIIEncoding() }; yield return new object[] { Encoding.ASCII }; yield return new object[] { new UTF32Encoding(true, true, true) }; yield return new object[] { new UTF32Encoding(true, true, false) }; yield return new object[] { new UTF32Encoding(true, false, false) }; yield return new object[] { new UTF32Encoding(true, false, true) }; yield return new object[] { new UTF32Encoding(false, true, true) }; yield return new object[] { new UTF32Encoding(false, true, false) }; yield return new object[] { new UTF32Encoding(false, false, false) }; yield return new object[] { new UTF32Encoding(false, false, true) }; yield return new object[] { Encoding.UTF32 }; yield return new object[] { Encoding.GetEncoding("latin1") }; } [Theory] [MemberData(nameof(Encodings_TestData))] public static unsafe void GetByteCount_Invalid(Encoding encoding) { // Chars is null if (PlatformDetection.IsNetCore) { AssertExtensions.Throws<ArgumentNullException>((encoding is ASCIIEncoding || encoding is UTF8Encoding) ? "chars" : "s", () => encoding.GetByteCount((string)null)); } else { AssertExtensions.Throws<ArgumentNullException>((encoding is ASCIIEncoding) ? "chars" : "s", () => encoding.GetByteCount((string)null)); } AssertExtensions.Throws<ArgumentNullException>("chars", () => encoding.GetByteCount((char[])null)); AssertExtensions.Throws<ArgumentNullException>("chars", () => encoding.GetByteCount((char[])null, 0, 0)); // Index < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount(new char[3], -1, 0)); // Count < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetByteCount(new char[3], 0, -1)); // Index + count > chars.Length AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoding.GetByteCount(new char[3], 0, 4)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoding.GetByteCount(new char[3], 1, 3)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoding.GetByteCount(new char[3], 2, 2)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoding.GetByteCount(new char[3], 3, 1)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoding.GetByteCount(new char[3], 4, 0)); char[] chars = new char[3]; fixed (char* pChars = chars) { char* pCharsLocal = pChars; AssertExtensions.Throws<ArgumentNullException>("chars", () => encoding.GetByteCount(null, 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetByteCount(pCharsLocal, -1)); } } [Theory] [MemberData(nameof(Encodings_TestData))] public static unsafe void GetBytes_Invalid(Encoding encoding) { string expectedStringParamName = encoding is ASCIIEncoding ? "chars" : "s"; // Source is null AssertExtensions.Throws<ArgumentNullException>("s", () => encoding.GetBytes((string)null)); AssertExtensions.Throws<ArgumentNullException>("chars", () => encoding.GetBytes((char[])null)); AssertExtensions.Throws<ArgumentNullException>("chars", () => encoding.GetBytes((char[])null, 0, 0)); AssertExtensions.Throws<ArgumentNullException>(expectedStringParamName, () => encoding.GetBytes((string)null, 0, 0, new byte[1], 0)); AssertExtensions.Throws<ArgumentNullException>("chars", () => encoding.GetBytes((char[])null, 0, 0, new byte[1], 0)); // Bytes is null AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetBytes("abc", 0, 3, null, 0)); AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetBytes(new char[3], 0, 3, null, 0)); // Char index < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetBytes(new char[1], -1, 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("charIndex", () => encoding.GetBytes("a", -1, 0, new byte[1], 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("charIndex", () => encoding.GetBytes(new char[1], -1, 0, new byte[1], 0)); // Char count < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetBytes(new char[1], 0, -1)); AssertExtensions.Throws<ArgumentOutOfRangeException>("charCount", () => encoding.GetBytes("a", 0, -1, new byte[1], 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("charCount", () => encoding.GetBytes(new char[1], 0, -1, new byte[1], 0)); // Char index + count > source.Length AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoding.GetBytes(new char[1], 2, 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>(expectedStringParamName, () => encoding.GetBytes("a", 2, 0, new byte[1], 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoding.GetBytes(new char[1], 2, 0, new byte[1], 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoding.GetBytes(new char[1], 1, 1)); AssertExtensions.Throws<ArgumentOutOfRangeException>(expectedStringParamName, () => encoding.GetBytes("a", 1, 1, new byte[1], 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoding.GetBytes(new char[1], 1, 1, new byte[1], 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoding.GetBytes(new char[1], 0, 2)); AssertExtensions.Throws<ArgumentOutOfRangeException>(expectedStringParamName, () => encoding.GetBytes("a", 0, 2, new byte[1], 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoding.GetBytes(new char[1], 0, 2, new byte[1], 0)); // Byte index < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("byteIndex", () => encoding.GetBytes("a", 0, 1, new byte[1], -1)); AssertExtensions.Throws<ArgumentOutOfRangeException>("byteIndex", () => encoding.GetBytes(new char[1], 0, 1, new byte[1], -1)); // Byte index > bytes.Length AssertExtensions.Throws<ArgumentOutOfRangeException>("byteIndex", () => encoding.GetBytes("a", 0, 1, new byte[1], 2)); AssertExtensions.Throws<ArgumentOutOfRangeException>("byteIndex", () => encoding.GetBytes(new char[1], 0, 1, new byte[1], 2)); // Bytes does not have enough capacity to accomodate result AssertExtensions.Throws<ArgumentException>("bytes", () => encoding.GetBytes("a", 0, 1, new byte[0], 0)); AssertExtensions.Throws<ArgumentException>("bytes", () => encoding.GetBytes("abc", 0, 3, new byte[1], 0)); AssertExtensions.Throws<ArgumentException>("bytes", () => encoding.GetBytes("\uD800\uDC00", 0, 2, new byte[1], 0)); AssertExtensions.Throws<ArgumentException>("bytes", () => encoding.GetBytes(new char[1], 0, 1, new byte[0], 0)); AssertExtensions.Throws<ArgumentException>("bytes", () => encoding.GetBytes(new char[3], 0, 3, new byte[1], 0)); AssertExtensions.Throws<ArgumentException>("bytes", () => encoding.GetBytes("\uD800\uDC00".ToCharArray(), 0, 2, new byte[1], 0)); char[] chars = new char[3]; byte[] bytes = new byte[3]; byte[] smallBytes = new byte[1]; fixed (char* pChars = chars) fixed (byte* pBytes = bytes) fixed (byte* pSmallBytes = smallBytes) { char* pCharsLocal = pChars; byte* pBytesLocal = pBytes; byte* pSmallBytesLocal = pSmallBytes; // Bytes or chars is null AssertExtensions.Throws<ArgumentNullException>("chars", () => encoding.GetBytes((char*)null, 0, pBytesLocal, bytes.Length)); AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetBytes(pCharsLocal, chars.Length, (byte*)null, bytes.Length)); // CharCount or byteCount is negative AssertExtensions.Throws<ArgumentOutOfRangeException>("charCount", () => encoding.GetBytes(pCharsLocal, -1, pBytesLocal, bytes.Length)); AssertExtensions.Throws<ArgumentOutOfRangeException>("byteCount", () => encoding.GetBytes(pCharsLocal, chars.Length, pBytesLocal, -1)); // Bytes does not have enough capacity to accomodate result AssertExtensions.Throws<ArgumentException>("bytes", () => encoding.GetBytes(pCharsLocal, chars.Length, pSmallBytesLocal, smallBytes.Length)); } } [Theory] [MemberData(nameof(Encodings_TestData))] public static unsafe void GetCharCount_Invalid(Encoding encoding) { // Bytes is null AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetCharCount(null)); AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetCharCount(null, 0, 0)); // Index or count < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetCharCount(new byte[4], -1, 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetCharCount(new byte[4], 0, -1)); // Index + count > bytes.Length AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetCharCount(new byte[4], 5, 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetCharCount(new byte[4], 4, 1)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetCharCount(new byte[4], 3, 2)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetCharCount(new byte[4], 2, 3)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetCharCount(new byte[4], 1, 4)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetCharCount(new byte[4], 0, 5)); byte[] bytes = new byte[4]; fixed (byte* pBytes = bytes) { byte* pBytesLocal = pBytes; AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetCharCount(null, 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetCharCount(pBytesLocal, -1)); } } [Theory] [MemberData(nameof(Encodings_TestData))] public static unsafe void GetChars_Invalid(Encoding encoding) { // Bytes is null AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetChars(null)); AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetChars(null, 0, 0)); AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetChars(null, 0, 0, new char[0], 0)); // Chars is null AssertExtensions.Throws<ArgumentNullException>("chars", () => encoding.GetChars(new byte[4], 0, 4, null, 0)); // Index < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetChars(new byte[4], -1, 4)); AssertExtensions.Throws<ArgumentOutOfRangeException>("byteIndex", () => encoding.GetChars(new byte[4], -1, 4, new char[1], 0)); // Count < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetChars(new byte[4], 0, -1)); AssertExtensions.Throws<ArgumentOutOfRangeException>("byteCount", () => encoding.GetChars(new byte[4], 0, -1, new char[1], 0)); // Count > bytes.Length AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetChars(new byte[4], 0, 5)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetChars(new byte[4], 0, 5, new char[1], 0)); // Index + count > bytes.Length AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetChars(new byte[4], 5, 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetChars(new byte[4], 5, 0, new char[1], 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetChars(new byte[4], 4, 1)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetChars(new byte[4], 4, 1, new char[1], 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetChars(new byte[4], 3, 2)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetChars(new byte[4], 3, 2, new char[1], 0)); // CharIndex < 0 or >= chars.Length AssertExtensions.Throws<ArgumentOutOfRangeException>("charIndex", () => encoding.GetChars(new byte[4], 0, 4, new char[1], -1)); AssertExtensions.Throws<ArgumentOutOfRangeException>("charIndex", () => encoding.GetChars(new byte[4], 0, 4, new char[1], 2)); // Chars does not have enough capacity to accomodate result AssertExtensions.Throws<ArgumentException>("chars", () => encoding.GetChars(new byte[4], 0, 4, new char[1], 1)); byte[] bytes = new byte[encoding.GetMaxByteCount(2)]; char[] chars = new char[4]; char[] smallChars = new char[1]; fixed (byte* pBytes = bytes) fixed (char* pChars = chars) fixed (char* pSmallChars = smallChars) { byte* pBytesLocal = pBytes; char* pCharsLocal = pChars; char* pSmallCharsLocal = pSmallChars; // Bytes or chars is null AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetChars((byte*)null, 0, pCharsLocal, chars.Length)); AssertExtensions.Throws<ArgumentNullException>("chars", () => encoding.GetChars(pBytesLocal, bytes.Length, (char*)null, chars.Length)); // ByteCount or charCount is negative AssertExtensions.Throws<ArgumentOutOfRangeException>("byteCount", () => encoding.GetChars(pBytesLocal, -1, pCharsLocal, chars.Length)); AssertExtensions.Throws<ArgumentOutOfRangeException>("charCount", () => encoding.GetChars(pBytesLocal, bytes.Length, pCharsLocal, -1)); // Chars does not have enough capacity to accomodate result AssertExtensions.Throws<ArgumentException>("chars", () => encoding.GetChars(pBytesLocal, bytes.Length, pSmallCharsLocal, smallChars.Length)); } } [Theory] [MemberData(nameof(Encodings_TestData))] public static void GetMaxByteCount_Invalid(Encoding encoding) { AssertExtensions.Throws<ArgumentOutOfRangeException>("charCount", () => encoding.GetMaxByteCount(-1)); if (!encoding.IsSingleByte) { AssertExtensions.Throws<ArgumentOutOfRangeException>("charCount", () => encoding.GetMaxByteCount(int.MaxValue / 2)); } AssertExtensions.Throws<ArgumentOutOfRangeException>("charCount", () => encoding.GetMaxByteCount(int.MaxValue)); // Make sure that GetMaxByteCount respects the MaxCharCount property of EncoderFallback // However, Utf7Encoding ignores this if (!(encoding is UTF7Encoding)) { Encoding customizedMaxCharCountEncoding = Encoding.GetEncoding(encoding.CodePage, new HighMaxCharCountEncoderFallback(), DecoderFallback.ReplacementFallback); AssertExtensions.Throws<ArgumentOutOfRangeException>("charCount", () => customizedMaxCharCountEncoding.GetMaxByteCount(2)); } } [Theory] [MemberData(nameof(Encodings_TestData))] public static void GetMaxCharCount_Invalid(Encoding encoding) { AssertExtensions.Throws<ArgumentOutOfRangeException>("byteCount", () => encoding.GetMaxCharCount(-1)); // TODO: find a more generic way to find what byteCount is invalid if (encoding is UTF8Encoding) { AssertExtensions.Throws<ArgumentOutOfRangeException>("byteCount", () => encoding.GetMaxCharCount(int.MaxValue)); } // Make sure that GetMaxCharCount respects the MaxCharCount property of DecoderFallback // However, some encodings don't use the fallback mechanism and ignore it. if (!(encoding is UTF7Encoding) && !(encoding is UTF32Encoding) && !encoding.IsLatin1()) { Encoding customizedMaxCharCountEncoding = Encoding.GetEncoding(encoding.CodePage, EncoderFallback.ReplacementFallback, new HighMaxCharCountDecoderFallback()); AssertExtensions.Throws<ArgumentOutOfRangeException>("byteCount", () => customizedMaxCharCountEncoding.GetMaxCharCount(2)); } } [Theory] [MemberData(nameof(Encodings_TestData))] public static void GetString_Invalid(Encoding encoding) { // Bytes is null AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetString(null)); AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetString(null, 0, 0)); // Index or count < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>(encoding is ASCIIEncoding ? "byteIndex" : "index", () => encoding.GetString(new byte[1], -1, 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>(encoding is ASCIIEncoding ? "byteCount" : "count", () => encoding.GetString(new byte[1], 0, -1)); // Index + count > bytes.Length AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetString(new byte[1], 2, 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetString(new byte[1], 1, 1)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetString(new byte[1], 0, 2)); } internal static unsafe void Encode_Invalid(Encoding encoding, string chars, int index, int count) { Assert.Equal(EncoderFallback.ExceptionFallback, encoding.EncoderFallback); char[] charsArray = chars.ToCharArray(); byte[] bytes = new byte[encoding.GetMaxByteCount(count)]; if (index == 0 && count == chars.Length) { Assert.Throws<EncoderFallbackException>(() => encoding.GetByteCount(chars)); Assert.Throws<EncoderFallbackException>(() => encoding.GetByteCount(charsArray)); Assert.Throws<EncoderFallbackException>(() => encoding.GetBytes(chars)); Assert.Throws<EncoderFallbackException>(() => encoding.GetBytes(charsArray)); } Assert.Throws<EncoderFallbackException>(() => encoding.GetByteCount(charsArray, index, count)); Assert.Throws<EncoderFallbackException>(() => encoding.GetBytes(charsArray, index, count)); Assert.Throws<EncoderFallbackException>(() => encoding.GetBytes(chars, index, count, bytes, 0)); Assert.Throws<EncoderFallbackException>(() => encoding.GetBytes(charsArray, index, count, bytes, 0)); fixed (char* pChars = chars) fixed (byte* pBytes = bytes) { char* pCharsLocal = pChars; byte* pBytesLocal = pBytes; Assert.Throws<EncoderFallbackException>(() => encoding.GetByteCount(pCharsLocal + index, count)); Assert.Throws<EncoderFallbackException>(() => encoding.GetBytes(pCharsLocal + index, count, pBytesLocal, bytes.Length)); } } internal static unsafe void Decode_Invalid(Encoding encoding, byte[] bytes, int index, int count) { Assert.Equal(DecoderFallback.ExceptionFallback, encoding.DecoderFallback); char[] chars = new char[encoding.GetMaxCharCount(count)]; if (index == 0 && count == bytes.Length) { Assert.Throws<DecoderFallbackException>(() => encoding.GetCharCount(bytes)); Assert.Throws<DecoderFallbackException>(() => encoding.GetChars(bytes)); Assert.Throws<DecoderFallbackException>(() => encoding.GetString(bytes)); } Assert.Throws<DecoderFallbackException>(() => encoding.GetCharCount(bytes, index, count)); Assert.Throws<DecoderFallbackException>(() => encoding.GetChars(bytes, index, count)); Assert.Throws<DecoderFallbackException>(() => encoding.GetString(bytes, index, count)); Assert.Throws<DecoderFallbackException>(() => encoding.GetChars(bytes, index, count, chars, 0)); fixed (byte* pBytes = bytes) fixed (char* pChars = chars) { byte* pBytesLocal = pBytes; char* pCharsLocal = pChars; Assert.Throws<DecoderFallbackException>(() => encoding.GetCharCount(pBytesLocal + index, count)); Assert.Throws<DecoderFallbackException>(() => encoding.GetChars(pBytesLocal + index, count, pCharsLocal, chars.Length)); Assert.Throws<DecoderFallbackException>(() => encoding.GetString(pBytesLocal + index, count)); } } public static IEnumerable<object[]> Encoders_TestData() { foreach (object[] encodingTestData in Encodings_TestData()) { Encoding encoding = (Encoding)encodingTestData[0]; yield return new object[] { encoding.GetEncoder(), true }; yield return new object[] { encoding.GetEncoder(), false }; } } [Theory] [MemberData(nameof(Encoders_TestData))] public static void Encoder_GetByteCount_Invalid(Encoder encoder, bool flush) { // Chars is null AssertExtensions.Throws<ArgumentNullException>("chars", () => encoder.GetByteCount(null, 0, 0, flush)); // Index is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoder.GetByteCount(new char[4], -1, 0, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoder.GetByteCount(new char[4], 5, 0, flush)); // Count is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => encoder.GetByteCount(new char[4], 0, -1, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoder.GetByteCount(new char[4], 0, 5, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoder.GetByteCount(new char[4], 1, 4, flush)); } [Theory] [MemberData(nameof(Encoders_TestData))] public static void Encoder_GetBytes_Invalid(Encoder encoder, bool flush) { // Chars is null AssertExtensions.Throws<ArgumentNullException>("chars", () => encoder.GetBytes(null, 0, 0, new byte[4], 0, flush)); // CharIndex is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("charIndex", () => encoder.GetBytes(new char[4], -1, 0, new byte[4], 0, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoder.GetBytes(new char[4], 5, 0, new byte[4], 0, flush)); // CharCount is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("charCount", () => encoder.GetBytes(new char[4], 0, -1, new byte[4], 0, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoder.GetBytes(new char[4], 0, 5, new byte[4], 0, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoder.GetBytes(new char[4], 1, 4, new byte[4], 0, flush)); // Bytes is null AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoder.GetBytes(new char[1], 0, 1, null, 0, flush)); // ByteIndex is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("byteIndex", () => encoder.GetBytes(new char[1], 0, 1, new byte[4], -1, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("byteIndex", () => encoder.GetBytes(new char[1], 0, 1, new byte[4], 5, flush)); // Bytes does not have enough space int byteCount = encoder.GetByteCount(new char[] { 'a' }, 0, 1, flush); AssertExtensions.Throws<ArgumentException>("bytes", () => encoder.GetBytes(new char[] { 'a' }, 0, 1, new byte[byteCount - 1], 0, flush)); } [Theory] [MemberData(nameof(Encoders_TestData))] public static void Encoder_Convert_Invalid(Encoder encoder, bool flush) { int charsUsed = 0; int bytesUsed = 0; bool completed = false; void VerifyOutParams() { Assert.Equal(0, charsUsed); Assert.Equal(0, bytesUsed); Assert.False(completed); } // Chars is null AssertExtensions.Throws<ArgumentNullException>("chars", () => encoder.Convert(null, 0, 0, new byte[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // CharIndex is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("charIndex", () => encoder.Convert(new char[4], -1, 0, new byte[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoder.Convert(new char[4], 5, 0, new byte[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // CharCount is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("charCount", () => encoder.Convert(new char[4], 0, -1, new byte[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoder.Convert(new char[4], 0, 5, new byte[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoder.Convert(new char[4], 1, 4, new byte[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // Bytes is null AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoder.Convert(new char[1], 0, 1, null, 0, 0, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // ByteIndex is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("byteIndex", () => encoder.Convert(new char[1], 0, 0, new byte[4], -1, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoder.Convert(new char[1], 0, 0, new byte[4], 5, 0, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // ByteCount is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("byteCount", () => encoder.Convert(new char[1], 0, 0, new byte[4], 0, -1, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoder.Convert(new char[1], 0, 0, new byte[4], 0, 5, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoder.Convert(new char[1], 0, 0, new byte[4], 1, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // Bytes does not have enough space int byteCount = encoder.GetByteCount(new char[] { 'a' }, 0, 1, flush); AssertExtensions.Throws<ArgumentException>("bytes", () => encoder.Convert(new char[] { 'a' }, 0, 1, new byte[byteCount - 1], 0, byteCount - 1, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); } public static IEnumerable<object[]> Decoders_TestData() { foreach (object[] encodingTestData in Encodings_TestData()) { Encoding encoding = (Encoding)encodingTestData[0]; yield return new object[] { encoding, encoding.GetDecoder(), true }; yield return new object[] { encoding, encoding.GetDecoder(), false }; } } [Theory] [MemberData(nameof(Decoders_TestData))] public static void Decoder_GetCharCount_Invalid(Encoding encoding, Decoder decoder, bool flush) { _ = encoding; // Bytes is null AssertExtensions.Throws<ArgumentNullException>("bytes", () => decoder.GetCharCount(null, 0, 0, flush)); // Index is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => decoder.GetCharCount(new byte[4], -1, 0, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.GetCharCount(new byte[4], 5, 0, flush)); // Count is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => decoder.GetCharCount(new byte[4], 0, -1, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.GetCharCount(new byte[4], 0, 5, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.GetCharCount(new byte[4], 1, 4, flush)); } [Theory] [MemberData(nameof(Decoders_TestData))] public static void Decoder_GetChars_Invalid(Encoding encoding, Decoder decoder, bool flush) { _ = encoding; // Bytes is null AssertExtensions.Throws<ArgumentNullException>("bytes", () => decoder.GetChars(null, 0, 0, new char[4], 0, flush)); // ByteIndex is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("byteIndex", () => decoder.GetChars(new byte[4], -1, 0, new char[4], 0, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.GetChars(new byte[4], 5, 0, new char[4], 0, flush)); // ByteCount is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("byteCount", () => decoder.GetChars(new byte[4], 0, -1, new char[4], 0, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.GetChars(new byte[4], 0, 5, new char[4], 0, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.GetChars(new byte [4], 1, 4, new char[4], 0, flush)); // Chars is null AssertExtensions.Throws<ArgumentNullException>("chars", () => decoder.GetChars(new byte[1], 0, 1, null, 0, flush)); // CharIndex is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("charIndex", () => decoder.GetChars(new byte[1], 0, 1, new char[4], -1, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("charIndex", () => decoder.GetChars(new byte[1], 0, 1, new char[4], 5, flush)); // Chars does not have enough space int charCount = decoder.GetCharCount(new byte[4], 0, 4, flush); AssertExtensions.Throws<ArgumentException>("chars", () => decoder.GetChars(new byte[4], 0, 4, new char[charCount - 1], 0, flush)); } [Theory] [MemberData(nameof(Decoders_TestData))] public static void Decoder_Convert_Invalid(Encoding encoding, Decoder decoder, bool flush) { _ = encoding; int bytesUsed = 0; int charsUsed = 0; bool completed = false; void VerifyOutParams() { Assert.Equal(0, bytesUsed); Assert.Equal(0, charsUsed); Assert.False(completed); } // Bytes is null AssertExtensions.Throws<ArgumentNullException>("bytes", () => decoder.Convert(null, 0, 0, new char[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // ByteIndex is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("byteIndex", () => decoder.Convert(new byte[4], -1, 0, new char[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.Convert(new byte[4], 5, 0, new char[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // ByteCount is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("byteCount", () => decoder.Convert(new byte[4], 0, -1, new char[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.Convert(new byte[4], 0, 5, new char[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.Convert(new byte[4], 1, 4, new char[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // Chars is null AssertExtensions.Throws<ArgumentNullException>("chars", () => decoder.Convert(new byte[1], 0, 1, null, 0, 0, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // CharIndex is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("charIndex", () => decoder.Convert(new byte[1], 0, 0, new char[4], -1, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => decoder.Convert(new byte[1], 0, 0, new char[4], 5, 0, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // CharCount is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("charCount", () => decoder.Convert(new byte[1], 0, 0, new char[4], 0, -1, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => decoder.Convert(new byte[1], 0, 0, new char[4], 0, 5, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => decoder.Convert(new byte[1], 0, 0, new char[4], 1, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // Chars does not have enough space AssertExtensions.Throws<ArgumentException>("chars", () => decoder.Convert(new byte[4], 0, 4, new char[0], 0, 0, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); } [Theory] [MemberData(nameof(Encodings_TestData))] public static unsafe void GetByteCount_Invalid_NetCoreApp(Encoding encoding) { // Chars is null AssertExtensions.Throws<ArgumentNullException>("s", () => encoding.GetByteCount((string)null, 0, 0)); // Index < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", -1, 0)); // Count < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetByteCount("abc", 0, -1)); // Index + count > chars.Length AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", 0, 4)); AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", 1, 3)); AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", 2, 2)); AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", 3, 1)); AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", 4, 0)); } [Theory] [MemberData(nameof(Encodings_TestData))] public static unsafe void GetBytes_Invalid_NetCoreApp(Encoding encoding) { // Source is null AssertExtensions.Throws<ArgumentNullException>("s", () => encoding.GetBytes((string)null, 0, 0)); // CharIndex < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetBytes("a", -1, 0)); // CharCount < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetBytes("a", 0, -1)); // CharIndex + charCount > source.Length AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetBytes("a", 2, 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetBytes("a", 1, 1)); AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetBytes("a", 0, 2)); } } public class HighMaxCharCountEncoderFallback : EncoderFallback { public override int MaxCharCount => int.MaxValue; public override EncoderFallbackBuffer CreateFallbackBuffer() => ReplacementFallback.CreateFallbackBuffer(); } public class HighMaxCharCountDecoderFallback : DecoderFallback { public override int MaxCharCount => int.MaxValue; public override DecoderFallbackBuffer CreateFallbackBuffer() => ReplacementFallback.CreateFallbackBuffer(); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using Xunit; namespace System.Text.Tests { public static class NegativeEncodingTests { public static IEnumerable<object[]> Encodings_TestData() { yield return new object[] { new UnicodeEncoding(false, false) }; yield return new object[] { new UnicodeEncoding(true, false) }; yield return new object[] { new UnicodeEncoding(true, true) }; yield return new object[] { new UnicodeEncoding(true, true) }; yield return new object[] { Encoding.BigEndianUnicode }; yield return new object[] { Encoding.Unicode }; yield return new object[] { new UTF7Encoding(true) }; yield return new object[] { new UTF7Encoding(false) }; yield return new object[] { Encoding.UTF7 }; yield return new object[] { new UTF8Encoding(true, true) }; yield return new object[] { new UTF8Encoding(false, true) }; yield return new object[] { new UTF8Encoding(true, false) }; yield return new object[] { new UTF8Encoding(false, false) }; yield return new object[] { Encoding.UTF8 }; yield return new object[] { new ASCIIEncoding() }; yield return new object[] { Encoding.ASCII }; yield return new object[] { new UTF32Encoding(true, true, true) }; yield return new object[] { new UTF32Encoding(true, true, false) }; yield return new object[] { new UTF32Encoding(true, false, false) }; yield return new object[] { new UTF32Encoding(true, false, true) }; yield return new object[] { new UTF32Encoding(false, true, true) }; yield return new object[] { new UTF32Encoding(false, true, false) }; yield return new object[] { new UTF32Encoding(false, false, false) }; yield return new object[] { new UTF32Encoding(false, false, true) }; yield return new object[] { Encoding.UTF32 }; yield return new object[] { Encoding.GetEncoding("latin1") }; } [Theory] [MemberData(nameof(Encodings_TestData))] public static unsafe void GetByteCount_Invalid(Encoding encoding) { // Chars is null if (PlatformDetection.IsNetCore) { AssertExtensions.Throws<ArgumentNullException>((encoding is ASCIIEncoding || encoding is UTF8Encoding) ? "chars" : "s", () => encoding.GetByteCount((string)null)); } else { AssertExtensions.Throws<ArgumentNullException>((encoding is ASCIIEncoding) ? "chars" : "s", () => encoding.GetByteCount((string)null)); } AssertExtensions.Throws<ArgumentNullException>("chars", () => encoding.GetByteCount((char[])null)); AssertExtensions.Throws<ArgumentNullException>("chars", () => encoding.GetByteCount((char[])null, 0, 0)); // Index < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount(new char[3], -1, 0)); // Count < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetByteCount(new char[3], 0, -1)); // Index + count > chars.Length AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoding.GetByteCount(new char[3], 0, 4)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoding.GetByteCount(new char[3], 1, 3)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoding.GetByteCount(new char[3], 2, 2)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoding.GetByteCount(new char[3], 3, 1)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoding.GetByteCount(new char[3], 4, 0)); char[] chars = new char[3]; fixed (char* pChars = chars) { char* pCharsLocal = pChars; AssertExtensions.Throws<ArgumentNullException>("chars", () => encoding.GetByteCount(null, 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetByteCount(pCharsLocal, -1)); } } [Theory] [MemberData(nameof(Encodings_TestData))] public static unsafe void GetBytes_Invalid(Encoding encoding) { string expectedStringParamName = encoding is ASCIIEncoding ? "chars" : "s"; // Source is null AssertExtensions.Throws<ArgumentNullException>("s", () => encoding.GetBytes((string)null)); AssertExtensions.Throws<ArgumentNullException>("chars", () => encoding.GetBytes((char[])null)); AssertExtensions.Throws<ArgumentNullException>("chars", () => encoding.GetBytes((char[])null, 0, 0)); AssertExtensions.Throws<ArgumentNullException>(expectedStringParamName, () => encoding.GetBytes((string)null, 0, 0, new byte[1], 0)); AssertExtensions.Throws<ArgumentNullException>("chars", () => encoding.GetBytes((char[])null, 0, 0, new byte[1], 0)); // Bytes is null AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetBytes("abc", 0, 3, null, 0)); AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetBytes(new char[3], 0, 3, null, 0)); // Char index < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetBytes(new char[1], -1, 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("charIndex", () => encoding.GetBytes("a", -1, 0, new byte[1], 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("charIndex", () => encoding.GetBytes(new char[1], -1, 0, new byte[1], 0)); // Char count < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetBytes(new char[1], 0, -1)); AssertExtensions.Throws<ArgumentOutOfRangeException>("charCount", () => encoding.GetBytes("a", 0, -1, new byte[1], 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("charCount", () => encoding.GetBytes(new char[1], 0, -1, new byte[1], 0)); // Char index + count > source.Length AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoding.GetBytes(new char[1], 2, 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>(expectedStringParamName, () => encoding.GetBytes("a", 2, 0, new byte[1], 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoding.GetBytes(new char[1], 2, 0, new byte[1], 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoding.GetBytes(new char[1], 1, 1)); AssertExtensions.Throws<ArgumentOutOfRangeException>(expectedStringParamName, () => encoding.GetBytes("a", 1, 1, new byte[1], 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoding.GetBytes(new char[1], 1, 1, new byte[1], 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoding.GetBytes(new char[1], 0, 2)); AssertExtensions.Throws<ArgumentOutOfRangeException>(expectedStringParamName, () => encoding.GetBytes("a", 0, 2, new byte[1], 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoding.GetBytes(new char[1], 0, 2, new byte[1], 0)); // Byte index < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("byteIndex", () => encoding.GetBytes("a", 0, 1, new byte[1], -1)); AssertExtensions.Throws<ArgumentOutOfRangeException>("byteIndex", () => encoding.GetBytes(new char[1], 0, 1, new byte[1], -1)); // Byte index > bytes.Length AssertExtensions.Throws<ArgumentOutOfRangeException>("byteIndex", () => encoding.GetBytes("a", 0, 1, new byte[1], 2)); AssertExtensions.Throws<ArgumentOutOfRangeException>("byteIndex", () => encoding.GetBytes(new char[1], 0, 1, new byte[1], 2)); // Bytes does not have enough capacity to accomodate result AssertExtensions.Throws<ArgumentException>("bytes", () => encoding.GetBytes("a", 0, 1, new byte[0], 0)); AssertExtensions.Throws<ArgumentException>("bytes", () => encoding.GetBytes("abc", 0, 3, new byte[1], 0)); AssertExtensions.Throws<ArgumentException>("bytes", () => encoding.GetBytes("\uD800\uDC00", 0, 2, new byte[1], 0)); AssertExtensions.Throws<ArgumentException>("bytes", () => encoding.GetBytes(new char[1], 0, 1, new byte[0], 0)); AssertExtensions.Throws<ArgumentException>("bytes", () => encoding.GetBytes(new char[3], 0, 3, new byte[1], 0)); AssertExtensions.Throws<ArgumentException>("bytes", () => encoding.GetBytes("\uD800\uDC00".ToCharArray(), 0, 2, new byte[1], 0)); char[] chars = new char[3]; byte[] bytes = new byte[3]; byte[] smallBytes = new byte[1]; fixed (char* pChars = chars) fixed (byte* pBytes = bytes) fixed (byte* pSmallBytes = smallBytes) { char* pCharsLocal = pChars; byte* pBytesLocal = pBytes; byte* pSmallBytesLocal = pSmallBytes; // Bytes or chars is null AssertExtensions.Throws<ArgumentNullException>("chars", () => encoding.GetBytes((char*)null, 0, pBytesLocal, bytes.Length)); AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetBytes(pCharsLocal, chars.Length, (byte*)null, bytes.Length)); // CharCount or byteCount is negative AssertExtensions.Throws<ArgumentOutOfRangeException>("charCount", () => encoding.GetBytes(pCharsLocal, -1, pBytesLocal, bytes.Length)); AssertExtensions.Throws<ArgumentOutOfRangeException>("byteCount", () => encoding.GetBytes(pCharsLocal, chars.Length, pBytesLocal, -1)); // Bytes does not have enough capacity to accomodate result AssertExtensions.Throws<ArgumentException>("bytes", () => encoding.GetBytes(pCharsLocal, chars.Length, pSmallBytesLocal, smallBytes.Length)); } } [Theory] [MemberData(nameof(Encodings_TestData))] public static unsafe void GetCharCount_Invalid(Encoding encoding) { // Bytes is null AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetCharCount(null)); AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetCharCount(null, 0, 0)); // Index or count < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetCharCount(new byte[4], -1, 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetCharCount(new byte[4], 0, -1)); // Index + count > bytes.Length AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetCharCount(new byte[4], 5, 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetCharCount(new byte[4], 4, 1)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetCharCount(new byte[4], 3, 2)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetCharCount(new byte[4], 2, 3)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetCharCount(new byte[4], 1, 4)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetCharCount(new byte[4], 0, 5)); byte[] bytes = new byte[4]; fixed (byte* pBytes = bytes) { byte* pBytesLocal = pBytes; AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetCharCount(null, 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetCharCount(pBytesLocal, -1)); } } [Theory] [MemberData(nameof(Encodings_TestData))] public static unsafe void GetChars_Invalid(Encoding encoding) { // Bytes is null AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetChars(null)); AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetChars(null, 0, 0)); AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetChars(null, 0, 0, new char[0], 0)); // Chars is null AssertExtensions.Throws<ArgumentNullException>("chars", () => encoding.GetChars(new byte[4], 0, 4, null, 0)); // Index < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetChars(new byte[4], -1, 4)); AssertExtensions.Throws<ArgumentOutOfRangeException>("byteIndex", () => encoding.GetChars(new byte[4], -1, 4, new char[1], 0)); // Count < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetChars(new byte[4], 0, -1)); AssertExtensions.Throws<ArgumentOutOfRangeException>("byteCount", () => encoding.GetChars(new byte[4], 0, -1, new char[1], 0)); // Count > bytes.Length AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetChars(new byte[4], 0, 5)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetChars(new byte[4], 0, 5, new char[1], 0)); // Index + count > bytes.Length AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetChars(new byte[4], 5, 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetChars(new byte[4], 5, 0, new char[1], 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetChars(new byte[4], 4, 1)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetChars(new byte[4], 4, 1, new char[1], 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetChars(new byte[4], 3, 2)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetChars(new byte[4], 3, 2, new char[1], 0)); // CharIndex < 0 or >= chars.Length AssertExtensions.Throws<ArgumentOutOfRangeException>("charIndex", () => encoding.GetChars(new byte[4], 0, 4, new char[1], -1)); AssertExtensions.Throws<ArgumentOutOfRangeException>("charIndex", () => encoding.GetChars(new byte[4], 0, 4, new char[1], 2)); // Chars does not have enough capacity to accomodate result AssertExtensions.Throws<ArgumentException>("chars", () => encoding.GetChars(new byte[4], 0, 4, new char[1], 1)); byte[] bytes = new byte[encoding.GetMaxByteCount(2)]; char[] chars = new char[4]; char[] smallChars = new char[1]; fixed (byte* pBytes = bytes) fixed (char* pChars = chars) fixed (char* pSmallChars = smallChars) { byte* pBytesLocal = pBytes; char* pCharsLocal = pChars; char* pSmallCharsLocal = pSmallChars; // Bytes or chars is null AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetChars((byte*)null, 0, pCharsLocal, chars.Length)); AssertExtensions.Throws<ArgumentNullException>("chars", () => encoding.GetChars(pBytesLocal, bytes.Length, (char*)null, chars.Length)); // ByteCount or charCount is negative AssertExtensions.Throws<ArgumentOutOfRangeException>("byteCount", () => encoding.GetChars(pBytesLocal, -1, pCharsLocal, chars.Length)); AssertExtensions.Throws<ArgumentOutOfRangeException>("charCount", () => encoding.GetChars(pBytesLocal, bytes.Length, pCharsLocal, -1)); // Chars does not have enough capacity to accomodate result AssertExtensions.Throws<ArgumentException>("chars", () => encoding.GetChars(pBytesLocal, bytes.Length, pSmallCharsLocal, smallChars.Length)); } } [Theory] [MemberData(nameof(Encodings_TestData))] public static void GetMaxByteCount_Invalid(Encoding encoding) { AssertExtensions.Throws<ArgumentOutOfRangeException>("charCount", () => encoding.GetMaxByteCount(-1)); if (!encoding.IsSingleByte) { AssertExtensions.Throws<ArgumentOutOfRangeException>("charCount", () => encoding.GetMaxByteCount(int.MaxValue / 2)); } AssertExtensions.Throws<ArgumentOutOfRangeException>("charCount", () => encoding.GetMaxByteCount(int.MaxValue)); // Make sure that GetMaxByteCount respects the MaxCharCount property of EncoderFallback // However, Utf7Encoding ignores this if (!(encoding is UTF7Encoding)) { Encoding customizedMaxCharCountEncoding = Encoding.GetEncoding(encoding.CodePage, new HighMaxCharCountEncoderFallback(), DecoderFallback.ReplacementFallback); AssertExtensions.Throws<ArgumentOutOfRangeException>("charCount", () => customizedMaxCharCountEncoding.GetMaxByteCount(2)); } } [Theory] [MemberData(nameof(Encodings_TestData))] public static void GetMaxCharCount_Invalid(Encoding encoding) { AssertExtensions.Throws<ArgumentOutOfRangeException>("byteCount", () => encoding.GetMaxCharCount(-1)); // TODO: find a more generic way to find what byteCount is invalid if (encoding is UTF8Encoding) { AssertExtensions.Throws<ArgumentOutOfRangeException>("byteCount", () => encoding.GetMaxCharCount(int.MaxValue)); } // Make sure that GetMaxCharCount respects the MaxCharCount property of DecoderFallback // However, some encodings don't use the fallback mechanism and ignore it. if (!(encoding is UTF7Encoding) && !(encoding is UTF32Encoding) && !encoding.IsLatin1()) { Encoding customizedMaxCharCountEncoding = Encoding.GetEncoding(encoding.CodePage, EncoderFallback.ReplacementFallback, new HighMaxCharCountDecoderFallback()); AssertExtensions.Throws<ArgumentOutOfRangeException>("byteCount", () => customizedMaxCharCountEncoding.GetMaxCharCount(2)); } } [Theory] [MemberData(nameof(Encodings_TestData))] public static void GetString_Invalid(Encoding encoding) { // Bytes is null AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetString(null)); AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoding.GetString(null, 0, 0)); // Index or count < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>(encoding is ASCIIEncoding ? "byteIndex" : "index", () => encoding.GetString(new byte[1], -1, 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>(encoding is ASCIIEncoding ? "byteCount" : "count", () => encoding.GetString(new byte[1], 0, -1)); // Index + count > bytes.Length AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetString(new byte[1], 2, 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetString(new byte[1], 1, 1)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoding.GetString(new byte[1], 0, 2)); } internal static unsafe void Encode_Invalid(Encoding encoding, string chars, int index, int count) { Assert.Equal(EncoderFallback.ExceptionFallback, encoding.EncoderFallback); char[] charsArray = chars.ToCharArray(); byte[] bytes = new byte[encoding.GetMaxByteCount(count)]; if (index == 0 && count == chars.Length) { Assert.Throws<EncoderFallbackException>(() => encoding.GetByteCount(chars)); Assert.Throws<EncoderFallbackException>(() => encoding.GetByteCount(charsArray)); Assert.Throws<EncoderFallbackException>(() => encoding.GetBytes(chars)); Assert.Throws<EncoderFallbackException>(() => encoding.GetBytes(charsArray)); } Assert.Throws<EncoderFallbackException>(() => encoding.GetByteCount(charsArray, index, count)); Assert.Throws<EncoderFallbackException>(() => encoding.GetBytes(charsArray, index, count)); Assert.Throws<EncoderFallbackException>(() => encoding.GetBytes(chars, index, count, bytes, 0)); Assert.Throws<EncoderFallbackException>(() => encoding.GetBytes(charsArray, index, count, bytes, 0)); fixed (char* pChars = chars) fixed (byte* pBytes = bytes) { char* pCharsLocal = pChars; byte* pBytesLocal = pBytes; Assert.Throws<EncoderFallbackException>(() => encoding.GetByteCount(pCharsLocal + index, count)); Assert.Throws<EncoderFallbackException>(() => encoding.GetBytes(pCharsLocal + index, count, pBytesLocal, bytes.Length)); } } internal static unsafe void Decode_Invalid(Encoding encoding, byte[] bytes, int index, int count) { Assert.Equal(DecoderFallback.ExceptionFallback, encoding.DecoderFallback); char[] chars = new char[encoding.GetMaxCharCount(count)]; if (index == 0 && count == bytes.Length) { Assert.Throws<DecoderFallbackException>(() => encoding.GetCharCount(bytes)); Assert.Throws<DecoderFallbackException>(() => encoding.GetChars(bytes)); Assert.Throws<DecoderFallbackException>(() => encoding.GetString(bytes)); } Assert.Throws<DecoderFallbackException>(() => encoding.GetCharCount(bytes, index, count)); Assert.Throws<DecoderFallbackException>(() => encoding.GetChars(bytes, index, count)); Assert.Throws<DecoderFallbackException>(() => encoding.GetString(bytes, index, count)); Assert.Throws<DecoderFallbackException>(() => encoding.GetChars(bytes, index, count, chars, 0)); fixed (byte* pBytes = bytes) fixed (char* pChars = chars) { byte* pBytesLocal = pBytes; char* pCharsLocal = pChars; Assert.Throws<DecoderFallbackException>(() => encoding.GetCharCount(pBytesLocal + index, count)); Assert.Throws<DecoderFallbackException>(() => encoding.GetChars(pBytesLocal + index, count, pCharsLocal, chars.Length)); Assert.Throws<DecoderFallbackException>(() => encoding.GetString(pBytesLocal + index, count)); } } public static IEnumerable<object[]> Encoders_TestData() { foreach (object[] encodingTestData in Encodings_TestData()) { Encoding encoding = (Encoding)encodingTestData[0]; yield return new object[] { encoding.GetEncoder(), true }; yield return new object[] { encoding.GetEncoder(), false }; } } [Theory] [MemberData(nameof(Encoders_TestData))] public static void Encoder_GetByteCount_Invalid(Encoder encoder, bool flush) { // Chars is null AssertExtensions.Throws<ArgumentNullException>("chars", () => encoder.GetByteCount(null, 0, 0, flush)); // Index is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoder.GetByteCount(new char[4], -1, 0, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoder.GetByteCount(new char[4], 5, 0, flush)); // Count is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => encoder.GetByteCount(new char[4], 0, -1, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoder.GetByteCount(new char[4], 0, 5, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoder.GetByteCount(new char[4], 1, 4, flush)); } [Theory] [MemberData(nameof(Encoders_TestData))] public static void Encoder_GetBytes_Invalid(Encoder encoder, bool flush) { // Chars is null AssertExtensions.Throws<ArgumentNullException>("chars", () => encoder.GetBytes(null, 0, 0, new byte[4], 0, flush)); // CharIndex is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("charIndex", () => encoder.GetBytes(new char[4], -1, 0, new byte[4], 0, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoder.GetBytes(new char[4], 5, 0, new byte[4], 0, flush)); // CharCount is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("charCount", () => encoder.GetBytes(new char[4], 0, -1, new byte[4], 0, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoder.GetBytes(new char[4], 0, 5, new byte[4], 0, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoder.GetBytes(new char[4], 1, 4, new byte[4], 0, flush)); // Bytes is null AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoder.GetBytes(new char[1], 0, 1, null, 0, flush)); // ByteIndex is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("byteIndex", () => encoder.GetBytes(new char[1], 0, 1, new byte[4], -1, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("byteIndex", () => encoder.GetBytes(new char[1], 0, 1, new byte[4], 5, flush)); // Bytes does not have enough space int byteCount = encoder.GetByteCount(new char[] { 'a' }, 0, 1, flush); AssertExtensions.Throws<ArgumentException>("bytes", () => encoder.GetBytes(new char[] { 'a' }, 0, 1, new byte[byteCount - 1], 0, flush)); } [Theory] [MemberData(nameof(Encoders_TestData))] public static void Encoder_Convert_Invalid(Encoder encoder, bool flush) { int charsUsed = 0; int bytesUsed = 0; bool completed = false; void VerifyOutParams() { Assert.Equal(0, charsUsed); Assert.Equal(0, bytesUsed); Assert.False(completed); } // Chars is null AssertExtensions.Throws<ArgumentNullException>("chars", () => encoder.Convert(null, 0, 0, new byte[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // CharIndex is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("charIndex", () => encoder.Convert(new char[4], -1, 0, new byte[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoder.Convert(new char[4], 5, 0, new byte[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // CharCount is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("charCount", () => encoder.Convert(new char[4], 0, -1, new byte[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoder.Convert(new char[4], 0, 5, new byte[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => encoder.Convert(new char[4], 1, 4, new byte[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // Bytes is null AssertExtensions.Throws<ArgumentNullException>("bytes", () => encoder.Convert(new char[1], 0, 1, null, 0, 0, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // ByteIndex is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("byteIndex", () => encoder.Convert(new char[1], 0, 0, new byte[4], -1, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoder.Convert(new char[1], 0, 0, new byte[4], 5, 0, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // ByteCount is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("byteCount", () => encoder.Convert(new char[1], 0, 0, new byte[4], 0, -1, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoder.Convert(new char[1], 0, 0, new byte[4], 0, 5, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => encoder.Convert(new char[1], 0, 0, new byte[4], 1, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // Bytes does not have enough space int byteCount = encoder.GetByteCount(new char[] { 'a' }, 0, 1, flush); AssertExtensions.Throws<ArgumentException>("bytes", () => encoder.Convert(new char[] { 'a' }, 0, 1, new byte[byteCount - 1], 0, byteCount - 1, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); } public static IEnumerable<object[]> Decoders_TestData() { foreach (object[] encodingTestData in Encodings_TestData()) { Encoding encoding = (Encoding)encodingTestData[0]; yield return new object[] { encoding, encoding.GetDecoder(), true }; yield return new object[] { encoding, encoding.GetDecoder(), false }; } } [Theory] [MemberData(nameof(Decoders_TestData))] public static void Decoder_GetCharCount_Invalid(Encoding encoding, Decoder decoder, bool flush) { _ = encoding; // Bytes is null AssertExtensions.Throws<ArgumentNullException>("bytes", () => decoder.GetCharCount(null, 0, 0, flush)); // Index is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => decoder.GetCharCount(new byte[4], -1, 0, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.GetCharCount(new byte[4], 5, 0, flush)); // Count is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => decoder.GetCharCount(new byte[4], 0, -1, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.GetCharCount(new byte[4], 0, 5, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.GetCharCount(new byte[4], 1, 4, flush)); } [Theory] [MemberData(nameof(Decoders_TestData))] public static void Decoder_GetChars_Invalid(Encoding encoding, Decoder decoder, bool flush) { _ = encoding; // Bytes is null AssertExtensions.Throws<ArgumentNullException>("bytes", () => decoder.GetChars(null, 0, 0, new char[4], 0, flush)); // ByteIndex is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("byteIndex", () => decoder.GetChars(new byte[4], -1, 0, new char[4], 0, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.GetChars(new byte[4], 5, 0, new char[4], 0, flush)); // ByteCount is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("byteCount", () => decoder.GetChars(new byte[4], 0, -1, new char[4], 0, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.GetChars(new byte[4], 0, 5, new char[4], 0, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.GetChars(new byte [4], 1, 4, new char[4], 0, flush)); // Chars is null AssertExtensions.Throws<ArgumentNullException>("chars", () => decoder.GetChars(new byte[1], 0, 1, null, 0, flush)); // CharIndex is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("charIndex", () => decoder.GetChars(new byte[1], 0, 1, new char[4], -1, flush)); AssertExtensions.Throws<ArgumentOutOfRangeException>("charIndex", () => decoder.GetChars(new byte[1], 0, 1, new char[4], 5, flush)); // Chars does not have enough space int charCount = decoder.GetCharCount(new byte[4], 0, 4, flush); AssertExtensions.Throws<ArgumentException>("chars", () => decoder.GetChars(new byte[4], 0, 4, new char[charCount - 1], 0, flush)); } [Theory] [MemberData(nameof(Decoders_TestData))] public static void Decoder_Convert_Invalid(Encoding encoding, Decoder decoder, bool flush) { _ = encoding; int bytesUsed = 0; int charsUsed = 0; bool completed = false; void VerifyOutParams() { Assert.Equal(0, bytesUsed); Assert.Equal(0, charsUsed); Assert.False(completed); } // Bytes is null AssertExtensions.Throws<ArgumentNullException>("bytes", () => decoder.Convert(null, 0, 0, new char[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // ByteIndex is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("byteIndex", () => decoder.Convert(new byte[4], -1, 0, new char[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.Convert(new byte[4], 5, 0, new char[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // ByteCount is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("byteCount", () => decoder.Convert(new byte[4], 0, -1, new char[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.Convert(new byte[4], 0, 5, new char[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.Convert(new byte[4], 1, 4, new char[4], 0, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // Chars is null AssertExtensions.Throws<ArgumentNullException>("chars", () => decoder.Convert(new byte[1], 0, 1, null, 0, 0, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // CharIndex is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("charIndex", () => decoder.Convert(new byte[1], 0, 0, new char[4], -1, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => decoder.Convert(new byte[1], 0, 0, new char[4], 5, 0, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // CharCount is invalid AssertExtensions.Throws<ArgumentOutOfRangeException>("charCount", () => decoder.Convert(new byte[1], 0, 0, new char[4], 0, -1, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => decoder.Convert(new byte[1], 0, 0, new char[4], 0, 5, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); AssertExtensions.Throws<ArgumentOutOfRangeException>("chars", () => decoder.Convert(new byte[1], 0, 0, new char[4], 1, 4, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); // Chars does not have enough space AssertExtensions.Throws<ArgumentException>("chars", () => decoder.Convert(new byte[4], 0, 4, new char[0], 0, 0, flush, out charsUsed, out bytesUsed, out completed)); VerifyOutParams(); } [Theory] [MemberData(nameof(Encodings_TestData))] public static unsafe void GetByteCount_Invalid_NetCoreApp(Encoding encoding) { // Chars is null AssertExtensions.Throws<ArgumentNullException>("s", () => encoding.GetByteCount((string)null, 0, 0)); // Index < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", -1, 0)); // Count < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetByteCount("abc", 0, -1)); // Index + count > chars.Length AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", 0, 4)); AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", 1, 3)); AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", 2, 2)); AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", 3, 1)); AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", 4, 0)); } [Theory] [MemberData(nameof(Encodings_TestData))] public static unsafe void GetBytes_Invalid_NetCoreApp(Encoding encoding) { // Source is null AssertExtensions.Throws<ArgumentNullException>("s", () => encoding.GetBytes((string)null, 0, 0)); // CharIndex < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetBytes("a", -1, 0)); // CharCount < 0 AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetBytes("a", 0, -1)); // CharIndex + charCount > source.Length AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetBytes("a", 2, 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetBytes("a", 1, 1)); AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetBytes("a", 0, 2)); } } public class HighMaxCharCountEncoderFallback : EncoderFallback { public override int MaxCharCount => int.MaxValue; public override EncoderFallbackBuffer CreateFallbackBuffer() => ReplacementFallback.CreateFallbackBuffer(); } public class HighMaxCharCountDecoderFallback : DecoderFallback { public override int MaxCharCount => int.MaxValue; public override DecoderFallbackBuffer CreateFallbackBuffer() => ReplacementFallback.CreateFallbackBuffer(); } }
-1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/tests/JIT/Regression/Dev11/Dev11_5437/Dev11_5437.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // using System; class Program { static void f(int c, int d, int e) { Console.WriteLine("c={0}, d={1}, e={2}", c, d, e); if (c + d != 4) { Console.WriteLine("FAILED: c + d != 4"); //We are hitting the bug so bailing out throw new Exception("FAILED"); } } static int Main() { int d = 0; int i = 3; for (int e = 0; e < 2; e++) { while (true) { int c = 3 - d++; f(c, d, e); // c == 3-d+1 ! if (--i < 1) break; } } Console.WriteLine("PASSED"); return 100; //Didn't hit the bug so return success } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // using System; class Program { static void f(int c, int d, int e) { Console.WriteLine("c={0}, d={1}, e={2}", c, d, e); if (c + d != 4) { Console.WriteLine("FAILED: c + d != 4"); //We are hitting the bug so bailing out throw new Exception("FAILED"); } } static int Main() { int d = 0; int i = 3; for (int e = 0; e < 2; e++) { while (true) { int c = 3 - d++; f(c, d, e); // c == 3-d+1 ! if (--i < 1) break; } } Console.WriteLine("PASSED"); return 100; //Didn't hit the bug so return success } }
-1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/mono/mono/tests/xdomain-threads.cs
using System; using System.Threading; using System.Runtime.Remoting; // Does a foreign domain's thread object persist (in .NET) even if it // hasn't been started? // // Insubstantial, because it can't be "moved" to another domain. // Can we start a foreign domain's thread (i.e. does the thread then // switch to the foreign domain and execute the start method there)? // // No, we can't start it from another domain, because we can't bring // to another domain. // What if we start a foreign domain's thread if the domain is gone? // // See above. public class Test : MarshalByRefObject { public Thread thread; public String str; public void setThread () { Console.WriteLine ("setting thread"); thread = Thread.CurrentThread; thread.Name = "foo"; } public void setStr (string s) { Console.WriteLine ("setting str"); str = s; } public void callSetThread (Test t) { Thread thread = new Thread (new ThreadStart (t.setThread)); thread.Start (); thread.Join (); t.setStr ("a" + "b"); } } public class main { public static int Main (string [] args) { AppDomain domain = AppDomain.CreateDomain ("newdomain"); Test myTest = new Test (); Test otherTest = (Test) domain.CreateInstanceAndUnwrap (typeof (Test).Assembly.FullName, typeof (Test).FullName); otherTest.callSetThread (myTest); if (myTest.thread.GetType () == Thread.CurrentThread.GetType ()) Console.WriteLine ("same type"); else { Console.WriteLine ("different type"); return 1; } AppDomain.Unload (domain); GC.Collect (); GC.WaitForPendingFinalizers (); Console.WriteLine ("thread " + myTest.thread); Console.WriteLine ("str " + myTest.str); if (!myTest.thread.Name.Equals("foo")) return 1; return 0; } }
using System; using System.Threading; using System.Runtime.Remoting; // Does a foreign domain's thread object persist (in .NET) even if it // hasn't been started? // // Insubstantial, because it can't be "moved" to another domain. // Can we start a foreign domain's thread (i.e. does the thread then // switch to the foreign domain and execute the start method there)? // // No, we can't start it from another domain, because we can't bring // to another domain. // What if we start a foreign domain's thread if the domain is gone? // // See above. public class Test : MarshalByRefObject { public Thread thread; public String str; public void setThread () { Console.WriteLine ("setting thread"); thread = Thread.CurrentThread; thread.Name = "foo"; } public void setStr (string s) { Console.WriteLine ("setting str"); str = s; } public void callSetThread (Test t) { Thread thread = new Thread (new ThreadStart (t.setThread)); thread.Start (); thread.Join (); t.setStr ("a" + "b"); } } public class main { public static int Main (string [] args) { AppDomain domain = AppDomain.CreateDomain ("newdomain"); Test myTest = new Test (); Test otherTest = (Test) domain.CreateInstanceAndUnwrap (typeof (Test).Assembly.FullName, typeof (Test).FullName); otherTest.callSetThread (myTest); if (myTest.thread.GetType () == Thread.CurrentThread.GetType ()) Console.WriteLine ("same type"); else { Console.WriteLine ("different type"); return 1; } AppDomain.Unload (domain); GC.Collect (); GC.WaitForPendingFinalizers (); Console.WriteLine ("thread " + myTest.thread); Console.WriteLine ("str " + myTest.str); if (!myTest.thread.Name.Equals("foo")) return 1; return 0; } }
-1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/libraries/Common/src/Interop/Windows/User32/Interop.PostQuitMessage.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Runtime.InteropServices; internal static partial class Interop { internal static partial class User32 { [GeneratedDllImport(Libraries.User32)] public static partial void PostQuitMessage(int exitCode); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Runtime.InteropServices; internal static partial class Interop { internal static partial class User32 { [GeneratedDllImport(Libraries.User32)] public static partial void PostQuitMessage(int exitCode); } }
-1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSObject.References.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; namespace System.Runtime.InteropServices.JavaScript { public partial class JSObject : SafeHandleMinusOneIsInvalid { private GCHandle? InFlight; private int InFlightCounter; public int JSHandle => (int)handle; public bool IsDisposed { get; private set; } public JSObject() : base(true) { InFlight = null; InFlightCounter = 0; var jsHandle = Runtime.CreateCSOwnedObject(this, nameof(Object)); SetHandle(jsHandle); } protected JSObject(string typeName, object[] _params) : base(true) { InFlight = null; InFlightCounter = 0; var jsHandle = Runtime.CreateCSOwnedObject(this, typeName, _params); SetHandle(jsHandle); } internal JSObject(IntPtr jsHandle) : base(true) { SetHandle(jsHandle); InFlight = null; InFlightCounter = 0; } internal void AddInFlight() { AssertNotDisposed(); lock (this) { InFlightCounter++; if (InFlightCounter == 1) { Debug.Assert(InFlight == null, "InFlight == null"); InFlight = GCHandle.Alloc(this, GCHandleType.Normal); } } } // Note that we could not use SafeHandle.DangerousAddRef() and DangerousRelease() // because we could get to zero InFlightCounter multiple times accross lifetime of the JSObject // we only want JSObject to be disposed (from GC finalizer) once there is no in-flight reference and also no natural C# reference internal void ReleaseInFlight() { lock (this) { Debug.Assert(InFlightCounter != 0, "InFlightCounter != 0"); InFlightCounter--; if (InFlightCounter == 0) { Debug.Assert(InFlight.HasValue, "InFlight.HasValue"); InFlight.Value.Free(); InFlight = null; } } } [MethodImpl(MethodImplOptions.AggressiveInlining)] #if DEBUG public void AssertNotDisposed() #else internal void AssertNotDisposed() #endif { if (IsDisposed) throw new ObjectDisposedException($"Cannot access a disposed {GetType().Name}."); } #if DEBUG public void AssertInFlight(int expectedInFlightCount) { if (InFlightCounter != expectedInFlightCount) throw new InvalidProgramException($"Invalid InFlightCounter for JSObject {JSHandle}, expected: {expectedInFlightCount}, actual: {InFlightCounter}"); } #endif protected override bool ReleaseHandle() { Runtime.ReleaseCSOwnedObject(this); SetHandleAsInvalid(); IsDisposed = true; return true; } public override bool Equals([NotNullWhen(true)] object? obj) => obj is JSObject other && JSHandle == other.JSHandle; public override int GetHashCode() => JSHandle; public override string ToString() { return $"(js-obj js '{JSHandle}')"; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; namespace System.Runtime.InteropServices.JavaScript { public partial class JSObject : SafeHandleMinusOneIsInvalid { private GCHandle? InFlight; private int InFlightCounter; public int JSHandle => (int)handle; public bool IsDisposed { get; private set; } public JSObject() : base(true) { InFlight = null; InFlightCounter = 0; var jsHandle = Runtime.CreateCSOwnedObject(this, nameof(Object)); SetHandle(jsHandle); } protected JSObject(string typeName, object[] _params) : base(true) { InFlight = null; InFlightCounter = 0; var jsHandle = Runtime.CreateCSOwnedObject(this, typeName, _params); SetHandle(jsHandle); } internal JSObject(IntPtr jsHandle) : base(true) { SetHandle(jsHandle); InFlight = null; InFlightCounter = 0; } internal void AddInFlight() { AssertNotDisposed(); lock (this) { InFlightCounter++; if (InFlightCounter == 1) { Debug.Assert(InFlight == null, "InFlight == null"); InFlight = GCHandle.Alloc(this, GCHandleType.Normal); } } } // Note that we could not use SafeHandle.DangerousAddRef() and DangerousRelease() // because we could get to zero InFlightCounter multiple times accross lifetime of the JSObject // we only want JSObject to be disposed (from GC finalizer) once there is no in-flight reference and also no natural C# reference internal void ReleaseInFlight() { lock (this) { Debug.Assert(InFlightCounter != 0, "InFlightCounter != 0"); InFlightCounter--; if (InFlightCounter == 0) { Debug.Assert(InFlight.HasValue, "InFlight.HasValue"); InFlight.Value.Free(); InFlight = null; } } } [MethodImpl(MethodImplOptions.AggressiveInlining)] #if DEBUG public void AssertNotDisposed() #else internal void AssertNotDisposed() #endif { if (IsDisposed) throw new ObjectDisposedException($"Cannot access a disposed {GetType().Name}."); } #if DEBUG public void AssertInFlight(int expectedInFlightCount) { if (InFlightCounter != expectedInFlightCount) throw new InvalidProgramException($"Invalid InFlightCounter for JSObject {JSHandle}, expected: {expectedInFlightCount}, actual: {InFlightCounter}"); } #endif protected override bool ReleaseHandle() { Runtime.ReleaseCSOwnedObject(this); SetHandleAsInvalid(); IsDisposed = true; return true; } public override bool Equals([NotNullWhen(true)] object? obj) => obj is JSObject other && JSHandle == other.JSHandle; public override int GetHashCode() => JSHandle; public override string ToString() { return $"(js-obj js '{JSHandle}')"; } } }
-1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/tests/JIT/jit64/valuetypes/nullable/castclass/generics/castclass-generics003.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Runtime.InteropServices; using System; internal class NullableTest { private static bool BoxUnboxToNQ<T>(T o) { return Helper.Compare((byte)(ValueType)(object)o, Helper.Create(default(byte))); } private static bool BoxUnboxToQ<T>(T o) { return Helper.Compare((byte?)(ValueType)(object)o, Helper.Create(default(byte))); } private static int Main() { byte? s = Helper.Create(default(byte)); if (BoxUnboxToNQ(s) && BoxUnboxToQ(s)) return ExitCode.Passed; else return ExitCode.Failed; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Runtime.InteropServices; using System; internal class NullableTest { private static bool BoxUnboxToNQ<T>(T o) { return Helper.Compare((byte)(ValueType)(object)o, Helper.Create(default(byte))); } private static bool BoxUnboxToQ<T>(T o) { return Helper.Compare((byte?)(ValueType)(object)o, Helper.Create(default(byte))); } private static int Main() { byte? s = Helper.Create(default(byte)); if (BoxUnboxToNQ(s) && BoxUnboxToQ(s)) return ExitCode.Passed; else return ExitCode.Failed; } }
-1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/mono/sample/wasm/console-node-es6/Program.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Threading.Tasks; public class Test { public static async Task<int> Main(string[] args) { await Task.Delay(1); Console.WriteLine("Hello World!"); for (int i = 0; i < args.Length; i++) { Console.WriteLine($"args[{i}] = {args[i]}"); } return args.Length; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Threading.Tasks; public class Test { public static async Task<int> Main(string[] args) { await Task.Delay(1); Console.WriteLine("Hello World!"); for (int i = 0; i < args.Length; i++) { Console.WriteLine($"args[{i}] = {args[i]}"); } return args.Length; } }
-1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/tests/JIT/HardwareIntrinsics/X86/Avx1/ExtendToVector256.Int16.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; namespace JIT.HardwareIntrinsics.X86 { public static partial class Program { private static void ExtendToVector256Int16() { var test = new GenericUnaryOpTest__ExtendToVector256Int16(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (Sse2.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); // Validates basic functionality works, using LoadAligned test.RunBasicScenario_LoadAligned(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (Sse2.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); // Validates calling via reflection works, using LoadAligned test.RunReflectionScenario_LoadAligned(); } // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (Sse2.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); // Validates passing a local works, using LoadAligned test.RunLclVarScenario_LoadAligned(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class GenericUnaryOpTest__ExtendToVector256Int16 { private struct TestStruct { public Vector128<Int16> _fld; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref testStruct._fld), ref Unsafe.As<Int16, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); return testStruct; } public void RunStructFldScenario(GenericUnaryOpTest__ExtendToVector256Int16 testClass) { var result = Avx.ExtendToVector256<Int16>(_fld); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); } } private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Int16>>() / sizeof(Int16); private static readonly int RetElementCount = Unsafe.SizeOf<Vector256<Int16>>() / sizeof(Int16); private static Int16[] _data = new Int16[Op1ElementCount]; private static Vector128<Int16> _clsVar; private Vector128<Int16> _fld; private SimpleUnaryOpTest__DataTable<Int16, Int16> _dataTable; static GenericUnaryOpTest__ExtendToVector256Int16() { for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar), ref Unsafe.As<Int16, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); } public GenericUnaryOpTest__ExtendToVector256Int16() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld), ref Unsafe.As<Int16, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt16(); } _dataTable = new SimpleUnaryOpTest__DataTable<Int16, Int16>(_data, new Int16[RetElementCount], LargestVectorSize); } public bool IsSupported => Avx.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Avx.ExtendToVector256<Int16>( Unsafe.Read<Vector128<Int16>>(_dataTable.inArrayPtr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = Avx.ExtendToVector256<Int16>( Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunBasicScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); var result = Avx.ExtendToVector256<Int16>( Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(Avx).GetMethod(nameof(Avx.ExtendToVector256)) .MakeGenericMethod( new Type[] { typeof(Int16) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Int16>>(_dataTable.inArrayPtr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Int16>)(result)); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(Avx).GetMethod(nameof(Avx.ExtendToVector256)) .MakeGenericMethod( new Type[] { typeof(Int16) }) .Invoke(null, new object[] { Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Int16>)(result)); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); var result = typeof(Avx).GetMethod(nameof(Avx.ExtendToVector256)) .MakeGenericMethod( new Type[] { typeof(Int16) }) .Invoke(null, new object[] { Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Int16>)(result)); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Avx.ExtendToVector256<Int16>( _clsVar ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var firstOp = Unsafe.Read<Vector128<Int16>>(_dataTable.inArrayPtr); var result = Avx.ExtendToVector256<Int16>(firstOp); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var firstOp = Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)); var result = Avx.ExtendToVector256<Int16>(firstOp); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); var firstOp = Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)); var result = Avx.ExtendToVector256<Int16>(firstOp); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new GenericUnaryOpTest__ExtendToVector256Int16(); var result = Avx.ExtendToVector256<Int16>(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Avx.ExtendToVector256<Int16>(_fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld, _dataTable.outArrayPtr); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Avx.ExtendToVector256(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); Succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { Succeeded = true; } } private void ValidateResult(Vector128<Int16> firstOp, void* result, [CallerMemberName] string method = "") { Int16[] inArray = new Int16[Op1ElementCount]; Int16[] outArray = new Int16[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref inArray[0]), firstOp); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Int16>>()); ValidateResult(inArray, outArray, method); } private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") { Int16[] inArray = new Int16[Op1ElementCount]; Int16[] outArray = new Int16[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (uint)Unsafe.SizeOf<Vector128<Int16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Int16>>()); ValidateResult(inArray, outArray, method); } private void ValidateResult(Int16[] firstOp, Int16[] result, [CallerMemberName] string method = "") { if (firstOp[0] != result[0]) { Succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)) { Succeeded = false; break; } } } if (!Succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.ExtendToVector256)}<Int16>(Vector128<Int16>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; namespace JIT.HardwareIntrinsics.X86 { public static partial class Program { private static void ExtendToVector256Int16() { var test = new GenericUnaryOpTest__ExtendToVector256Int16(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (Sse2.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); // Validates basic functionality works, using LoadAligned test.RunBasicScenario_LoadAligned(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (Sse2.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); // Validates calling via reflection works, using LoadAligned test.RunReflectionScenario_LoadAligned(); } // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (Sse2.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); // Validates passing a local works, using LoadAligned test.RunLclVarScenario_LoadAligned(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class GenericUnaryOpTest__ExtendToVector256Int16 { private struct TestStruct { public Vector128<Int16> _fld; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref testStruct._fld), ref Unsafe.As<Int16, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); return testStruct; } public void RunStructFldScenario(GenericUnaryOpTest__ExtendToVector256Int16 testClass) { var result = Avx.ExtendToVector256<Int16>(_fld); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); } } private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Int16>>() / sizeof(Int16); private static readonly int RetElementCount = Unsafe.SizeOf<Vector256<Int16>>() / sizeof(Int16); private static Int16[] _data = new Int16[Op1ElementCount]; private static Vector128<Int16> _clsVar; private Vector128<Int16> _fld; private SimpleUnaryOpTest__DataTable<Int16, Int16> _dataTable; static GenericUnaryOpTest__ExtendToVector256Int16() { for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar), ref Unsafe.As<Int16, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); } public GenericUnaryOpTest__ExtendToVector256Int16() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld), ref Unsafe.As<Int16, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt16(); } _dataTable = new SimpleUnaryOpTest__DataTable<Int16, Int16>(_data, new Int16[RetElementCount], LargestVectorSize); } public bool IsSupported => Avx.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Avx.ExtendToVector256<Int16>( Unsafe.Read<Vector128<Int16>>(_dataTable.inArrayPtr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = Avx.ExtendToVector256<Int16>( Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunBasicScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); var result = Avx.ExtendToVector256<Int16>( Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(Avx).GetMethod(nameof(Avx.ExtendToVector256)) .MakeGenericMethod( new Type[] { typeof(Int16) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Int16>>(_dataTable.inArrayPtr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Int16>)(result)); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(Avx).GetMethod(nameof(Avx.ExtendToVector256)) .MakeGenericMethod( new Type[] { typeof(Int16) }) .Invoke(null, new object[] { Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Int16>)(result)); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); var result = typeof(Avx).GetMethod(nameof(Avx.ExtendToVector256)) .MakeGenericMethod( new Type[] { typeof(Int16) }) .Invoke(null, new object[] { Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Int16>)(result)); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Avx.ExtendToVector256<Int16>( _clsVar ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var firstOp = Unsafe.Read<Vector128<Int16>>(_dataTable.inArrayPtr); var result = Avx.ExtendToVector256<Int16>(firstOp); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var firstOp = Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)); var result = Avx.ExtendToVector256<Int16>(firstOp); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); var firstOp = Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)); var result = Avx.ExtendToVector256<Int16>(firstOp); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new GenericUnaryOpTest__ExtendToVector256Int16(); var result = Avx.ExtendToVector256<Int16>(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Avx.ExtendToVector256<Int16>(_fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld, _dataTable.outArrayPtr); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Avx.ExtendToVector256(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); Succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { Succeeded = true; } } private void ValidateResult(Vector128<Int16> firstOp, void* result, [CallerMemberName] string method = "") { Int16[] inArray = new Int16[Op1ElementCount]; Int16[] outArray = new Int16[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref inArray[0]), firstOp); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Int16>>()); ValidateResult(inArray, outArray, method); } private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") { Int16[] inArray = new Int16[Op1ElementCount]; Int16[] outArray = new Int16[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (uint)Unsafe.SizeOf<Vector128<Int16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Int16>>()); ValidateResult(inArray, outArray, method); } private void ValidateResult(Int16[] firstOp, Int16[] result, [CallerMemberName] string method = "") { if (firstOp[0] != result[0]) { Succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)) { Succeeded = false; break; } } } if (!Succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.ExtendToVector256)}<Int16>(Vector128<Int16>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); } } } }
-1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/coreclr/nativeaot/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ReflectionExecutionDomainCallbacksImplementation.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Collections.Generic; using System.Runtime.InteropServices; using Internal.Runtime.Augments; using Internal.Reflection.Core; using Internal.Reflection.Core.Execution; using Internal.Reflection.Execution.PayForPlayExperience; using Internal.Reflection.Extensions.NonPortable; using System.Reflection.Runtime.General; using Debug = System.Diagnostics.Debug; namespace Internal.Reflection.Execution { //========================================================================================================================== // This class provides various services down to System.Private.CoreLib. (Though we forward most or all of them directly up to Reflection.Core.) //========================================================================================================================== internal sealed class ReflectionExecutionDomainCallbacksImplementation : ReflectionExecutionDomainCallbacks { public ReflectionExecutionDomainCallbacksImplementation(ExecutionDomain executionDomain, ExecutionEnvironmentImplementation executionEnvironment) { _executionDomain = executionDomain; _executionEnvironment = executionEnvironment; } public sealed override Type GetType(string typeName, Func<AssemblyName, Assembly> assemblyResolver, Func<Assembly, string, bool, Type> typeResolver, bool throwOnError, bool ignoreCase, string defaultAssemblyName) { LowLevelListWithIList<string> defaultAssemblies = new LowLevelListWithIList<string>(); if (defaultAssemblyName != null) defaultAssemblies.Add(defaultAssemblyName); defaultAssemblies.Add(AssemblyBinder.DefaultAssemblyNameForGetType); return _executionDomain.GetType(typeName, assemblyResolver, typeResolver, throwOnError, ignoreCase, defaultAssemblies); } public sealed override bool IsReflectionBlocked(RuntimeTypeHandle typeHandle) { return _executionEnvironment.IsReflectionBlocked(typeHandle); } //======================================================================================= // This group of methods jointly service the Type.GetTypeFromHandle() path. The caller // is responsible for analyzing the RuntimeTypeHandle to figure out which flavor to call. //======================================================================================= public sealed override Type GetNamedTypeForHandle(RuntimeTypeHandle typeHandle, bool isGenericTypeDefinition) { return _executionDomain.GetNamedTypeForHandle(typeHandle, isGenericTypeDefinition); } public sealed override Type GetArrayTypeForHandle(RuntimeTypeHandle typeHandle) { return _executionDomain.GetArrayTypeForHandle(typeHandle); } public sealed override Type GetMdArrayTypeForHandle(RuntimeTypeHandle typeHandle, int rank) { return _executionDomain.GetMdArrayTypeForHandle(typeHandle, rank); } public sealed override Type GetPointerTypeForHandle(RuntimeTypeHandle typeHandle) { return _executionDomain.GetPointerTypeForHandle(typeHandle); } public sealed override Type GetByRefTypeForHandle(RuntimeTypeHandle typeHandle) { return _executionDomain.GetByRefTypeForHandle(typeHandle); } public sealed override Type GetConstructedGenericTypeForHandle(RuntimeTypeHandle typeHandle) { return _executionDomain.GetConstructedGenericTypeForHandle(typeHandle); } //======================================================================================= // MissingMetadataException support. //======================================================================================= public sealed override Exception CreateMissingMetadataException(Type pertainant) { return _executionDomain.CreateMissingMetadataException(pertainant); } // This is called from the ToString() helper of a RuntimeType that does not have full metadata. // This helper makes a "best effort" to give the caller something better than "EETypePtr nnnnnnnnn". public sealed override string GetBetterDiagnosticInfoIfAvailable(RuntimeTypeHandle runtimeTypeHandle) { return Type.GetTypeFromHandle(runtimeTypeHandle).ToDisplayStringIfAvailable(null); } public sealed override MethodBase GetMethodBaseFromStartAddressIfAvailable(IntPtr methodStartAddress) { RuntimeTypeHandle declaringTypeHandle = default(RuntimeTypeHandle); QMethodDefinition methodHandle; if (!ReflectionExecution.ExecutionEnvironment.TryGetMethodForStartAddress(methodStartAddress, ref declaringTypeHandle, out methodHandle)) { return null; } // We don't use the type argument handles as we want the uninstantiated method info return ReflectionCoreExecution.ExecutionDomain.GetMethod(declaringTypeHandle, methodHandle, genericMethodTypeArgumentHandles: null); } public sealed override Assembly GetAssemblyForHandle(RuntimeTypeHandle typeHandle) { return Type.GetTypeFromHandle(typeHandle).Assembly; } public sealed override IntPtr TryGetStaticClassConstructionContext(RuntimeTypeHandle runtimeTypeHandle) { return _executionEnvironment.TryGetStaticClassConstructionContext(runtimeTypeHandle); } /// <summary> /// Retrieves the default value for a parameter of a method. /// </summary> /// <param name="defaultParametersContext">The default parameters context used to invoke the method, /// this should identify the method in question. This is passed to the RuntimeAugments.CallDynamicInvokeMethod.</param> /// <param name="thType">The type of the parameter to retrieve.</param> /// <param name="argIndex">The index of the parameter on the method to retrieve.</param> /// <param name="defaultValue">The default value of the parameter if available.</param> /// <returns>true if the default parameter value is available, otherwise false.</returns> public sealed override bool TryGetDefaultParameterValue(object defaultParametersContext, RuntimeTypeHandle thType, int argIndex, out object defaultValue) { defaultValue = null; MethodBase methodBase = defaultParametersContext as MethodBase; if (methodBase is null) { if (defaultParametersContext is Delegate) { methodBase = GetDelegateInvokeMethod(defaultParametersContext.GetType()); } if (methodBase is null) { return false; } [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2070:UnrecognizedReflectionPattern", Justification = "Delegates always generate metadata for the Invoke method")] static MethodBase GetDelegateInvokeMethod(Type delegateType) { MethodInfo result = delegateType.GetMethod("Invoke", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly); Debug.Assert(result != null); return result; } } ParameterInfo parameterInfo = methodBase.GetParametersNoCopy()[argIndex]; if (!parameterInfo.HasDefaultValue) { // If the parameter is optional, with no default value and we're asked for its default value, // it means the caller specified Missing.Value as the value for the parameter. In this case the behavior // is defined as passing in the Missing.Value, regardless of the parameter type. // If Missing.Value is convertible to the parameter type, it will just work, otherwise we will fail // due to type mismatch. if (parameterInfo.IsOptional) { defaultValue = Missing.Value; return true; } return false; } defaultValue = parameterInfo.DefaultValue; return true; } public sealed override RuntimeTypeHandle GetTypeHandleIfAvailable(Type type) { return _executionDomain.GetTypeHandleIfAvailable(type); } public sealed override bool SupportsReflection(Type type) { return _executionDomain.SupportsReflection(type); } public sealed override MethodInfo GetDelegateMethod(Delegate del) { return DelegateMethodInfoRetriever.GetDelegateMethodInfo(del); } public sealed override Exception GetExceptionForHR(int hr) { return Marshal.GetExceptionForHR(hr); } private ExecutionDomain _executionDomain; private ExecutionEnvironmentImplementation _executionEnvironment; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Collections.Generic; using System.Runtime.InteropServices; using Internal.Runtime.Augments; using Internal.Reflection.Core; using Internal.Reflection.Core.Execution; using Internal.Reflection.Execution.PayForPlayExperience; using Internal.Reflection.Extensions.NonPortable; using System.Reflection.Runtime.General; using Debug = System.Diagnostics.Debug; namespace Internal.Reflection.Execution { //========================================================================================================================== // This class provides various services down to System.Private.CoreLib. (Though we forward most or all of them directly up to Reflection.Core.) //========================================================================================================================== internal sealed class ReflectionExecutionDomainCallbacksImplementation : ReflectionExecutionDomainCallbacks { public ReflectionExecutionDomainCallbacksImplementation(ExecutionDomain executionDomain, ExecutionEnvironmentImplementation executionEnvironment) { _executionDomain = executionDomain; _executionEnvironment = executionEnvironment; } public sealed override Type GetType(string typeName, Func<AssemblyName, Assembly> assemblyResolver, Func<Assembly, string, bool, Type> typeResolver, bool throwOnError, bool ignoreCase, string defaultAssemblyName) { LowLevelListWithIList<string> defaultAssemblies = new LowLevelListWithIList<string>(); if (defaultAssemblyName != null) defaultAssemblies.Add(defaultAssemblyName); defaultAssemblies.Add(AssemblyBinder.DefaultAssemblyNameForGetType); return _executionDomain.GetType(typeName, assemblyResolver, typeResolver, throwOnError, ignoreCase, defaultAssemblies); } public sealed override bool IsReflectionBlocked(RuntimeTypeHandle typeHandle) { return _executionEnvironment.IsReflectionBlocked(typeHandle); } //======================================================================================= // This group of methods jointly service the Type.GetTypeFromHandle() path. The caller // is responsible for analyzing the RuntimeTypeHandle to figure out which flavor to call. //======================================================================================= public sealed override Type GetNamedTypeForHandle(RuntimeTypeHandle typeHandle, bool isGenericTypeDefinition) { return _executionDomain.GetNamedTypeForHandle(typeHandle, isGenericTypeDefinition); } public sealed override Type GetArrayTypeForHandle(RuntimeTypeHandle typeHandle) { return _executionDomain.GetArrayTypeForHandle(typeHandle); } public sealed override Type GetMdArrayTypeForHandle(RuntimeTypeHandle typeHandle, int rank) { return _executionDomain.GetMdArrayTypeForHandle(typeHandle, rank); } public sealed override Type GetPointerTypeForHandle(RuntimeTypeHandle typeHandle) { return _executionDomain.GetPointerTypeForHandle(typeHandle); } public sealed override Type GetByRefTypeForHandle(RuntimeTypeHandle typeHandle) { return _executionDomain.GetByRefTypeForHandle(typeHandle); } public sealed override Type GetConstructedGenericTypeForHandle(RuntimeTypeHandle typeHandle) { return _executionDomain.GetConstructedGenericTypeForHandle(typeHandle); } //======================================================================================= // MissingMetadataException support. //======================================================================================= public sealed override Exception CreateMissingMetadataException(Type pertainant) { return _executionDomain.CreateMissingMetadataException(pertainant); } // This is called from the ToString() helper of a RuntimeType that does not have full metadata. // This helper makes a "best effort" to give the caller something better than "EETypePtr nnnnnnnnn". public sealed override string GetBetterDiagnosticInfoIfAvailable(RuntimeTypeHandle runtimeTypeHandle) { return Type.GetTypeFromHandle(runtimeTypeHandle).ToDisplayStringIfAvailable(null); } public sealed override MethodBase GetMethodBaseFromStartAddressIfAvailable(IntPtr methodStartAddress) { RuntimeTypeHandle declaringTypeHandle = default(RuntimeTypeHandle); QMethodDefinition methodHandle; if (!ReflectionExecution.ExecutionEnvironment.TryGetMethodForStartAddress(methodStartAddress, ref declaringTypeHandle, out methodHandle)) { return null; } // We don't use the type argument handles as we want the uninstantiated method info return ReflectionCoreExecution.ExecutionDomain.GetMethod(declaringTypeHandle, methodHandle, genericMethodTypeArgumentHandles: null); } public sealed override Assembly GetAssemblyForHandle(RuntimeTypeHandle typeHandle) { return Type.GetTypeFromHandle(typeHandle).Assembly; } public sealed override IntPtr TryGetStaticClassConstructionContext(RuntimeTypeHandle runtimeTypeHandle) { return _executionEnvironment.TryGetStaticClassConstructionContext(runtimeTypeHandle); } /// <summary> /// Retrieves the default value for a parameter of a method. /// </summary> /// <param name="defaultParametersContext">The default parameters context used to invoke the method, /// this should identify the method in question. This is passed to the RuntimeAugments.CallDynamicInvokeMethod.</param> /// <param name="thType">The type of the parameter to retrieve.</param> /// <param name="argIndex">The index of the parameter on the method to retrieve.</param> /// <param name="defaultValue">The default value of the parameter if available.</param> /// <returns>true if the default parameter value is available, otherwise false.</returns> public sealed override bool TryGetDefaultParameterValue(object defaultParametersContext, RuntimeTypeHandle thType, int argIndex, out object defaultValue) { defaultValue = null; MethodBase methodBase = defaultParametersContext as MethodBase; if (methodBase is null) { if (defaultParametersContext is Delegate) { methodBase = GetDelegateInvokeMethod(defaultParametersContext.GetType()); } if (methodBase is null) { return false; } [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2070:UnrecognizedReflectionPattern", Justification = "Delegates always generate metadata for the Invoke method")] static MethodBase GetDelegateInvokeMethod(Type delegateType) { MethodInfo result = delegateType.GetMethod("Invoke", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly); Debug.Assert(result != null); return result; } } ParameterInfo parameterInfo = methodBase.GetParametersNoCopy()[argIndex]; if (!parameterInfo.HasDefaultValue) { // If the parameter is optional, with no default value and we're asked for its default value, // it means the caller specified Missing.Value as the value for the parameter. In this case the behavior // is defined as passing in the Missing.Value, regardless of the parameter type. // If Missing.Value is convertible to the parameter type, it will just work, otherwise we will fail // due to type mismatch. if (parameterInfo.IsOptional) { defaultValue = Missing.Value; return true; } return false; } defaultValue = parameterInfo.DefaultValue; return true; } public sealed override RuntimeTypeHandle GetTypeHandleIfAvailable(Type type) { return _executionDomain.GetTypeHandleIfAvailable(type); } public sealed override bool SupportsReflection(Type type) { return _executionDomain.SupportsReflection(type); } public sealed override MethodInfo GetDelegateMethod(Delegate del) { return DelegateMethodInfoRetriever.GetDelegateMethodInfo(del); } public sealed override Exception GetExceptionForHR(int hr) { return Marshal.GetExceptionForHR(hr); } private ExecutionDomain _executionDomain; private ExecutionEnvironmentImplementation _executionEnvironment; } }
-1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/GCHandleTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using Xunit; namespace System.Runtime.InteropServices.Tests { public class GCHandleTests { [Fact] public void Ctor_Default() { var handle = new GCHandle(); Assert.Throws<InvalidOperationException>(() => handle.Target); Assert.False(handle.IsAllocated); Assert.Equal(IntPtr.Zero, GCHandle.ToIntPtr(handle)); Assert.Equal(IntPtr.Zero, (IntPtr)handle); } public static IEnumerable<object[]> Alloc_TestData() { yield return new object[] { null }; yield return new object[] { "String" }; yield return new object[] { 123 }; yield return new object[] { new int[1] }; yield return new object[] { new NonBlittable[1] }; yield return new object[] { new object[1] }; yield return new object[] { new NonBlittable() }; } [Theory] [MemberData(nameof(Alloc_TestData))] public void Alloc_Value_ReturnsExpected(object value) { GCHandle handle = GCHandle.Alloc(value); ValidateGCHandle(handle, GCHandleType.Normal, value); } public static IEnumerable<object[]> Alloc_Type_TestData() { foreach (object[] data in Alloc_TestData()) { yield return new object[] { data[0], GCHandleType.Normal }; yield return new object[] { data[0], GCHandleType.Weak }; yield return new object[] { data[0], GCHandleType.WeakTrackResurrection }; } yield return new object[] { null, GCHandleType.Pinned }; yield return new object[] { "", GCHandleType.Pinned }; yield return new object[] { 1, GCHandleType.Pinned }; yield return new object[] { new Blittable(), GCHandleType.Pinned }; yield return new object[] { new Blittable(), GCHandleType.Pinned }; yield return new object[] { new Blittable[0], GCHandleType.Pinned }; } [Theory] [MemberData(nameof(Alloc_Type_TestData))] public static void Alloc_Type_ReturnsExpected(object value, GCHandleType type) { GCHandle handle = GCHandle.Alloc(value, type); ValidateGCHandle(handle, type, value); } public static IEnumerable<object[]> InvalidPinnedObject_TestData() { yield return new object[] { new NonBlittable() }; yield return new object[] { new object[0] }; yield return new object[] { new NonBlittable[0] }; } [Theory] [MemberData(nameof(InvalidPinnedObject_TestData))] public void Alloc_InvalidPinnedObject_ThrowsArgumentException(object value) { Assert.Throws<ArgumentException>(() => GCHandle.Alloc(value, GCHandleType.Pinned)); } [Theory] [InlineData(GCHandleType.Weak - 1)] [InlineData(GCHandleType.Pinned + 1)] public void Alloc_InvalidGCHandleType_ThrowsArgumentOutOfRangeException(GCHandleType type) { AssertExtensions.Throws<ArgumentOutOfRangeException>("type", () => GCHandle.Alloc(new object(), type)); } [Fact] public void FromIntPtr_Zero_ThrowsInvalidOperationException() { Assert.Throws<InvalidOperationException>(() => GCHandle.FromIntPtr(IntPtr.Zero)); } [Fact] public void AddrOfPinnedObject_NotInitialized_ThrowsInvalidOperationException() { var handle = new GCHandle(); Assert.Throws<InvalidOperationException>(() => handle.AddrOfPinnedObject()); } [Fact] public void AddrOfPinnedObject_NotPinned_ThrowsInvalidOperationException() { GCHandle handle = GCHandle.Alloc(new object()); try { Assert.Throws<InvalidOperationException>(() => handle.AddrOfPinnedObject()); } finally { handle.Free(); } } [Fact] public void Free_NotInitialized_ThrowsInvalidOperationException() { var handle = new GCHandle(); Assert.Throws<InvalidOperationException>(() => handle.Free()); } public static IEnumerable<object[]> Equals_TestData() { GCHandle handle = GCHandle.Alloc(new object()); yield return new object[] { handle, handle, true }; yield return new object[] { GCHandle.Alloc(new object()), GCHandle.Alloc(new object()), false }; yield return new object[] { GCHandle.Alloc(new object()), new object(), false }; yield return new object[] { GCHandle.Alloc(new object()), null, false }; } [Theory] [MemberData(nameof(Equals_TestData))] public void Equals_Object_ReturnsExpected(GCHandle handle, object other, bool expected) { try { Assert.Equal(expected, handle.Equals(other)); if (other is GCHandle otherHandle) { Assert.Equal(expected, handle.Equals(otherHandle)); Assert.Equal(expected, handle == otherHandle); Assert.Equal(!expected, handle != otherHandle); } } finally { handle.Free(); if (other is GCHandle otherHandle && !expected) { otherHandle.Free(); } } } private static void ValidateGCHandle(GCHandle handle, GCHandleType type, object target) { try { Assert.Equal(target, handle.Target); Assert.True(handle.IsAllocated); Assert.NotEqual(IntPtr.Zero, GCHandle.ToIntPtr(handle)); Assert.Equal(GCHandle.ToIntPtr(handle), (IntPtr)handle); Assert.Equal(((IntPtr)handle).GetHashCode(), handle.GetHashCode()); if (type == GCHandleType.Pinned) { if (target == null) { Assert.Equal(IntPtr.Zero, handle.AddrOfPinnedObject()); } else { Assert.NotEqual(IntPtr.Zero, handle.AddrOfPinnedObject()); } } } finally { handle.Free(); Assert.False(handle.IsAllocated); } } public struct Blittable { public int Object { get; set; } } public struct NonBlittable { public List<string> Object { get; set; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using Xunit; namespace System.Runtime.InteropServices.Tests { public class GCHandleTests { [Fact] public void Ctor_Default() { var handle = new GCHandle(); Assert.Throws<InvalidOperationException>(() => handle.Target); Assert.False(handle.IsAllocated); Assert.Equal(IntPtr.Zero, GCHandle.ToIntPtr(handle)); Assert.Equal(IntPtr.Zero, (IntPtr)handle); } public static IEnumerable<object[]> Alloc_TestData() { yield return new object[] { null }; yield return new object[] { "String" }; yield return new object[] { 123 }; yield return new object[] { new int[1] }; yield return new object[] { new NonBlittable[1] }; yield return new object[] { new object[1] }; yield return new object[] { new NonBlittable() }; } [Theory] [MemberData(nameof(Alloc_TestData))] public void Alloc_Value_ReturnsExpected(object value) { GCHandle handle = GCHandle.Alloc(value); ValidateGCHandle(handle, GCHandleType.Normal, value); } public static IEnumerable<object[]> Alloc_Type_TestData() { foreach (object[] data in Alloc_TestData()) { yield return new object[] { data[0], GCHandleType.Normal }; yield return new object[] { data[0], GCHandleType.Weak }; yield return new object[] { data[0], GCHandleType.WeakTrackResurrection }; } yield return new object[] { null, GCHandleType.Pinned }; yield return new object[] { "", GCHandleType.Pinned }; yield return new object[] { 1, GCHandleType.Pinned }; yield return new object[] { new Blittable(), GCHandleType.Pinned }; yield return new object[] { new Blittable(), GCHandleType.Pinned }; yield return new object[] { new Blittable[0], GCHandleType.Pinned }; } [Theory] [MemberData(nameof(Alloc_Type_TestData))] public static void Alloc_Type_ReturnsExpected(object value, GCHandleType type) { GCHandle handle = GCHandle.Alloc(value, type); ValidateGCHandle(handle, type, value); } public static IEnumerable<object[]> InvalidPinnedObject_TestData() { yield return new object[] { new NonBlittable() }; yield return new object[] { new object[0] }; yield return new object[] { new NonBlittable[0] }; } [Theory] [MemberData(nameof(InvalidPinnedObject_TestData))] public void Alloc_InvalidPinnedObject_ThrowsArgumentException(object value) { Assert.Throws<ArgumentException>(() => GCHandle.Alloc(value, GCHandleType.Pinned)); } [Theory] [InlineData(GCHandleType.Weak - 1)] [InlineData(GCHandleType.Pinned + 1)] public void Alloc_InvalidGCHandleType_ThrowsArgumentOutOfRangeException(GCHandleType type) { AssertExtensions.Throws<ArgumentOutOfRangeException>("type", () => GCHandle.Alloc(new object(), type)); } [Fact] public void FromIntPtr_Zero_ThrowsInvalidOperationException() { Assert.Throws<InvalidOperationException>(() => GCHandle.FromIntPtr(IntPtr.Zero)); } [Fact] public void AddrOfPinnedObject_NotInitialized_ThrowsInvalidOperationException() { var handle = new GCHandle(); Assert.Throws<InvalidOperationException>(() => handle.AddrOfPinnedObject()); } [Fact] public void AddrOfPinnedObject_NotPinned_ThrowsInvalidOperationException() { GCHandle handle = GCHandle.Alloc(new object()); try { Assert.Throws<InvalidOperationException>(() => handle.AddrOfPinnedObject()); } finally { handle.Free(); } } [Fact] public void Free_NotInitialized_ThrowsInvalidOperationException() { var handle = new GCHandle(); Assert.Throws<InvalidOperationException>(() => handle.Free()); } public static IEnumerable<object[]> Equals_TestData() { GCHandle handle = GCHandle.Alloc(new object()); yield return new object[] { handle, handle, true }; yield return new object[] { GCHandle.Alloc(new object()), GCHandle.Alloc(new object()), false }; yield return new object[] { GCHandle.Alloc(new object()), new object(), false }; yield return new object[] { GCHandle.Alloc(new object()), null, false }; } [Theory] [MemberData(nameof(Equals_TestData))] public void Equals_Object_ReturnsExpected(GCHandle handle, object other, bool expected) { try { Assert.Equal(expected, handle.Equals(other)); if (other is GCHandle otherHandle) { Assert.Equal(expected, handle.Equals(otherHandle)); Assert.Equal(expected, handle == otherHandle); Assert.Equal(!expected, handle != otherHandle); } } finally { handle.Free(); if (other is GCHandle otherHandle && !expected) { otherHandle.Free(); } } } private static void ValidateGCHandle(GCHandle handle, GCHandleType type, object target) { try { Assert.Equal(target, handle.Target); Assert.True(handle.IsAllocated); Assert.NotEqual(IntPtr.Zero, GCHandle.ToIntPtr(handle)); Assert.Equal(GCHandle.ToIntPtr(handle), (IntPtr)handle); Assert.Equal(((IntPtr)handle).GetHashCode(), handle.GetHashCode()); if (type == GCHandleType.Pinned) { if (target == null) { Assert.Equal(IntPtr.Zero, handle.AddrOfPinnedObject()); } else { Assert.NotEqual(IntPtr.Zero, handle.AddrOfPinnedObject()); } } } finally { handle.Free(); Assert.False(handle.IsAllocated); } } public struct Blittable { public int Object { get; set; } } public struct NonBlittable { public List<string> Object { get; set; } } } }
-1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/OutputSettings.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; using Xunit.Abstractions; using System.IO; using System.Xml.Xsl; using System.Text; namespace System.Xml.Tests { //[TestCase(Name = "OutputSettings", Desc = "This testcase tests the OutputSettings on XslCompiledTransform", Param = "Debug")] public class COutputSettings : XsltApiTestCaseBase2 { private XslCompiledTransform _xsl = null; private string _xmlFile = string.Empty; private string _xslFile = string.Empty; private ITestOutputHelper _output; public COutputSettings(ITestOutputHelper output) : base(output) { _output = output; } private void Init(string xmlFile, string xslFile) { _xsl = new XslCompiledTransform(); _xmlFile = FullFilePath(xmlFile); _xslFile = FullFilePath(xslFile); return; } private StringWriter Transform() { StringWriter sw = new StringWriter(); _xsl.Transform(_xmlFile, null, sw); return sw; } private void VerifyResult(object actual, object expected, string message) { _output.WriteLine("Expected : {0}", expected); _output.WriteLine("Actual : {0}", actual); Assert.Equal(actual, expected); } //[Variation(id = 1, Desc = "Verify the default value of the OutputSettings, expected null", Pri = 0)] [Fact] public void OS1() { XslCompiledTransform xslt = new XslCompiledTransform(); Assert.True(xslt.OutputSettings == null); return; } //[Variation(id = 2, Desc = "Verify the OutputMethod when output method is not specified, expected AutoDetect", Pri = 1, Params = new object[] { "books.xml", "OutputMethod_Default.xsl" })] [InlineData("books.xml", "OutputMethod_Default.xsl", 2)] //[Variation(id = 3, Desc = "Verify the OutputMethod when output method is xml, expected Xml", Pri = 0, Params = new object[] { "books.xml", "OutputMethod_Xml.xsl" })] [InlineData("books.xml", "OutputMethod_Xml.xsl", 3)] //[Variation(id = 4, Desc = "Verify the OutputMethod when output method is html, expected Html", Pri = 0, Params = new object[] { "books.xml", "OutputMethod_Html.xsl" })] [InlineData("books.xml", "OutputMethod_Html.xsl", 4)] //[Variation(id = 5, Desc = "Verify the OutputMethod when output method is text, expected Text", Pri = 1, Params = new object[] { "books.xml", "OutputMethod_Text.xsl" })] [InlineData("books.xml", "OutputMethod_Text.xsl", 5)] //[Variation(id = 6, Desc = "Verify the OutputMethod when output method is not specified, first output element is html, expected AutoDetect", Pri = 1, Params = new object[] { "books.xml", "OutputMethod_LiteralHtml.xsl" })] [InlineData("books.xml", "OutputMethod_LiteralHtml.xsl", 6)] //[Variation(id = 7, Desc = "Verify the OutputMethod when multiple output methods (Xml,Html,Text) are defined, expected Text", Pri = 1, Params = new object[] { "books.xml", "OutputMethod_Multiple1.xsl" })] [InlineData("books.xml", "OutputMethod_Multiple1.xsl", 7)] //[Variation(id = 8, Desc = "Verify the OutputMethod when multiple output methods (Html,Text,Xml) are defined, expected Xml", Pri = 1, Params = new object[] { "books.xml", "OutputMethod_Multiple2.xsl" })] [InlineData("books.xml", "OutputMethod_Multiple2.xsl", 8)] //[Variation(id = 9, Desc = "Verify the OutputMethod when multiple output methods (Text,Xml,Html) are defined, expected Html", Pri = 1, Params = new object[] { "books.xml", "OutputMethod_Multiple3.xsl" })] [InlineData("books.xml", "OutputMethod_Multiple3.xsl", 9)] [Theory] public void OS2(object param0, object param1, object param2) { Init(param0.ToString(), param1.ToString()); _xsl.Load(_xslFile); XmlWriterSettings os = _xsl.OutputSettings; switch ((int)param2) { case 2: Assert.Equal(XmlOutputMethod.AutoDetect, os.OutputMethod); break; case 3: Assert.Equal(XmlOutputMethod.Xml, os.OutputMethod); break; case 4: Assert.Equal(XmlOutputMethod.Html, os.OutputMethod); break; case 5: Assert.Equal(XmlOutputMethod.Text, os.OutputMethod); break; case 6: Assert.Equal(XmlOutputMethod.AutoDetect, os.OutputMethod); break; case 7: Assert.Equal(XmlOutputMethod.Text, os.OutputMethod); break; case 8: Assert.Equal(XmlOutputMethod.Xml, os.OutputMethod); break; case 9: Assert.Equal(XmlOutputMethod.Html, os.OutputMethod); break; } return; } //[Variation(id = 10, Desc = "Verify OmitXmlDeclaration when omit-xml-declared is omitted in XSLT, expected false", Pri = 0, Params = new object[] { "books.xml", "OmitXmlDecl_Default.xsl", false, "Default value for OmitXmlDeclaration is 'no'" })] [InlineData("books.xml", "OmitXmlDecl_Default.xsl", false)] //[Variation(id = 11, Desc = "Verify OmitXmlDeclaration when omit-xml-declared is yes in XSLT, expected true", Pri = 0, Params = new object[] { "books.xml", "OmitXmlDecl_Yes.xsl", true, "OmitXmlDeclaration must be 'yes'" })] [InlineData("books.xml", "OmitXmlDecl_Yes.xsl", true)] //[Variation(id = 12, Desc = "Verify OmitXmlDeclaration when omit-xml-declared is no in XSLT, expected false", Pri = 1, Params = new object[] { "books.xml", "OmitXmlDecl_No.xsl", false, "OmitXmlDeclaration must be 'no'" })] [InlineData("books.xml", "OmitXmlDecl_No.xsl", false)] [Theory] public void OS3(object param0, object param1, object param2) { Init(param0.ToString(), param1.ToString()); _xsl.Load(_xslFile); XmlWriterSettings os = _xsl.OutputSettings; Assert.Equal(os.OmitXmlDeclaration, (bool)param2); return; } //[Variation(id = 13, Desc = "Verify OutputSettings when omit-xml-declaration has an invalid value, expected null", Pri = 2, Params = new object[] { "books.xml", "OmitXmlDecl_Invalid1.xsl" })] [InlineData("books.xml", "OmitXmlDecl_Invalid1.xsl")] [Theory] public void OS4(object param0, object param1) { Init(param0.ToString(), param1.ToString()); try { _xsl.Load(_xslFile); } catch (XsltException e) { _output.WriteLine(e.ToString()); XmlWriterSettings os = _xsl.OutputSettings; Assert.Null(os); } return; } //[Variation(id = 14, Desc = "Verify OutputSettings on non well-formed XSLT, expected null", Pri = 2, Params = new object[] { "books.xml", "OmitXmlDecl_Invalid2.xsl" })] [InlineData("books.xml", "OmitXmlDecl_Invalid2.xsl")] [Theory] public void OS5(object param0, object param1) { Init(param0.ToString(), param1.ToString()); try { _xsl.Load(_xslFile); } catch (XsltException e) { _output.WriteLine(e.ToString()); XmlWriterSettings os = _xsl.OutputSettings; Assert.Null(os); } return; } //[Variation(id = 18, Desc = "Verify Encoding set to windows-1252 explicitly, expected windows-1252", Pri = 1, Params = new object[] { "books.xml", "Encoding4.xsl", "windows-1252", "Encoding must be windows-1252" })] [InlineData("books.xml", "Encoding4.xsl", "windows-1252")] [Theory] public void OS6_Windows1252Encoding(object param0, object param1, object param2) { Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); OS6(param0, param1, param2); } //[Variation(id = 15, Desc = "Verify default Encoding, expected UTF-8", Pri = 1, Params = new object[] { "books.xml", "Encoding1.xsl", "utf-8", "Default Encoding must be utf-8" })] [InlineData("books.xml", "Encoding1.xsl", "utf-8")] //[Variation(id = 16, Desc = "Verify Encoding set to UTF-8 explicitly, expected UTF-8", Pri = 1, Params = new object[] { "books.xml", "Encoding2.xsl", "utf-8", "Encoding must be utf-8" })] [InlineData("books.xml", "Encoding2.xsl", "utf-8")] //[Variation(id = 17, Desc = "Verify Encoding set to UTF-16 explicitly, expected UTF-16", Pri = 1, Params = new object[] { "books.xml", "Encoding3.xsl", "utf-16", "Encoding must be utf-16" })] [InlineData("books.xml", "Encoding3.xsl", "utf-16")] //[Variation(id = 19, Desc = "Verify Encoding when multiple xsl:output tags are present, expected the last set (iso-8859-1)", Pri = 1, Params = new object[] { "books.xml", "Encoding5.xsl", "iso-8859-1", "Encoding must be iso-8859-1" })] [InlineData("books.xml", "Encoding5.xsl", "iso-8859-1")] [Theory] public void OS6(object param0, object param1, object param2) { Init(param0.ToString(), param1.ToString()); _xsl.Load(_xslFile); XmlWriterSettings os = _xsl.OutputSettings; Assert.Equal(os.Encoding, System.Text.Encoding.GetEncoding((string)param2)); return; } //[Variation(id = 20, Desc = "Verify Indent when indent is omitted in XSLT, expected false", Pri = 0, Params = new object[] { "books.xml", "Indent_Default.xsl", false, "Default value for Indent is 'no'" })] [InlineData("books.xml", "Indent_Default.xsl", false)] //[Variation(id = 21, Desc = "Verify Indent when indent is yes in XSLT, expected true", Pri = 0, Params = new object[] { "books.xml", "Indent_Yes.xsl", true, "Indent must be 'yes'" })] [InlineData("books.xml", "Indent_Yes.xsl", true)] //[Variation(id = 22, Desc = "Verify Indent when indent is no in XSLT, expected false", Pri = 1, Params = new object[] { "books.xml", "Indent_No.xsl", false, "Indent must be 'no'" })] [InlineData("books.xml", "Indent_No.xsl", false)] [Theory] public void OS7(object param0, object param1, object param2) { Init(param0.ToString(), param1.ToString()); _xsl.Load(_xslFile); XmlWriterSettings os = _xsl.OutputSettings; Assert.Equal(os.Indent, (bool)param2); return; } //[Variation(id = 23, Desc = "Verify OutputSettings when Indent has an invalid value, expected null", Pri = 2, Params = new object[] { "books.xml", "Indent_Invalid1.xsl" })] [InlineData("books.xml", "Indent_Invalid1.xsl")] [Theory] public void OS8(object param0, object param1) { Init(param0.ToString(), param1.ToString()); try { _xsl.Load(_xslFile); } catch (XsltException e) { _output.WriteLine(e.ToString()); XmlWriterSettings os = _xsl.OutputSettings; Assert.Null(os); } return; } //[Variation(id = 24, Desc = "Verify OutputSettings on non well-formed XSLT, expected null", Pri = 2, Params = new object[] { "books.xml", "Indent_Invalid2.xsl" })] [InlineData("books.xml", "Indent_Invalid2.xsl")] [Theory] public void OS9(object param0, object param1) { Init(param0.ToString(), param1.ToString()); try { _xsl.Load(_xslFile); } catch (XsltException e) { _output.WriteLine(e.ToString()); XmlWriterSettings os = _xsl.OutputSettings; Assert.Null(os); } return; } //[Variation(id = 25, Desc = "Verify OutputSettings with all attributes on xsl:output", Pri = 0, Params = new object[] { "books.xml", "OutputSettings.xsl" })] [InlineData("books.xml", "OutputSettings.xsl")] [Theory] public void OS10(object param0, object param1) { Init(param0.ToString(), param1.ToString()); _xsl.Load(_xslFile); XmlWriterSettings os = _xsl.OutputSettings; _output.WriteLine("OmitXmlDeclaration : {0}", os.OmitXmlDeclaration); Assert.True(os.OmitXmlDeclaration); _output.WriteLine("Indent : {0}", os.Indent); Assert.True(os.Indent); _output.WriteLine("OutputMethod : {0}", os.OutputMethod); Assert.Equal(XmlOutputMethod.Xml, os.OutputMethod); _output.WriteLine("Encoding : {0}", os.Encoding.ToString()); Assert.Equal(os.Encoding, System.Text.Encoding.GetEncoding("utf-8")); return; } //[Variation(id = 26, Desc = "Compare Stream Output with XmlWriter over Stream with OutputSettings", Pri = 0, Params = new object[] { "books.xml", "OutputSettings1.xsl" })] [InlineData("books.xml", "OutputSettings1.xsl")] [Theory] public void OS11(object param0, object param1) { Init(param0.ToString(), param1.ToString()); _xsl.Load(_xslFile); //Transform to Stream Stream stm1 = new FileStream("out1.xml", FileMode.Create, FileAccess.ReadWrite); _output.WriteLine("Transforming to Stream1 - 'out1.xml'"); _xsl.Transform(_xmlFile, null, stm1); //Create an XmlWriter using OutputSettings Stream stm2 = new FileStream("out2.xml", FileMode.Create, FileAccess.ReadWrite); XmlWriterSettings os = _xsl.OutputSettings; XmlWriter xw = XmlWriter.Create(stm2, os); //Transform to XmlWriter _output.WriteLine("Transforming to XmlWriter over Stream2 with XSLT OutputSettings - 'out2.xml'"); _xsl.Transform(_xmlFile, null, xw); //Close the streams stm1.Dispose(); stm2.Dispose(); //XmlDiff the 2 Outputs. XmlDiff.XmlDiff diff = new XmlDiff.XmlDiff(); XmlReader xr1 = XmlReader.Create("out1.xml"); XmlReader xr2 = XmlReader.Create("out2.xml"); //XmlDiff _output.WriteLine("Comparing the Stream Output and XmlWriter Output"); Assert.True(diff.Compare(xr1, xr2)); //Delete the temp files xr1.Dispose(); xr2.Dispose(); File.Delete("out1.xml"); File.Delete("out2.xml"); return; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; using Xunit.Abstractions; using System.IO; using System.Xml.Xsl; using System.Text; namespace System.Xml.Tests { //[TestCase(Name = "OutputSettings", Desc = "This testcase tests the OutputSettings on XslCompiledTransform", Param = "Debug")] public class COutputSettings : XsltApiTestCaseBase2 { private XslCompiledTransform _xsl = null; private string _xmlFile = string.Empty; private string _xslFile = string.Empty; private ITestOutputHelper _output; public COutputSettings(ITestOutputHelper output) : base(output) { _output = output; } private void Init(string xmlFile, string xslFile) { _xsl = new XslCompiledTransform(); _xmlFile = FullFilePath(xmlFile); _xslFile = FullFilePath(xslFile); return; } private StringWriter Transform() { StringWriter sw = new StringWriter(); _xsl.Transform(_xmlFile, null, sw); return sw; } private void VerifyResult(object actual, object expected, string message) { _output.WriteLine("Expected : {0}", expected); _output.WriteLine("Actual : {0}", actual); Assert.Equal(actual, expected); } //[Variation(id = 1, Desc = "Verify the default value of the OutputSettings, expected null", Pri = 0)] [Fact] public void OS1() { XslCompiledTransform xslt = new XslCompiledTransform(); Assert.True(xslt.OutputSettings == null); return; } //[Variation(id = 2, Desc = "Verify the OutputMethod when output method is not specified, expected AutoDetect", Pri = 1, Params = new object[] { "books.xml", "OutputMethod_Default.xsl" })] [InlineData("books.xml", "OutputMethod_Default.xsl", 2)] //[Variation(id = 3, Desc = "Verify the OutputMethod when output method is xml, expected Xml", Pri = 0, Params = new object[] { "books.xml", "OutputMethod_Xml.xsl" })] [InlineData("books.xml", "OutputMethod_Xml.xsl", 3)] //[Variation(id = 4, Desc = "Verify the OutputMethod when output method is html, expected Html", Pri = 0, Params = new object[] { "books.xml", "OutputMethod_Html.xsl" })] [InlineData("books.xml", "OutputMethod_Html.xsl", 4)] //[Variation(id = 5, Desc = "Verify the OutputMethod when output method is text, expected Text", Pri = 1, Params = new object[] { "books.xml", "OutputMethod_Text.xsl" })] [InlineData("books.xml", "OutputMethod_Text.xsl", 5)] //[Variation(id = 6, Desc = "Verify the OutputMethod when output method is not specified, first output element is html, expected AutoDetect", Pri = 1, Params = new object[] { "books.xml", "OutputMethod_LiteralHtml.xsl" })] [InlineData("books.xml", "OutputMethod_LiteralHtml.xsl", 6)] //[Variation(id = 7, Desc = "Verify the OutputMethod when multiple output methods (Xml,Html,Text) are defined, expected Text", Pri = 1, Params = new object[] { "books.xml", "OutputMethod_Multiple1.xsl" })] [InlineData("books.xml", "OutputMethod_Multiple1.xsl", 7)] //[Variation(id = 8, Desc = "Verify the OutputMethod when multiple output methods (Html,Text,Xml) are defined, expected Xml", Pri = 1, Params = new object[] { "books.xml", "OutputMethod_Multiple2.xsl" })] [InlineData("books.xml", "OutputMethod_Multiple2.xsl", 8)] //[Variation(id = 9, Desc = "Verify the OutputMethod when multiple output methods (Text,Xml,Html) are defined, expected Html", Pri = 1, Params = new object[] { "books.xml", "OutputMethod_Multiple3.xsl" })] [InlineData("books.xml", "OutputMethod_Multiple3.xsl", 9)] [Theory] public void OS2(object param0, object param1, object param2) { Init(param0.ToString(), param1.ToString()); _xsl.Load(_xslFile); XmlWriterSettings os = _xsl.OutputSettings; switch ((int)param2) { case 2: Assert.Equal(XmlOutputMethod.AutoDetect, os.OutputMethod); break; case 3: Assert.Equal(XmlOutputMethod.Xml, os.OutputMethod); break; case 4: Assert.Equal(XmlOutputMethod.Html, os.OutputMethod); break; case 5: Assert.Equal(XmlOutputMethod.Text, os.OutputMethod); break; case 6: Assert.Equal(XmlOutputMethod.AutoDetect, os.OutputMethod); break; case 7: Assert.Equal(XmlOutputMethod.Text, os.OutputMethod); break; case 8: Assert.Equal(XmlOutputMethod.Xml, os.OutputMethod); break; case 9: Assert.Equal(XmlOutputMethod.Html, os.OutputMethod); break; } return; } //[Variation(id = 10, Desc = "Verify OmitXmlDeclaration when omit-xml-declared is omitted in XSLT, expected false", Pri = 0, Params = new object[] { "books.xml", "OmitXmlDecl_Default.xsl", false, "Default value for OmitXmlDeclaration is 'no'" })] [InlineData("books.xml", "OmitXmlDecl_Default.xsl", false)] //[Variation(id = 11, Desc = "Verify OmitXmlDeclaration when omit-xml-declared is yes in XSLT, expected true", Pri = 0, Params = new object[] { "books.xml", "OmitXmlDecl_Yes.xsl", true, "OmitXmlDeclaration must be 'yes'" })] [InlineData("books.xml", "OmitXmlDecl_Yes.xsl", true)] //[Variation(id = 12, Desc = "Verify OmitXmlDeclaration when omit-xml-declared is no in XSLT, expected false", Pri = 1, Params = new object[] { "books.xml", "OmitXmlDecl_No.xsl", false, "OmitXmlDeclaration must be 'no'" })] [InlineData("books.xml", "OmitXmlDecl_No.xsl", false)] [Theory] public void OS3(object param0, object param1, object param2) { Init(param0.ToString(), param1.ToString()); _xsl.Load(_xslFile); XmlWriterSettings os = _xsl.OutputSettings; Assert.Equal(os.OmitXmlDeclaration, (bool)param2); return; } //[Variation(id = 13, Desc = "Verify OutputSettings when omit-xml-declaration has an invalid value, expected null", Pri = 2, Params = new object[] { "books.xml", "OmitXmlDecl_Invalid1.xsl" })] [InlineData("books.xml", "OmitXmlDecl_Invalid1.xsl")] [Theory] public void OS4(object param0, object param1) { Init(param0.ToString(), param1.ToString()); try { _xsl.Load(_xslFile); } catch (XsltException e) { _output.WriteLine(e.ToString()); XmlWriterSettings os = _xsl.OutputSettings; Assert.Null(os); } return; } //[Variation(id = 14, Desc = "Verify OutputSettings on non well-formed XSLT, expected null", Pri = 2, Params = new object[] { "books.xml", "OmitXmlDecl_Invalid2.xsl" })] [InlineData("books.xml", "OmitXmlDecl_Invalid2.xsl")] [Theory] public void OS5(object param0, object param1) { Init(param0.ToString(), param1.ToString()); try { _xsl.Load(_xslFile); } catch (XsltException e) { _output.WriteLine(e.ToString()); XmlWriterSettings os = _xsl.OutputSettings; Assert.Null(os); } return; } //[Variation(id = 18, Desc = "Verify Encoding set to windows-1252 explicitly, expected windows-1252", Pri = 1, Params = new object[] { "books.xml", "Encoding4.xsl", "windows-1252", "Encoding must be windows-1252" })] [InlineData("books.xml", "Encoding4.xsl", "windows-1252")] [Theory] public void OS6_Windows1252Encoding(object param0, object param1, object param2) { Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); OS6(param0, param1, param2); } //[Variation(id = 15, Desc = "Verify default Encoding, expected UTF-8", Pri = 1, Params = new object[] { "books.xml", "Encoding1.xsl", "utf-8", "Default Encoding must be utf-8" })] [InlineData("books.xml", "Encoding1.xsl", "utf-8")] //[Variation(id = 16, Desc = "Verify Encoding set to UTF-8 explicitly, expected UTF-8", Pri = 1, Params = new object[] { "books.xml", "Encoding2.xsl", "utf-8", "Encoding must be utf-8" })] [InlineData("books.xml", "Encoding2.xsl", "utf-8")] //[Variation(id = 17, Desc = "Verify Encoding set to UTF-16 explicitly, expected UTF-16", Pri = 1, Params = new object[] { "books.xml", "Encoding3.xsl", "utf-16", "Encoding must be utf-16" })] [InlineData("books.xml", "Encoding3.xsl", "utf-16")] //[Variation(id = 19, Desc = "Verify Encoding when multiple xsl:output tags are present, expected the last set (iso-8859-1)", Pri = 1, Params = new object[] { "books.xml", "Encoding5.xsl", "iso-8859-1", "Encoding must be iso-8859-1" })] [InlineData("books.xml", "Encoding5.xsl", "iso-8859-1")] [Theory] public void OS6(object param0, object param1, object param2) { Init(param0.ToString(), param1.ToString()); _xsl.Load(_xslFile); XmlWriterSettings os = _xsl.OutputSettings; Assert.Equal(os.Encoding, System.Text.Encoding.GetEncoding((string)param2)); return; } //[Variation(id = 20, Desc = "Verify Indent when indent is omitted in XSLT, expected false", Pri = 0, Params = new object[] { "books.xml", "Indent_Default.xsl", false, "Default value for Indent is 'no'" })] [InlineData("books.xml", "Indent_Default.xsl", false)] //[Variation(id = 21, Desc = "Verify Indent when indent is yes in XSLT, expected true", Pri = 0, Params = new object[] { "books.xml", "Indent_Yes.xsl", true, "Indent must be 'yes'" })] [InlineData("books.xml", "Indent_Yes.xsl", true)] //[Variation(id = 22, Desc = "Verify Indent when indent is no in XSLT, expected false", Pri = 1, Params = new object[] { "books.xml", "Indent_No.xsl", false, "Indent must be 'no'" })] [InlineData("books.xml", "Indent_No.xsl", false)] [Theory] public void OS7(object param0, object param1, object param2) { Init(param0.ToString(), param1.ToString()); _xsl.Load(_xslFile); XmlWriterSettings os = _xsl.OutputSettings; Assert.Equal(os.Indent, (bool)param2); return; } //[Variation(id = 23, Desc = "Verify OutputSettings when Indent has an invalid value, expected null", Pri = 2, Params = new object[] { "books.xml", "Indent_Invalid1.xsl" })] [InlineData("books.xml", "Indent_Invalid1.xsl")] [Theory] public void OS8(object param0, object param1) { Init(param0.ToString(), param1.ToString()); try { _xsl.Load(_xslFile); } catch (XsltException e) { _output.WriteLine(e.ToString()); XmlWriterSettings os = _xsl.OutputSettings; Assert.Null(os); } return; } //[Variation(id = 24, Desc = "Verify OutputSettings on non well-formed XSLT, expected null", Pri = 2, Params = new object[] { "books.xml", "Indent_Invalid2.xsl" })] [InlineData("books.xml", "Indent_Invalid2.xsl")] [Theory] public void OS9(object param0, object param1) { Init(param0.ToString(), param1.ToString()); try { _xsl.Load(_xslFile); } catch (XsltException e) { _output.WriteLine(e.ToString()); XmlWriterSettings os = _xsl.OutputSettings; Assert.Null(os); } return; } //[Variation(id = 25, Desc = "Verify OutputSettings with all attributes on xsl:output", Pri = 0, Params = new object[] { "books.xml", "OutputSettings.xsl" })] [InlineData("books.xml", "OutputSettings.xsl")] [Theory] public void OS10(object param0, object param1) { Init(param0.ToString(), param1.ToString()); _xsl.Load(_xslFile); XmlWriterSettings os = _xsl.OutputSettings; _output.WriteLine("OmitXmlDeclaration : {0}", os.OmitXmlDeclaration); Assert.True(os.OmitXmlDeclaration); _output.WriteLine("Indent : {0}", os.Indent); Assert.True(os.Indent); _output.WriteLine("OutputMethod : {0}", os.OutputMethod); Assert.Equal(XmlOutputMethod.Xml, os.OutputMethod); _output.WriteLine("Encoding : {0}", os.Encoding.ToString()); Assert.Equal(os.Encoding, System.Text.Encoding.GetEncoding("utf-8")); return; } //[Variation(id = 26, Desc = "Compare Stream Output with XmlWriter over Stream with OutputSettings", Pri = 0, Params = new object[] { "books.xml", "OutputSettings1.xsl" })] [InlineData("books.xml", "OutputSettings1.xsl")] [Theory] public void OS11(object param0, object param1) { Init(param0.ToString(), param1.ToString()); _xsl.Load(_xslFile); //Transform to Stream Stream stm1 = new FileStream("out1.xml", FileMode.Create, FileAccess.ReadWrite); _output.WriteLine("Transforming to Stream1 - 'out1.xml'"); _xsl.Transform(_xmlFile, null, stm1); //Create an XmlWriter using OutputSettings Stream stm2 = new FileStream("out2.xml", FileMode.Create, FileAccess.ReadWrite); XmlWriterSettings os = _xsl.OutputSettings; XmlWriter xw = XmlWriter.Create(stm2, os); //Transform to XmlWriter _output.WriteLine("Transforming to XmlWriter over Stream2 with XSLT OutputSettings - 'out2.xml'"); _xsl.Transform(_xmlFile, null, xw); //Close the streams stm1.Dispose(); stm2.Dispose(); //XmlDiff the 2 Outputs. XmlDiff.XmlDiff diff = new XmlDiff.XmlDiff(); XmlReader xr1 = XmlReader.Create("out1.xml"); XmlReader xr2 = XmlReader.Create("out2.xml"); //XmlDiff _output.WriteLine("Comparing the Stream Output and XmlWriter Output"); Assert.True(diff.Compare(xr1, xr2)); //Delete the temp files xr1.Dispose(); xr2.Dispose(); File.Delete("out1.xml"); File.Delete("out2.xml"); return; } } }
-1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/tests/JIT/HardwareIntrinsics/General/Vector256_1/op_BitwiseOr.Double.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; namespace JIT.HardwareIntrinsics.General { public static partial class Program { private static void op_BitwiseOrDouble() { var test = new VectorBinaryOpTest__op_BitwiseOrDouble(); // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorBinaryOpTest__op_BitwiseOrDouble { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Double[] inArray1, Double[] inArray2, Double[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Double>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Double>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Double>(); if ((alignment != 32 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Double, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Double, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector256<Double> _fld1; public Vector256<Double> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref testStruct._fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref testStruct._fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); return testStruct; } public void RunStructFldScenario(VectorBinaryOpTest__op_BitwiseOrDouble testClass) { var result = _fld1 | _fld2; Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector256<Double>>() / sizeof(Double); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector256<Double>>() / sizeof(Double); private static readonly int RetElementCount = Unsafe.SizeOf<Vector256<Double>>() / sizeof(Double); private static Double[] _data1 = new Double[Op1ElementCount]; private static Double[] _data2 = new Double[Op2ElementCount]; private static Vector256<Double> _clsVar1; private static Vector256<Double> _clsVar2; private Vector256<Double> _fld1; private Vector256<Double> _fld2; private DataTable _dataTable; static VectorBinaryOpTest__op_BitwiseOrDouble() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); } public VectorBinaryOpTest__op_BitwiseOrDouble() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr) | Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(Vector256<Double>).GetMethod("op_BitwiseOr", new Type[] { typeof(Vector256<Double>), typeof(Vector256<Double>) }) .Invoke(null, new object[] { Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = _clsVar1 | _clsVar2; Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr); var result = op1 | op2; Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new VectorBinaryOpTest__op_BitwiseOrDouble(); var result = test._fld1 | test._fld2; Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = _fld1 | _fld2; Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = test._fld1 | test._fld2; Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } private void ValidateResult(Vector256<Double> op1, Vector256<Double> op2, void* result, [CallerMemberName] string method = "") { Double[] inArray1 = new Double[Op1ElementCount]; Double[] inArray2 = new Double[Op2ElementCount]; Double[] outArray = new Double[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Double>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Double[] inArray1 = new Double[Op1ElementCount]; Double[] inArray2 = new Double[Op2ElementCount]; Double[] outArray = new Double[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector256<Double>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector256<Double>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Double>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Double[] left, Double[] right, Double[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (BitConverter.DoubleToInt64Bits(result[0]) != (BitConverter.DoubleToInt64Bits(left[0]) | BitConverter.DoubleToInt64Bits(right[0]))) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (BitConverter.DoubleToInt64Bits(result[i]) != (BitConverter.DoubleToInt64Bits(left[i]) | BitConverter.DoubleToInt64Bits(right[i]))) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Vector256)}.op_BitwiseOr<Double>(Vector256<Double>, Vector256<Double>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; namespace JIT.HardwareIntrinsics.General { public static partial class Program { private static void op_BitwiseOrDouble() { var test = new VectorBinaryOpTest__op_BitwiseOrDouble(); // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorBinaryOpTest__op_BitwiseOrDouble { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Double[] inArray1, Double[] inArray2, Double[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Double>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Double>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Double>(); if ((alignment != 32 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Double, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Double, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector256<Double> _fld1; public Vector256<Double> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref testStruct._fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref testStruct._fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); return testStruct; } public void RunStructFldScenario(VectorBinaryOpTest__op_BitwiseOrDouble testClass) { var result = _fld1 | _fld2; Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector256<Double>>() / sizeof(Double); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector256<Double>>() / sizeof(Double); private static readonly int RetElementCount = Unsafe.SizeOf<Vector256<Double>>() / sizeof(Double); private static Double[] _data1 = new Double[Op1ElementCount]; private static Double[] _data2 = new Double[Op2ElementCount]; private static Vector256<Double> _clsVar1; private static Vector256<Double> _clsVar2; private Vector256<Double> _fld1; private Vector256<Double> _fld2; private DataTable _dataTable; static VectorBinaryOpTest__op_BitwiseOrDouble() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); } public VectorBinaryOpTest__op_BitwiseOrDouble() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr) | Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(Vector256<Double>).GetMethod("op_BitwiseOr", new Type[] { typeof(Vector256<Double>), typeof(Vector256<Double>) }) .Invoke(null, new object[] { Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = _clsVar1 | _clsVar2; Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr); var result = op1 | op2; Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new VectorBinaryOpTest__op_BitwiseOrDouble(); var result = test._fld1 | test._fld2; Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = _fld1 | _fld2; Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = test._fld1 | test._fld2; Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } private void ValidateResult(Vector256<Double> op1, Vector256<Double> op2, void* result, [CallerMemberName] string method = "") { Double[] inArray1 = new Double[Op1ElementCount]; Double[] inArray2 = new Double[Op2ElementCount]; Double[] outArray = new Double[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Double>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Double[] inArray1 = new Double[Op1ElementCount]; Double[] inArray2 = new Double[Op2ElementCount]; Double[] outArray = new Double[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector256<Double>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector256<Double>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Double>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Double[] left, Double[] right, Double[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (BitConverter.DoubleToInt64Bits(result[0]) != (BitConverter.DoubleToInt64Bits(left[0]) | BitConverter.DoubleToInt64Bits(right[0]))) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (BitConverter.DoubleToInt64Bits(result[i]) != (BitConverter.DoubleToInt64Bits(left[i]) | BitConverter.DoubleToInt64Bits(right[i]))) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Vector256)}.op_BitwiseOr<Double>(Vector256<Double>, Vector256<Double>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/tests/JIT/Directed/StructPromote/Unsafe/AccessInvalidFieldOffset.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> </PropertyGroup> <PropertyGroup> <DebugType>None</DebugType> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="$(MSBuildProjectName).cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> </PropertyGroup> <PropertyGroup> <DebugType>None</DebugType> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="$(MSBuildProjectName).cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/tests/JIT/HardwareIntrinsics/X86/Avx2_Vector128/BroadcastScalarToVector128.UInt16.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; namespace JIT.HardwareIntrinsics.X86 { public static partial class Program { private static void BroadcastScalarToVector128UInt16() { var test = new SimpleUnaryOpTest__BroadcastScalarToVector128UInt16(); if (test.IsSupported) { // Validates basic functionality works test.RunBasicScenario_Load(); // Validates calling via reflection works test.RunReflectionScenario_Load(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector128UInt16 { private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<UInt16>>() / sizeof(UInt16); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<UInt16>>() / sizeof(UInt16); private static UInt16[] _data = new UInt16[Op1ElementCount]; private SimpleUnaryOpTest__DataTable<UInt16, UInt16> _dataTable; public SimpleUnaryOpTest__BroadcastScalarToVector128UInt16() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt16(); } _dataTable = new SimpleUnaryOpTest__DataTable<UInt16, UInt16>(_data, new UInt16[RetElementCount], LargestVectorSize); } public bool IsSupported => Avx2.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = Avx2.BroadcastScalarToVector128( (UInt16*)(_dataTable.inArrayPtr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(Avx2).GetMethod(nameof(Avx2.BroadcastScalarToVector128), new Type[] { typeof(UInt16*) }) .Invoke(null, new object[] { Pointer.Box(_dataTable.inArrayPtr, typeof(UInt16*)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt16>)(result)); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); Succeeded = false; try { RunBasicScenario_Load(); } catch (PlatformNotSupportedException) { Succeeded = true; } } private void ValidateResult(Vector128<UInt16> firstOp, void* result, [CallerMemberName] string method = "") { UInt16[] inArray = new UInt16[Op1ElementCount]; UInt16[] outArray = new UInt16[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray[0]), firstOp); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); ValidateResult(inArray, outArray, method); } private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") { UInt16[] inArray = new UInt16[Op1ElementCount]; UInt16[] outArray = new UInt16[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); ValidateResult(inArray, outArray, method); } private void ValidateResult(UInt16[] firstOp, UInt16[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (firstOp[0] != result[0]) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if ((firstOp[0] != result[i])) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Avx2)}.{nameof(Avx2.BroadcastScalarToVector128)}<UInt16>(Vector128<UInt16>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; namespace JIT.HardwareIntrinsics.X86 { public static partial class Program { private static void BroadcastScalarToVector128UInt16() { var test = new SimpleUnaryOpTest__BroadcastScalarToVector128UInt16(); if (test.IsSupported) { // Validates basic functionality works test.RunBasicScenario_Load(); // Validates calling via reflection works test.RunReflectionScenario_Load(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector128UInt16 { private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<UInt16>>() / sizeof(UInt16); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<UInt16>>() / sizeof(UInt16); private static UInt16[] _data = new UInt16[Op1ElementCount]; private SimpleUnaryOpTest__DataTable<UInt16, UInt16> _dataTable; public SimpleUnaryOpTest__BroadcastScalarToVector128UInt16() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt16(); } _dataTable = new SimpleUnaryOpTest__DataTable<UInt16, UInt16>(_data, new UInt16[RetElementCount], LargestVectorSize); } public bool IsSupported => Avx2.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = Avx2.BroadcastScalarToVector128( (UInt16*)(_dataTable.inArrayPtr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(Avx2).GetMethod(nameof(Avx2.BroadcastScalarToVector128), new Type[] { typeof(UInt16*) }) .Invoke(null, new object[] { Pointer.Box(_dataTable.inArrayPtr, typeof(UInt16*)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt16>)(result)); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); Succeeded = false; try { RunBasicScenario_Load(); } catch (PlatformNotSupportedException) { Succeeded = true; } } private void ValidateResult(Vector128<UInt16> firstOp, void* result, [CallerMemberName] string method = "") { UInt16[] inArray = new UInt16[Op1ElementCount]; UInt16[] outArray = new UInt16[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray[0]), firstOp); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); ValidateResult(inArray, outArray, method); } private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") { UInt16[] inArray = new UInt16[Op1ElementCount]; UInt16[] outArray = new UInt16[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); ValidateResult(inArray, outArray, method); } private void ValidateResult(UInt16[] firstOp, UInt16[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (firstOp[0] != result[0]) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if ((firstOp[0] != result[i])) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Avx2)}.{nameof(Avx2.BroadcastScalarToVector128)}<UInt16>(Vector128<UInt16>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/tests/JIT/Methodical/explicit/misc/refarg_box_val.il
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. .assembly extern mscorlib { } .assembly extern System.Console { .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) .ver 4:0:0:0 } .assembly 'refarg_box_val'// as "refarg_box_val" { // .custom instance void ['mscorlib']System.Diagnostics.DebuggableAttribute::.ctor(bool, // bool) = ( 01 00 00 01 00 00 ) } .assembly extern xunit.core {} // MVID: {27E0B251-2BC1-4652-9A1C-3EFA7F79CFC4} .namespace Test { .class value private auto ansi sealed Val extends ['mscorlib']System.ValueType { .field public float64 padding1 .field public class System.Object padding2 .field public unsigned int8 padding3 .field public unsigned int16 padding4 .field public int32 'value' .method public hidebysig specialname rtspecialname instance void .ctor(int32 val) il managed { // Code size 55 (0x37) .maxstack 2 .locals (int32 V_0) IL_0000: ldarg.0 IL_0001: ldc.r8 0. IL_000a: stfld float64 Test.Val::padding1 IL_000f: ldarg.0 IL_0010: ldc.i4.s 11 IL_0012: stloc.0 IL_0013: ldloc.s V_0 IL_0015: box ['mscorlib']System.Int32 IL_001a: stfld class System.Object Test.Val::padding2 IL_001f: ldarg.0 IL_0020: ldc.i4.s 11 IL_0022: stfld unsigned int8 Test.Val::padding3 IL_0027: ldarg.0 IL_0028: ldc.i4.s 11 IL_002a: stfld unsigned int16 Test.Val::padding4 IL_002f: ldarg.0 IL_0030: ldarg.1 IL_0031: stfld int32 Test.Val::'value' IL_0036: ret } // end of method 'Val::.ctor' } // end of class 'Val' .class private auto ansi App extends ['mscorlib']System.Object { .field private static class System.Object s_aa .method private hidebysig static void Litter() il managed { // Code size 38 (0x26) .maxstack 2 .locals (int32 V_0, int32[] V_1) IL_0000: call void ['mscorlib']System.GC::Collect() IL_0005: ldc.i4.0 IL_0006: stloc.0 IL_0007: br.s IL_0018 IL_0009: ldc.i4 0x3e8 IL_000e: newarr ['mscorlib']System.Int32 IL_0013: stloc.1 IL_0014: ldloc.0 IL_0015: ldc.i4.1 IL_0016: add IL_0017: stloc.0 IL_0018: ldloc.0 IL_0019: ldc.i4 0x3e8 IL_001e: blt.s IL_0009 IL_0020: call void ['mscorlib']System.GC::Collect() IL_0025: ret } // end of method 'App::Litter' .method private hidebysig static int32 Test(value class Test.Val& n) il managed { // Code size 54 (0x36) .maxstack 2 .locals (int32 V_0) IL_0000: ldnull IL_0001: stsfld class System.Object Test.App::s_aa IL_0006: call void Test.App::Litter() IL_000b: ldarg.0 IL_000c: ldfld int32 Test.Val::'value' IL_0011: ldc.i4 0x13a IL_0016: beq.s IL_0026 IL_0018: ldstr "*** failed ***" IL_001d: call void [System.Console]System.Console::WriteLine(class System.String) IL_0022: ldc.i4.1 IL_0023: stloc.0 IL_0024: br.s IL_0034 IL_0026: ldstr "*** passed ***" IL_002b: call void [System.Console]System.Console::WriteLine(class System.String) IL_0030: ldc.i4 0x64 IL_0031: stloc.0 IL_0032: br.s IL_0034 IL_0034: ldloc.0 IL_0035: ret } // end of method 'App::Test' .method private hidebysig static int32 Main() il managed { .custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = ( 01 00 00 00 ) .entrypoint // Code size 32 (0x20) .maxstack 2 .locals (value class Test.Val ZZZz, //not used now int32 V_1, int32 V_2) //IL_0000: ldloc.s V_0 //IL_0002: ldc.i4.0 //IL_0003: call instance void Test.Val::.ctor(int32) //IL_0008: ldloc.s V_0 ldsfld class System.Object Test.App::s_aa unbox Test.Val IL_000a: call int32 Test.App::Test(value class Test.Val&) IL_000f: stloc.1 IL_0010: call void ['mscorlib']System.GC::Collect() IL_0015: call void ['mscorlib']System.GC::WaitForPendingFinalizers() IL_001a: ldloc.1 IL_001b: stloc.2 IL_001c: br.s IL_001e IL_001e: ldloc.2 IL_001f: ret } // end of method 'App::Main' .method public hidebysig specialname rtspecialname static void .cctor() il managed { // Code size 24 (0x18) .maxstack 2 .locals (value class Test.Val V_0) IL_0000: ldc.i4 0x13a IL_0005: newobj instance void Test.Val::.ctor(int32) IL_000a: stloc.0 IL_000b: ldloc.s V_0 IL_000d: box Test.Val IL_0012: stsfld class System.Object Test.App::s_aa IL_0017: ret } // end of method 'App::.cctor' .method public hidebysig specialname rtspecialname instance void .ctor() il managed { // Code size 7 (0x7) .maxstack 8 IL_0000: ldarg.0 IL_0001: call instance void ['mscorlib']System.Object::.ctor() IL_0006: ret } // end of method 'App::.ctor' } // end of class 'App' } // end of namespace 'Test' //*********** DISASSEMBLY COMPLETE ***********************
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. .assembly extern mscorlib { } .assembly extern System.Console { .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) .ver 4:0:0:0 } .assembly 'refarg_box_val'// as "refarg_box_val" { // .custom instance void ['mscorlib']System.Diagnostics.DebuggableAttribute::.ctor(bool, // bool) = ( 01 00 00 01 00 00 ) } .assembly extern xunit.core {} // MVID: {27E0B251-2BC1-4652-9A1C-3EFA7F79CFC4} .namespace Test { .class value private auto ansi sealed Val extends ['mscorlib']System.ValueType { .field public float64 padding1 .field public class System.Object padding2 .field public unsigned int8 padding3 .field public unsigned int16 padding4 .field public int32 'value' .method public hidebysig specialname rtspecialname instance void .ctor(int32 val) il managed { // Code size 55 (0x37) .maxstack 2 .locals (int32 V_0) IL_0000: ldarg.0 IL_0001: ldc.r8 0. IL_000a: stfld float64 Test.Val::padding1 IL_000f: ldarg.0 IL_0010: ldc.i4.s 11 IL_0012: stloc.0 IL_0013: ldloc.s V_0 IL_0015: box ['mscorlib']System.Int32 IL_001a: stfld class System.Object Test.Val::padding2 IL_001f: ldarg.0 IL_0020: ldc.i4.s 11 IL_0022: stfld unsigned int8 Test.Val::padding3 IL_0027: ldarg.0 IL_0028: ldc.i4.s 11 IL_002a: stfld unsigned int16 Test.Val::padding4 IL_002f: ldarg.0 IL_0030: ldarg.1 IL_0031: stfld int32 Test.Val::'value' IL_0036: ret } // end of method 'Val::.ctor' } // end of class 'Val' .class private auto ansi App extends ['mscorlib']System.Object { .field private static class System.Object s_aa .method private hidebysig static void Litter() il managed { // Code size 38 (0x26) .maxstack 2 .locals (int32 V_0, int32[] V_1) IL_0000: call void ['mscorlib']System.GC::Collect() IL_0005: ldc.i4.0 IL_0006: stloc.0 IL_0007: br.s IL_0018 IL_0009: ldc.i4 0x3e8 IL_000e: newarr ['mscorlib']System.Int32 IL_0013: stloc.1 IL_0014: ldloc.0 IL_0015: ldc.i4.1 IL_0016: add IL_0017: stloc.0 IL_0018: ldloc.0 IL_0019: ldc.i4 0x3e8 IL_001e: blt.s IL_0009 IL_0020: call void ['mscorlib']System.GC::Collect() IL_0025: ret } // end of method 'App::Litter' .method private hidebysig static int32 Test(value class Test.Val& n) il managed { // Code size 54 (0x36) .maxstack 2 .locals (int32 V_0) IL_0000: ldnull IL_0001: stsfld class System.Object Test.App::s_aa IL_0006: call void Test.App::Litter() IL_000b: ldarg.0 IL_000c: ldfld int32 Test.Val::'value' IL_0011: ldc.i4 0x13a IL_0016: beq.s IL_0026 IL_0018: ldstr "*** failed ***" IL_001d: call void [System.Console]System.Console::WriteLine(class System.String) IL_0022: ldc.i4.1 IL_0023: stloc.0 IL_0024: br.s IL_0034 IL_0026: ldstr "*** passed ***" IL_002b: call void [System.Console]System.Console::WriteLine(class System.String) IL_0030: ldc.i4 0x64 IL_0031: stloc.0 IL_0032: br.s IL_0034 IL_0034: ldloc.0 IL_0035: ret } // end of method 'App::Test' .method private hidebysig static int32 Main() il managed { .custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = ( 01 00 00 00 ) .entrypoint // Code size 32 (0x20) .maxstack 2 .locals (value class Test.Val ZZZz, //not used now int32 V_1, int32 V_2) //IL_0000: ldloc.s V_0 //IL_0002: ldc.i4.0 //IL_0003: call instance void Test.Val::.ctor(int32) //IL_0008: ldloc.s V_0 ldsfld class System.Object Test.App::s_aa unbox Test.Val IL_000a: call int32 Test.App::Test(value class Test.Val&) IL_000f: stloc.1 IL_0010: call void ['mscorlib']System.GC::Collect() IL_0015: call void ['mscorlib']System.GC::WaitForPendingFinalizers() IL_001a: ldloc.1 IL_001b: stloc.2 IL_001c: br.s IL_001e IL_001e: ldloc.2 IL_001f: ret } // end of method 'App::Main' .method public hidebysig specialname rtspecialname static void .cctor() il managed { // Code size 24 (0x18) .maxstack 2 .locals (value class Test.Val V_0) IL_0000: ldc.i4 0x13a IL_0005: newobj instance void Test.Val::.ctor(int32) IL_000a: stloc.0 IL_000b: ldloc.s V_0 IL_000d: box Test.Val IL_0012: stsfld class System.Object Test.App::s_aa IL_0017: ret } // end of method 'App::.cctor' .method public hidebysig specialname rtspecialname instance void .ctor() il managed { // Code size 7 (0x7) .maxstack 8 IL_0000: ldarg.0 IL_0001: call instance void ['mscorlib']System.Object::.ctor() IL_0006: ret } // end of method 'App::.ctor' } // end of class 'App' } // end of namespace 'Test' //*********** DISASSEMBLY COMPLETE ***********************
-1
dotnet/runtime
65,932
Update stale comments that reference GitHub issues
Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
jeffhandley
2022-02-27T20:14:23Z
2022-02-28T03:21:49Z
68fb7fc68cc1af800bee1d38af22b5027bf4ab4e
a58437f7e6794aba690e053827a5d436919c6bc3
Update stale comments that reference GitHub issues. Fixes #65931 [Cleanup Issue-URLs in Code · Issue #63902 · dotnet/runtime](https://github.com/dotnet/runtime/issues/63902) identified stale comments that reference GitHub issues. This PR updates comments to reflect updated statuses. _I'm marking this PR as a draft while working through that issue to see if other comments can also be quickly updated._ /cc @deeprobin
./src/libraries/System.Text.Encoding/tests/UTF7Encoding/UTF7EncodingDecode.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using Xunit; namespace System.Text.Tests { public class UTF7EncodingDecode { public static IEnumerable<object[]> Decode_TestData() { // All ASCII chars for (int i = 0; i <= byte.MaxValue; i++) { char c = (char)i; if (c == 43) { continue; } yield return new object[] { new byte[] { (byte)c }, 0, 1, c.ToString() }; yield return new object[] { new byte[] { 97, (byte)c, 98 }, 1, 1, c.ToString() }; yield return new object[] { new byte[] { 97, (byte)c, 98 }, 2, 1, "b" }; yield return new object[] { new byte[] { 97, (byte)c, 98 }, 0, 3, "a" + c.ToString() + "b" }; } // Plus yield return new object[] { new byte[] { (byte)'+' }, 0, 1, string.Empty }; yield return new object[] { new byte[] { 43, 45 }, 0, 2, "+" }; yield return new object[] { new byte[] { 43, 45, 65 }, 0, 3, "+A" }; yield return new object[] { new byte[] { 0x2B, 0x2D, 0x2D }, 0, 3,"+-" }; // UTF7 code points can be represented in different sequences of bytes yield return new object[] { new byte[] { 0x41, 0x09, 0x0D, 0x0A, 0x20, 0x2F, 0x7A }, 0, 7, "A\t\r\n /z" }; yield return new object[] { new byte[] { 0x2B, 0x41, 0x45, 0x45, 0x41, 0x43, 0x51 }, 0, 7, "A\t" }; yield return new object[] { new byte[] { 0x2B, 0x09 }, 0, 2, "\t" }; yield return new object[] { new byte[] { 0x2B, 0x09, 0x2D }, 0, 3, "\t-" }; yield return new object[] { new byte[] { 0x2B, 0x1E, 0x2D }, 0, 3, "\u001E-" }; yield return new object[] { new byte[] { 0x2B, 0x7F, 0x1E, 0x2D }, 0, 4, "\u007F\u001E-" }; yield return new object[] { new byte[] { 0x1E }, 0, 1, "\u001e" }; yield return new object[] { new byte[] { 0x21 }, 0, 1, "!" }; yield return new object[] { new byte[] { 0x2B, 0x21, 0x2D }, 0, 3, "!-" }; yield return new object[] { new byte[] { 0x2B, 0x21, 0x41, 0x41, 0x2D }, 0, 5, "!AA-" }; yield return new object[] { new byte[] { 0x2B, 0x80, 0x81, 0x82, 0x2D }, 0, 5, "\u0080\u0081\u0082-" }; yield return new object[] { new byte[] { 0x2B, 0x80, 0x81, 0x82, 0x2D }, 0, 4, "\u0080\u0081\u0082" }; yield return new object[] { new byte[] { 0x80, 0x81 }, 0, 2, "\u0080\u0081" }; yield return new object[] { new byte[] { 0x2B, 0x80, 0x21, 0x80, 0x21, 0x1E, 0x2D }, 0, 7, "\u0080!\u0080!\u001E-" }; // Exclamation mark yield return new object[] { new byte[] { 0x2B, 0x41, 0x43, 0x45, 0x41, 0x66, 0x51 }, 0, 7, "!}" }; yield return new object[] { new byte[] { 0x2B, 0x41, 0x43, 0x45, 0x41, 0x66, 0x51, 0x2D }, 0, 8, "!}" }; yield return new object[] { new byte[] { 0x21, 0x7D }, 0, 2, "!}" }; yield return new object[] { new byte[] { 0x2B, 0x41, 0x43, 0x45, 0x41, 0x66, 0x51, 0x2D }, 1, 2, "AC" }; yield return new object[] { new byte[] { 0x2B, 0x41, 0x43, 0x45, 0x2D }, 0, 5, "!" }; yield return new object[] { new byte[] { 0x2B, 0x41, 0x43, 0x45, 0x2D }, 0, 2, string.Empty }; yield return new object[] { new byte[] { 0x2B, 0x41, 0x43, 0x45, 0x2D }, 0, 3, string.Empty }; yield return new object[] { new byte[] { 0x2B, 0x41, 0x43, 0x48, 0x2D }, 0, 5, "!" }; // Unicode yield return new object[] { new byte[] { 0x2B, 0x44, 0x6C, 0x6B, 0x46, 0x30, 0x51, 0x2D }, 0, 8, "\u0E59\u05D1" }; yield return new object[] { new byte[] { 0x2B, 0x44, 0x6C, 0x6B, 0x46, 0x30, 0x51 }, 0, 7, "\u0E59\u05D1" }; yield return new object[] { new byte[] { 0x41, 0x2B, 0x41, 0x43, 0x45, 0x41, 0x66, 0x51, 0x2D, 0x09, 0x2B, 0x44, 0x6C, 0x6B, 0x46, 0x30, 0x51 }, 0, 17, "\u0041\u0021\u007D\u0009\u0E59\u05D1" }; yield return new object[] { new byte[] { 0x41, 0x2B, 0x41, 0x43, 0x45, 0x41, 0x66, 0x51, 0x2D, 0x09, 0x2B, 0x44, 0x6C, 0x6B, 0x46, 0x30, 0x51, 0x2D }, 0, 18, "\u0041\u0021\u007D\u0009\u0E59\u05D1" }; yield return new object[] { new byte[] { 0x41, 0x21, 0x7D, 0x09, 0x2B, 0x44, 0x6C, 0x6B, 0x46, 0x30, 0x51, 0x2D }, 0, 12, "\u0041\u0021\u007D\u0009\u0E59\u05D1" }; yield return new object[] { new byte[] { 0x41, 0x21, 0x7D, 0x09, 0x2B, 0x44, 0x6C, 0x6B, 0x46, 0x30, 0x51 }, 0, 11, "\u0041\u0021\u007D\u0009\u0E59\u05D1" }; yield return new object[] { new byte[] { 0x2B, 0x2B, 0x41, 0x41, 0x2D }, 0, 5, "\uF800" }; yield return new object[] { new byte[] { 0x2B, 0x41, 0x43, 0x48, 0x35, 0x41, 0x41, 0x2D }, 0, 8, "\u0021\uF900" }; yield return new object[] { new byte[] { 0x2B, 0x41, 0x43, 0x48, 0x35, 0x41, 0x41, 0x2D }, 0, 4, "!" }; // Surrogate pairs yield return new object[] { new byte[] { 0x2B, 0x32, 0x41, 0x44, 0x66, 0x2F, 0x77, 0x2D }, 0, 8, "\uD800\uDFFF" }; // Invalid Unicode yield return new object[] { new byte[] { 43, 50, 65, 65, 45 }, 0, 5, "\uD800" }; // Lone high surrogate yield return new object[] { new byte[] { 43, 51, 65, 65, 45 }, 0, 5, "\uDC00" }; // Lone low surrogate yield return new object[] { new byte[] { 0x2B, 0x33, 0x2F, 0x38, 0x2D }, 0, 5, "\uDFFF" }; // Lone low surrogate yield return new object[] { new byte[] { 43, 50, 65, 68, 89, 65, 65, 45 }, 0, 8, "\uD800\uD800" }; // High, high yield return new object[] { new byte[] { 43, 51, 65, 68, 89, 65, 65, 45 }, 0, 8, "\uDC00\uD800" }; // Low, high yield return new object[] { new byte[] { 43, 51, 65, 68, 99, 65, 65, 45 }, 0, 8, "\uDC00\uDC00" }; // Low, low // High BMP non-chars yield return new object[] { new byte[] { 43, 47, 47, 48, 45 }, 0, 5, "\uFFFD" }; yield return new object[] { new byte[] { 43, 47, 47, 52, 45 }, 0, 5, "\uFFFE" }; yield return new object[] { new byte[] { 43, 47, 47, 56, 45 }, 0, 5, "\uFFFF" }; // Empty strings yield return new object[] { new byte[0], 0, 0, string.Empty }; yield return new object[] { new byte[10], 0, 0, string.Empty }; yield return new object[] { new byte[10], 10, 0, string.Empty }; } [Theory] [MemberData(nameof(Decode_TestData))] public void Decode(byte[] bytes, int index, int count, string expected) { EncodingHelpers.Decode(new UTF7Encoding(true), bytes, index, count, expected); EncodingHelpers.Decode(new UTF7Encoding(false), bytes, index, count, expected); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using Xunit; namespace System.Text.Tests { public class UTF7EncodingDecode { public static IEnumerable<object[]> Decode_TestData() { // All ASCII chars for (int i = 0; i <= byte.MaxValue; i++) { char c = (char)i; if (c == 43) { continue; } yield return new object[] { new byte[] { (byte)c }, 0, 1, c.ToString() }; yield return new object[] { new byte[] { 97, (byte)c, 98 }, 1, 1, c.ToString() }; yield return new object[] { new byte[] { 97, (byte)c, 98 }, 2, 1, "b" }; yield return new object[] { new byte[] { 97, (byte)c, 98 }, 0, 3, "a" + c.ToString() + "b" }; } // Plus yield return new object[] { new byte[] { (byte)'+' }, 0, 1, string.Empty }; yield return new object[] { new byte[] { 43, 45 }, 0, 2, "+" }; yield return new object[] { new byte[] { 43, 45, 65 }, 0, 3, "+A" }; yield return new object[] { new byte[] { 0x2B, 0x2D, 0x2D }, 0, 3,"+-" }; // UTF7 code points can be represented in different sequences of bytes yield return new object[] { new byte[] { 0x41, 0x09, 0x0D, 0x0A, 0x20, 0x2F, 0x7A }, 0, 7, "A\t\r\n /z" }; yield return new object[] { new byte[] { 0x2B, 0x41, 0x45, 0x45, 0x41, 0x43, 0x51 }, 0, 7, "A\t" }; yield return new object[] { new byte[] { 0x2B, 0x09 }, 0, 2, "\t" }; yield return new object[] { new byte[] { 0x2B, 0x09, 0x2D }, 0, 3, "\t-" }; yield return new object[] { new byte[] { 0x2B, 0x1E, 0x2D }, 0, 3, "\u001E-" }; yield return new object[] { new byte[] { 0x2B, 0x7F, 0x1E, 0x2D }, 0, 4, "\u007F\u001E-" }; yield return new object[] { new byte[] { 0x1E }, 0, 1, "\u001e" }; yield return new object[] { new byte[] { 0x21 }, 0, 1, "!" }; yield return new object[] { new byte[] { 0x2B, 0x21, 0x2D }, 0, 3, "!-" }; yield return new object[] { new byte[] { 0x2B, 0x21, 0x41, 0x41, 0x2D }, 0, 5, "!AA-" }; yield return new object[] { new byte[] { 0x2B, 0x80, 0x81, 0x82, 0x2D }, 0, 5, "\u0080\u0081\u0082-" }; yield return new object[] { new byte[] { 0x2B, 0x80, 0x81, 0x82, 0x2D }, 0, 4, "\u0080\u0081\u0082" }; yield return new object[] { new byte[] { 0x80, 0x81 }, 0, 2, "\u0080\u0081" }; yield return new object[] { new byte[] { 0x2B, 0x80, 0x21, 0x80, 0x21, 0x1E, 0x2D }, 0, 7, "\u0080!\u0080!\u001E-" }; // Exclamation mark yield return new object[] { new byte[] { 0x2B, 0x41, 0x43, 0x45, 0x41, 0x66, 0x51 }, 0, 7, "!}" }; yield return new object[] { new byte[] { 0x2B, 0x41, 0x43, 0x45, 0x41, 0x66, 0x51, 0x2D }, 0, 8, "!}" }; yield return new object[] { new byte[] { 0x21, 0x7D }, 0, 2, "!}" }; yield return new object[] { new byte[] { 0x2B, 0x41, 0x43, 0x45, 0x41, 0x66, 0x51, 0x2D }, 1, 2, "AC" }; yield return new object[] { new byte[] { 0x2B, 0x41, 0x43, 0x45, 0x2D }, 0, 5, "!" }; yield return new object[] { new byte[] { 0x2B, 0x41, 0x43, 0x45, 0x2D }, 0, 2, string.Empty }; yield return new object[] { new byte[] { 0x2B, 0x41, 0x43, 0x45, 0x2D }, 0, 3, string.Empty }; yield return new object[] { new byte[] { 0x2B, 0x41, 0x43, 0x48, 0x2D }, 0, 5, "!" }; // Unicode yield return new object[] { new byte[] { 0x2B, 0x44, 0x6C, 0x6B, 0x46, 0x30, 0x51, 0x2D }, 0, 8, "\u0E59\u05D1" }; yield return new object[] { new byte[] { 0x2B, 0x44, 0x6C, 0x6B, 0x46, 0x30, 0x51 }, 0, 7, "\u0E59\u05D1" }; yield return new object[] { new byte[] { 0x41, 0x2B, 0x41, 0x43, 0x45, 0x41, 0x66, 0x51, 0x2D, 0x09, 0x2B, 0x44, 0x6C, 0x6B, 0x46, 0x30, 0x51 }, 0, 17, "\u0041\u0021\u007D\u0009\u0E59\u05D1" }; yield return new object[] { new byte[] { 0x41, 0x2B, 0x41, 0x43, 0x45, 0x41, 0x66, 0x51, 0x2D, 0x09, 0x2B, 0x44, 0x6C, 0x6B, 0x46, 0x30, 0x51, 0x2D }, 0, 18, "\u0041\u0021\u007D\u0009\u0E59\u05D1" }; yield return new object[] { new byte[] { 0x41, 0x21, 0x7D, 0x09, 0x2B, 0x44, 0x6C, 0x6B, 0x46, 0x30, 0x51, 0x2D }, 0, 12, "\u0041\u0021\u007D\u0009\u0E59\u05D1" }; yield return new object[] { new byte[] { 0x41, 0x21, 0x7D, 0x09, 0x2B, 0x44, 0x6C, 0x6B, 0x46, 0x30, 0x51 }, 0, 11, "\u0041\u0021\u007D\u0009\u0E59\u05D1" }; yield return new object[] { new byte[] { 0x2B, 0x2B, 0x41, 0x41, 0x2D }, 0, 5, "\uF800" }; yield return new object[] { new byte[] { 0x2B, 0x41, 0x43, 0x48, 0x35, 0x41, 0x41, 0x2D }, 0, 8, "\u0021\uF900" }; yield return new object[] { new byte[] { 0x2B, 0x41, 0x43, 0x48, 0x35, 0x41, 0x41, 0x2D }, 0, 4, "!" }; // Surrogate pairs yield return new object[] { new byte[] { 0x2B, 0x32, 0x41, 0x44, 0x66, 0x2F, 0x77, 0x2D }, 0, 8, "\uD800\uDFFF" }; // Invalid Unicode yield return new object[] { new byte[] { 43, 50, 65, 65, 45 }, 0, 5, "\uD800" }; // Lone high surrogate yield return new object[] { new byte[] { 43, 51, 65, 65, 45 }, 0, 5, "\uDC00" }; // Lone low surrogate yield return new object[] { new byte[] { 0x2B, 0x33, 0x2F, 0x38, 0x2D }, 0, 5, "\uDFFF" }; // Lone low surrogate yield return new object[] { new byte[] { 43, 50, 65, 68, 89, 65, 65, 45 }, 0, 8, "\uD800\uD800" }; // High, high yield return new object[] { new byte[] { 43, 51, 65, 68, 89, 65, 65, 45 }, 0, 8, "\uDC00\uD800" }; // Low, high yield return new object[] { new byte[] { 43, 51, 65, 68, 99, 65, 65, 45 }, 0, 8, "\uDC00\uDC00" }; // Low, low // High BMP non-chars yield return new object[] { new byte[] { 43, 47, 47, 48, 45 }, 0, 5, "\uFFFD" }; yield return new object[] { new byte[] { 43, 47, 47, 52, 45 }, 0, 5, "\uFFFE" }; yield return new object[] { new byte[] { 43, 47, 47, 56, 45 }, 0, 5, "\uFFFF" }; // Empty strings yield return new object[] { new byte[0], 0, 0, string.Empty }; yield return new object[] { new byte[10], 0, 0, string.Empty }; yield return new object[] { new byte[10], 10, 0, string.Empty }; } [Theory] [MemberData(nameof(Decode_TestData))] public void Decode(byte[] bytes, int index, int count, string expected) { EncodingHelpers.Decode(new UTF7Encoding(true), bytes, index, count, expected); EncodingHelpers.Decode(new UTF7Encoding(false), bytes, index, count, expected); } } }
-1