Skip to content

Commit

Permalink
Delete RuntimeTypeHandle.GetValueInternal (#577)
Browse files Browse the repository at this point in the history
GetValueInternal may or may not go away from RyuJIT at some point.

We originally used this to implement EETypePtrOf, but the IL-based implementation had problems with generic inlining so we replaced it in dotnet/corert#3814.

The fallback IL was probably still used for CppCodegen at that time so it wasn't deleted.
  • Loading branch information
MichalStrehovsky committed Jan 22, 2021
1 parent d002b8f commit 4fe82ad
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,5 @@ public class Type
public struct RuntimeTypeHandle
{
private EETypePtr _pEEType;

[Intrinsic]
internal static unsafe IntPtr GetValueInternal(RuntimeTypeHandle handle)
{
return (IntPtr)handle._pEEType.ToPointer();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,7 @@ internal ref T GetWritableData<T>() where T : unmanaged
internal static EETypePtr EETypePtrOf<T>()
{
// Compilers are required to provide a low level implementation of this method.
// This can be achieved by optimizing away the reflection part of this implementation
// by optimizing typeof(!!0).TypeHandle into "ldtoken !!0", or by
// completely replacing the body of this method.
return typeof(T).TypeHandle.ToEETypePtr();
throw new NotImplementedException();
}

public struct InterfaceCollection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,6 @@ internal string LastResortToString
}
}

[Intrinsic]
internal static IntPtr GetValueInternal(RuntimeTypeHandle handle)
{
return handle.RawValue;
}

internal IntPtr RawValue
{
get
Expand Down
6 changes: 0 additions & 6 deletions src/coreclr/tools/Common/TypeSystem/IL/CoreRTILProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ private MethodIL TryGetIntrinsicMethodIL(MethodDesc method)
return new ILStubMethodIL(method, new byte[] { (byte)ILOpcode.break_, (byte)ILOpcode.ret }, Array.Empty<LocalVariableDefinition>(), null);
}
break;
case "EETypePtr":
{
if (owningType.Namespace == "System" && method.Name == "EETypePtrOf")
return EETypePtrOfIntrinsic.EmitIL(method);
}
break;
case "RuntimeAugments":
{
if (owningType.Namespace == "Internal.Runtime.Augments" && method.Name == "GetCanonType")
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,6 @@ private void ImportCall(ILOpcode opcode, int token)
return;
}

if (IsRuntimeTypeHandleGetValueInternal(method))
{
if (_previousInstructionOffset >= 0 && _ilBytes[_previousInstructionOffset] == (byte)ILOpcode.ldtoken)
return;
}

if (IsActivatorDefaultConstructorOf(method))
{
if (runtimeDeterminedMethod.IsRuntimeDeterminedExactMethod)
Expand Down Expand Up @@ -804,7 +798,6 @@ private void ImportLdToken(int token)
}
_dependencies.Add(reference, "ldtoken");

// If this is a ldtoken Type / GetValueInternal sequence, we're done.
// If this is a ldtoken Type / Type.GetTypeFromHandle sequence, we need one more helper.
BasicBlock nextBasicBlock = _basicBlocks[_currentOffset];
if (nextBasicBlock == null)
Expand All @@ -813,12 +806,7 @@ private void ImportLdToken(int token)
{
int methodToken = ReadILTokenAt(_currentOffset + 1);
var method = (MethodDesc)_methodIL.GetObject(methodToken);
if (IsRuntimeTypeHandleGetValueInternal(method))
{
// Codegen expands this and doesn't do the normal ldtoken.
return;
}
else if (IsTypeGetTypeFromHandle(method))
if (IsTypeGetTypeFromHandle(method))
{
// Codegen will swap this one for GetRuntimeTypeHandle when optimizing
_dependencies.Add(GetHelperEntrypoint(ReadyToRunHelper.GetRuntimeType), "ldtoken");
Expand Down Expand Up @@ -1115,20 +1103,6 @@ private bool IsRuntimeHelpersInitializeArray(MethodDesc method)
return false;
}

private bool IsRuntimeTypeHandleGetValueInternal(MethodDesc method)
{
if (method.IsIntrinsic && method.Name == "GetValueInternal")
{
MetadataType owningType = method.OwningType as MetadataType;
if (owningType != null)
{
return owningType.Name == "RuntimeTypeHandle" && owningType.Namespace == "System";
}
}

return false;
}

private bool IsTypeGetTypeFromHandle(MethodDesc method)
{
if (method.IsIntrinsic && method.Name == "GetTypeFromHandle")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@
<Compile Include="..\..\Common\TypeSystem\IL\Stubs\DelegateMethodILEmitter.cs">
<Link>IL\Stubs\DelegateMethodILEmitter.cs</Link>
</Compile>
<Compile Include="..\..\Common\TypeSystem\IL\Stubs\EETypePtrOfIntrinsic.cs">
<Link>IL\Stubs\EETypePtrOfIntrinsic.cs</Link>
</Compile>
<Compile Include="..\..\Common\TypeSystem\IL\Stubs\MethodBaseGetCurrentMethodThunk.Sorting.cs">
<Link>IL\Stubs\MethodBaseGetCurrentMethodThunk.Sorting.cs</Link>
</Compile>
Expand Down

0 comments on commit 4fe82ad

Please sign in to comment.