Skip to content

Commit

Permalink
Cleanup ProjectN references (#68201)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotas committed Apr 19, 2022
1 parent 9924f09 commit 400d171
Show file tree
Hide file tree
Showing 42 changed files with 65 additions and 212 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private static IntPtr RhpResolveInterfaceMethod(object pObject, IntPtr pCell)
{
if (pObject == null)
{
// ProjectN Optimizer may perform code motion on dispatch such that it occurs independant of
// Optimizer may perform code motion on dispatch such that it occurs independant of
// null check on "this" pointer. Allow for this case by returning back an invalid pointer.
return IntPtr.Zero;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ public enum RhFailFastReason
UnhandledException_ExceptionDispatchNotAllowed = 2, // "Unhandled exception: no handler found before escaping a finally clause or other fail-fast scope."
UnhandledException_CallerDidNotHandle = 3, // "Unhandled exception: no handler found in calling method."
ClassLibDidNotTranslateExceptionID = 4, // "Unable to translate failure into a classlib-specific exception object."

PN_UnhandledException = 5, // ProjectN: "unhandled exception"
PN_UnhandledExceptionFromPInvoke = 6, // ProjectN: "Unhandled exception: an unmanaged exception was thrown out of a managed-to-native transition."
Max
UnhandledException = 5, // "unhandled exception"
UnhandledExceptionFromPInvoke = 6, // "Unhandled exception: an unmanaged exception was thrown out of a managed-to-native transition."
}

internal static unsafe partial class EH
Expand Down Expand Up @@ -648,7 +646,7 @@ private static void DispatchEx(ref StackFrameIterator frameIter, ref ExInfo exIn
OnUnhandledExceptionViaClassLib(exceptionObj);

UnhandledExceptionFailFastViaClasslib(
RhFailFastReason.PN_UnhandledException,
RhFailFastReason.UnhandledException,
exceptionObj,
(IntPtr)prevOriginalPC, // IP of the last frame that did not handle the exception
ref exInfo);
Expand Down Expand Up @@ -926,12 +924,12 @@ private static void InvokeSecondPass(ref ExInfo exInfo, uint idxStart, uint idxL
[UnmanagedCallersOnly(EntryPoint = "RhpFailFastForPInvokeExceptionPreemp", CallConvs = new Type[] { typeof(CallConvCdecl) })]
public static void RhpFailFastForPInvokeExceptionPreemp(IntPtr PInvokeCallsiteReturnAddr, void* pExceptionRecord, void* pContextRecord)
{
FailFastViaClasslib(RhFailFastReason.PN_UnhandledExceptionFromPInvoke, null, PInvokeCallsiteReturnAddr);
FailFastViaClasslib(RhFailFastReason.UnhandledExceptionFromPInvoke, null, PInvokeCallsiteReturnAddr);
}
[RuntimeExport("RhpFailFastForPInvokeExceptionCoop")]
public static void RhpFailFastForPInvokeExceptionCoop(IntPtr classlibBreadcrumb, void* pExceptionRecord, void* pContextRecord)
{
FailFastViaClasslib(RhFailFastReason.PN_UnhandledExceptionFromPInvoke, null, classlibBreadcrumb);
FailFastViaClasslib(RhFailFastReason.UnhandledExceptionFromPInvoke, null, classlibBreadcrumb);
}
} // static class EH
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
//
// With FEATURE_RX_THUNKS, thunks are created by allocating new virtual memory space, where the first half of
// that space is filled with thunk stubs, and gets RX permissions, and the second half is for the thunks data,
// and gets RW permissions. The thunk stubs and data blocks are not in groupped in pairs like in ProjectN: all
// the thunk stubs blocks are groupped at the begining of the allocated virtual memory space, and all the
// and gets RW permissions. The thunk stubs and data blocks are not in groupped in pairs:
// all the thunk stubs blocks are groupped at the begining of the allocated virtual memory space, and all the
// thunk data blocks are groupped in the second half of the virtual space.
//
// Available thunks are tracked using a linked list. The first cell in the data block of each thunk is
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/nativeaot/Runtime/eventtracepriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ class BulkTypeValue
// This is really a denorm of the size already stored in rgTypeParameters, but we
// need a persistent place to stash this away so EventDataDescCreate & EventWrite
// have a reliable place to copy it from. This is filled in at the last minute,
// when sending the event. (On ProjectN, which doesn't have StackSArray, this is
// filled in earlier and used in more places.)
// when sending the event.
ULONG cTypeParameters;

#ifdef FEATURE_REDHAWK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ internal static ReflectionCoreCallbacks ReflectionCoreCallbacks

//
// This class is implemented by Internal.Reflection.Core.dll and provides the actual implementation
// of Type.GetTypeInfo() and (on Project N) (Assembly.Load()).
// of Type.GetTypeInfo() and Assembly.Load().
//
[System.Runtime.CompilerServices.ReflectionBlocked]
public abstract class ReflectionCoreCallbacks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public IEnumerable<CustomAttributeData> GetMatchingCustomAttributes(E element, T
//
// Since "typeFilterKnownToBeSealed" is only used to enable an optimization, it's always safe to leave it "false".
//
// Because the Project N toolchain removes any custom attribute that refuses to opt into metadata so at this point,
// Because the NativeAOT toolchain removes any custom attribute that refuses to opt into metadata so at this point,
// we could simply return an empty enumeration and "be correct." However, the code paths following this already do that naturally.
// (i.e. the "passFilter" will never return true, thus we will never attempt to query the custom attribute type for its
// own AttributeUsage custom attribute.) If the toolchain behavior changes in the future, it's preferable that
Expand Down Expand Up @@ -191,8 +191,6 @@ private static AttributeUsageAttribute GetAttributeUsage(Type attributeType)
//
// Legacy: Why aren't we checking the parent types? Answer: Although AttributeUsageAttribute is itself marked inheritable, desktop Reflection
// treats it as *non*-inheritable for the purpose of deciding whether another attribute class is inheritable.
// This behavior goes all the way back to at least 3.5 (and perhaps earlier). For compat reasons,
// we won't-fixed this in 4.5 and we won't-fix this in Project N.
//
AttributeUsageAttribute? usage = attributeType.GetCustomAttribute<AttributeUsageAttribute>(inherit: false);
if (usage == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ private static void ValidateElementType(Type elementType)

public void Initialize()
{
// Project N port note: On the desktop, this api is a nop unless the array element type is a value type with
// an explicit nullary constructor. Such a type cannot be expressed in C# so Project N does not support this.
// The ILC toolchain fails the build if it encounters such a type.
// This api is a nop unless the array element type is a value type with an explicit nullary constructor.
// Such a type could not be expressed in C# up until recently.
// TODO: Implement this
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,8 @@ protected Delegate([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Al
// If the thunk does not exist, the function will return IntPtr.Zero.
private protected virtual IntPtr GetThunk(int whichThunk)
{
#if PROJECTN
// The GetThunk function should be overriden on all delegate types, except for universal
// canonical delegates which use calling convention converter thunks to marshal arguments
// for the delegate call. If we execute this version of GetThunk, we can at least assert
// that the current delegate type is a generic type.
Debug.Assert(this.EETypePtr.IsGeneric);
return TypeLoaderExports.GetDelegateThunk(this, whichThunk);
#else
// CoreRT doesn't support Universal Shared Code right now, so let's make this method return null for now.
// When CoreRT adds USG support we'll probably want to do some level of IL switching here so that
// we don't have this static call into type loader when USG is not enabled at compile time.
// The static call hurts size in our minimal targets.
// NativeAOT doesn't support Universal Shared Code, so let's make this method return null.
return IntPtr.Zero;
#endif
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,8 @@ public enum RhFailFastReason
UnhandledException_ExceptionDispatchNotAllowed = 2, // "Unhandled exception: no handler found before escaping a finally clause or other fail-fast scope."
UnhandledException_CallerDidNotHandle = 3, // "Unhandled exception: no handler found in calling method."
ClassLibDidNotTranslateExceptionID = 4, // "Unable to translate failure into a classlib-specific exception object."
PN_UnhandledException = 5, // ProjectN: "Unhandled exception: a managed exception was not handled before reaching unmanaged code"
PN_UnhandledExceptionFromPInvoke = 6, // ProjectN: "Unhandled exception: an unmanaged exception was thrown out of a managed-to-native transition."
Max
UnhandledException = 5, // "Unhandled exception: a managed exception was not handled before reaching unmanaged code"
UnhandledExceptionFromPInvoke = 6, // "Unhandled exception: an unmanaged exception was thrown out of a managed-to-native transition."
}

private static string GetStringForFailFastReason(RhFailFastReason reason)
Expand All @@ -142,9 +141,9 @@ private static string GetStringForFailFastReason(RhFailFastReason reason)
return "Unhandled exception: no handler found in calling method.";
case RhFailFastReason.ClassLibDidNotTranslateExceptionID:
return "Unable to translate failure into a classlib-specific exception object.";
case RhFailFastReason.PN_UnhandledException:
case RhFailFastReason.UnhandledException:
return "Unhandled exception: a managed exception was not handled before reaching unmanaged code.";
case RhFailFastReason.PN_UnhandledExceptionFromPInvoke:
case RhFailFastReason.UnhandledExceptionFromPInvoke:
return "Unhandled exception: an unmanaged exception was thrown out of a managed-to-native transition.";
default:
return "Unknown reason.";
Expand Down Expand Up @@ -179,9 +178,9 @@ public static void ReportUnhandledException(Exception exception)
// If possible report the exception to GEH, if not fail fast.
WinRTInteropCallbacks callbacks = WinRTInterop.UnsafeCallbacks;
if (callbacks == null || !callbacks.ReportUnhandledError(exception))
FailFast(GetStringForFailFastReason(RhFailFastReason.PN_UnhandledException), exception);
FailFast(GetStringForFailFastReason(RhFailFastReason.UnhandledException), exception);
#else
FailFast(GetStringForFailFastReason(RhFailFastReason.PN_UnhandledException), exception);
FailFast(GetStringForFailFastReason(RhFailFastReason.UnhandledException), exception);
#endif
}

Expand All @@ -206,7 +205,7 @@ public static void RuntimeFailFast(RhFailFastReason reason, Exception? exception

if (!minimalFailFast)
{
if ((reason == RhFailFastReason.PN_UnhandledException) && (exception != null))
if ((reason == RhFailFastReason.UnhandledException) && (exception != null))
{
Debug.WriteLine("Unhandled Exception: " + exception.ToString());
}
Expand Down Expand Up @@ -267,7 +266,7 @@ internal static void FailFast(string message, Exception? exception, RhFailFastRe
// * RhFailFastReason, if it is one of the known reasons
if (exception != null)
{
if (reason == RhFailFastReason.PN_UnhandledException)
if (reason == RhFailFastReason.UnhandledException)
errorCode = (uint)(exception.GetEETypePtr().GetHashCode());
else if (exception.HResult != 0)
errorCode = (uint)exception.HResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ protected override bool IsByRefImpl()
return RuntimeAugments.IsByRefType(_typeHandle);
}

protected override bool IsCOMObjectImpl() => throw new NotSupportedException(SR.Reflection_Disabled);
protected override bool IsCOMObjectImpl()
{
return false;
}

protected override bool IsPointerImpl()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public abstract class ExecutionEnvironment
//==============================================================================================
// Other
//==============================================================================================
public abstract bool IsCOMObject(Type type);
public abstract FieldAccessor CreateLiteralFieldAccessor(object value, RuntimeTypeHandle fieldTypeHandle);
public abstract EnumInfo GetEnumInfo(RuntimeTypeHandle typeHandle);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,7 @@ public sealed override bool Equals(object obj)

public sealed override object Invoke(BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
{
#if PROJECTN
if (parameters != null && parameters.Length != 0)
throw new TargetParameterCountException();

Guid clsid = _declaringType.GUID;
string server = _declaringType.Server;
IntPtr pItf = IntPtr.Zero;
try
{
pItf = McgMarshal.CoCreateInstanceEx(clsid, server);

// CoCreateInstanceEx will throw exception if it fails to
// create an instance.
Debug.Assert(pItf != IntPtr.Zero);

return Marshal.GetObjectForIUnknown(pItf);
}
finally
{
if (pItf != IntPtr.Zero)
Marshal.Release(pItf);
}
#else
throw new PlatformNotSupportedException();
#endif
}

public sealed override MethodBase MetadataDefinitionMethod { get { throw new NotSupportedException(); } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace System.Reflection.Runtime.Modules
//
// The runtime's implementation of a Module.
//
// Modules are quite meaningless in ProjectN but we have to keep up the appearances since they still exist in Win8P's surface area.
// As far as ProjectN is concerned, each Assembly has one module.
// Modules are quite meaningless in .NET Core but we have to keep up the appearances since they still exist in surface area.
// Each Assembly has one (manifest) module.
//
internal abstract partial class RuntimeModule : Module
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ protected sealed override TypeCode GetTypeCodeImpl()

protected sealed override bool IsCOMObjectImpl()
{
return ReflectionCoreExecution.ExecutionEnvironment.IsCOMObject(this);
return false;
}

protected sealed override bool IsPrimitiveImpl()
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public unsafe sealed override bool TryGetTypeReferenceForNamedType(RuntimeTypeHa
/// metadataReader + typeRefHandle - a valid metadata reader + typeReferenceHandle where "metadataReader" is one
/// of the metadata readers returned by ExecutionEnvironment.MetadataReaders.
///
/// Note: Although this method has a "bool" return value like the other mapping table accessors, the Project N pay-for-play design
/// Note: Although this method has a "bool" return value like the other mapping table accessors, the pay-for-play design
/// guarantees that any type that has a metadata TypeReference to it also has a RuntimeTypeHandle underneath.
/// </summary>
/// <param name="metadataReader">Metadata reader for module containing the type reference</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Internal.Reflection.Execution
{
//=========================================================================================================================
// The setup information for the reflection domain used for Project N's "classic reflection".
// The setup information for the reflection domain used for "classic reflection".
//=========================================================================================================================
internal sealed class ReflectionDomainSetupImplementation : ReflectionDomainSetup
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<Compile Include="Internal\Reflection\Execution\ReflectionExecution.cs" />
<Compile Include="Internal\Reflection\Execution\ReflectionDomainSetupImplementation.cs" />
<Compile Include="Internal\Reflection\Execution\ExecutionEnvironmentImplementation.cs" />
<Compile Include="Internal\Reflection\Execution\ExecutionEnvironmentImplementation.Interop.cs" />
<Compile Include="Internal\Reflection\Execution\ExecutionEnvironmentImplementation.Runtime.cs" />
<Compile Include="Internal\Reflection\Execution\ExecutionEnvironmentImplementation.MappingTables.cs" />
<Compile Include="Internal\Reflection\Execution\ExecutionEnvironmentImplementation.MetadataTable.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
namespace Internal.Reflection.Execution
{
//=============================================================================================================================
// The assembly resolution policy for Project N's emulation of "classic reflection."
// The assembly resolution policy for emulation of "classic reflection."
//
// The policy is very simple: the only assemblies that can be "loaded" are those that are statically linked into the running
// native process. There is no support for probing for assemblies in directories, user-supplied files, GACs, NICs or any
Expand Down
Loading

0 comments on commit 400d171

Please sign in to comment.