本文整理汇总了C#中Internal.JitInterface.CORINFO_RESOLVED_TOKEN类的典型用法代码示例。如果您正苦于以下问题:C# CORINFO_RESOLVED_TOKEN类的具体用法?C# CORINFO_RESOLVED_TOKEN怎么用?C# CORINFO_RESOLVED_TOKEN使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CORINFO_RESOLVED_TOKEN类属于Internal.JitInterface命名空间,在下文中一共展示了CORINFO_RESOLVED_TOKEN类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getCallInfo
private void getCallInfo(ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, CORINFO_CALLINFO_FLAGS flags, ref CORINFO_CALL_INFO pResult)
{
#if DEBUG
// In debug, write some bogus data to the struct to ensure we have filled everything
// properly.
fixed (CORINFO_CALL_INFO* tmp = &pResult)
MemoryHelper.FillMemory((byte*)tmp, 0xcc, Marshal.SizeOf<CORINFO_CALL_INFO>());
#endif
MethodDesc method = HandleToObject(pResolvedToken.hMethod);
// Spec says that a callvirt lookup ignores static methods. Since static methods
// can't have the exact same signature as instance methods, a lookup that found
// a static method would have never found an instance method.
if (method.Signature.IsStatic && (flags & CORINFO_CALLINFO_FLAGS.CORINFO_CALLINFO_CALLVIRT) != 0)
{
throw new BadImageFormatException();
}
TypeDesc exactType = HandleToObject(pResolvedToken.hClass);
TypeDesc constrainedType = null;
if ((flags & CORINFO_CALLINFO_FLAGS.CORINFO_CALLINFO_CALLVIRT) != 0 && pConstrainedResolvedToken != null)
{
constrainedType = HandleToObject(pConstrainedResolvedToken->hClass);
}
bool resolvedConstraint = false;
bool forceUseRuntimeLookup = false;
MethodDesc methodAfterConstraintResolution = method;
if (constrainedType == null)
{
pResult.thisTransform = CORINFO_THIS_TRANSFORM.CORINFO_NO_THIS_TRANSFORM;
}
else
{
// We have a "constrained." call. Try a partial resolve of the constraint call. Note that this
// will not necessarily resolve the call exactly, since we might be compiling
// shared generic code - it may just resolve it to a candidate suitable for
// JIT compilation, and require a runtime lookup for the actual code pointer
// to call.
MethodDesc directMethod = constrainedType.GetClosestDefType().TryResolveConstraintMethodApprox(exactType, method, out forceUseRuntimeLookup);
if (directMethod != null)
{
// Either
// 1. no constraint resolution at compile time (!directMethod)
// OR 2. no code sharing lookup in call
// OR 3. we have have resolved to an instantiating stub
methodAfterConstraintResolution = directMethod;
Debug.Assert(!methodAfterConstraintResolution.OwningType.IsInterface);
resolvedConstraint = true;
pResult.thisTransform = CORINFO_THIS_TRANSFORM.CORINFO_NO_THIS_TRANSFORM;
exactType = constrainedType;
}
else if (constrainedType.IsValueType)
{
pResult.thisTransform = CORINFO_THIS_TRANSFORM.CORINFO_BOX_THIS;
}
else
{
pResult.thisTransform = CORINFO_THIS_TRANSFORM.CORINFO_DEREF_THIS;
}
}
MethodDesc targetMethod = methodAfterConstraintResolution;
// TODO: Support Generics
if (targetMethod.HasInstantiation)
{
pResult.contextHandle = contextFromMethod(targetMethod);
}
else
{
pResult.contextHandle = contextFromType(targetMethod.OwningType);
}
pResult._exactContextNeedsRuntimeLookup = 0;
//
// Determine whether to perform direct call
//
bool directCall = false;
bool resolvedCallVirt = false;
if (targetMethod.Signature.IsStatic)
{
// Static methods are always direct calls
directCall = true;
}
else if (targetMethod.OwningType.IsInterface)
{
// Force all interface calls to be interpreted as if they are virtual.
directCall = false;
}
else if ((flags & CORINFO_CALLINFO_FLAGS.CORINFO_CALLINFO_CALLVIRT) == 0 || resolvedConstraint)
//.........这里部分代码省略.........
示例2: getTokenTypeAsHandle
private CORINFO_CLASS_STRUCT_* getTokenTypeAsHandle(IntPtr _this, ref CORINFO_RESOLVED_TOKEN pResolvedToken)
{
WellKnownType result = WellKnownType.RuntimeTypeHandle;
if (pResolvedToken.hMethod != null)
{
result = WellKnownType.RuntimeMethodHandle;
}
else
if (pResolvedToken.hField != null)
{
result = WellKnownType.RuntimeFieldHandle;
}
return ObjectToHandle(_compilation.TypeSystemContext.GetWellKnownType(result));
}
示例3: getCastingHelper
private CorInfoHelpFunc getCastingHelper(IntPtr _this, ref CORINFO_RESOLVED_TOKEN pResolvedToken, [MarshalAs(UnmanagedType.I1)]bool fThrowing)
{ throw new NotImplementedException("getCastingHelper"); }
示例4: getFieldInfo
private void getFieldInfo(IntPtr _this, ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, CORINFO_ACCESS_FLAGS flags, ref CORINFO_FIELD_INFO pResult)
{
#if DEBUG
// In debug, write some bogus data to the struct to ensure we have filled everything
// properly.
fixed (CORINFO_FIELD_INFO* tmp = &pResult)
MemoryHelper.FillMemory((byte*)tmp, 0xcc, Marshal.SizeOf<CORINFO_FIELD_INFO>());
#endif
Debug.Assert(((int)flags & ((int)CORINFO_ACCESS_FLAGS.CORINFO_ACCESS_GET |
(int)CORINFO_ACCESS_FLAGS.CORINFO_ACCESS_SET |
(int)CORINFO_ACCESS_FLAGS.CORINFO_ACCESS_ADDRESS |
(int)CORINFO_ACCESS_FLAGS.CORINFO_ACCESS_INIT_ARRAY)) != 0);
var field = HandleToObject(pResolvedToken.hField);
CORINFO_FIELD_ACCESSOR fieldAccessor;
CORINFO_FIELD_FLAGS fieldFlags = (CORINFO_FIELD_FLAGS)0;
if (field.IsStatic)
{
fieldFlags |= CORINFO_FIELD_FLAGS.CORINFO_FLG_FIELD_STATIC;
if (field.HasRva)
{
throw new NotSupportedException("getFieldInfo for RVA mapped field");
}
fieldAccessor = CORINFO_FIELD_ACCESSOR.CORINFO_FIELD_STATIC_SHARED_STATIC_HELPER;
pResult.helper = CorInfoHelpFunc.CORINFO_HELP_READYTORUN_STATIC_BASE;
ReadyToRunHelperId helperId;
if (field.IsThreadStatic)
{
helperId = ReadyToRunHelperId.GetThreadStaticBase;
}
else if (field.HasGCStaticBase)
{
helperId = ReadyToRunHelperId.GetGCStaticBase;
}
else
{
helperId = ReadyToRunHelperId.GetNonGCStaticBase;
}
pResult.fieldLookup.addr = (void*)ObjectToHandle(_compilation.NodeFactory.ReadyToRunHelper(helperId, field.OwningType));
pResult.fieldLookup.accessType = InfoAccessType.IAT_VALUE;
}
else
{
fieldAccessor = CORINFO_FIELD_ACCESSOR.CORINFO_FIELD_INSTANCE;
}
if (field.IsInitOnly)
fieldFlags |= CORINFO_FIELD_FLAGS.CORINFO_FLG_FIELD_FINAL;
pResult.fieldAccessor = fieldAccessor;
pResult.fieldFlags = fieldFlags;
pResult.fieldType = getFieldType(_this, pResolvedToken.hField, ref pResult.structType, pResolvedToken.hClass);
pResult.accessAllowed = CorInfoIsAccessAllowedResult.CORINFO_ACCESS_ALLOWED;
pResult.offset = (uint)field.Offset;
// TODO: We need to implement access checks for fields and methods. See JitInterface.cpp in mrtjit
// and STS::AccessCheck::CanAccess.
}
示例5: getCallInfo
private void getCallInfo(IntPtr _this, ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, CORINFO_CALLINFO_FLAGS flags, ref CORINFO_CALL_INFO pResult)
{
#if DEBUG
// In debug, write some bogus data to the struct to ensure we have filled everything
// properly.
fixed (CORINFO_CALL_INFO* tmp = &pResult)
MemoryHelper.FillMemory((byte*)tmp, 0xcc, Marshal.SizeOf<CORINFO_CALL_INFO>());
#endif
MethodDesc method = HandleToObject(pResolvedToken.hMethod);
// Spec says that a callvirt lookup ignores static methods. Since static methods
// can't have the exact same signature as instance methods, a lookup that found
// a static method would have never found an instance method.
if (method.Signature.IsStatic && (flags & CORINFO_CALLINFO_FLAGS.CORINFO_CALLINFO_CALLVIRT) != 0)
{
throw new BadImageFormatException();
}
TypeDesc exactType = HandleToObject(pResolvedToken.hClass);
TypeDesc constrainedType = null;
if ((flags & CORINFO_CALLINFO_FLAGS.CORINFO_CALLINFO_CALLVIRT) != 0 && pConstrainedResolvedToken != null)
{
constrainedType = HandleToObject(pConstrainedResolvedToken->hClass);
}
bool resolvedConstraint = false;
bool forceUseRuntimeLookup = false;
MethodDesc methodAfterConstraintResolution = method;
if (constrainedType == null)
{
pResult.thisTransform = CORINFO_THIS_TRANSFORM.CORINFO_NO_THIS_TRANSFORM;
}
else
{
// We have a "constrained." call. Try a partial resolve of the constraint call. Note that this
// will not necessarily resolve the call exactly, since we might be compiling
// shared generic code - it may just resolve it to a candidate suitable for
// JIT compilation, and require a runtime lookup for the actual code pointer
// to call.
MethodDesc directMethod = constrainedType.GetClosestMetadataType().TryResolveConstraintMethodApprox(exactType, method, out forceUseRuntimeLookup);
if (directMethod != null)
{
// Either
// 1. no constraint resolution at compile time (!directMethod)
// OR 2. no code sharing lookup in call
// OR 3. we have have resolved to an instantiating stub
methodAfterConstraintResolution = directMethod;
Debug.Assert(!methodAfterConstraintResolution.OwningType.IsInterface);
resolvedConstraint = true;
pResult.thisTransform = CORINFO_THIS_TRANSFORM.CORINFO_NO_THIS_TRANSFORM;
exactType = constrainedType;
}
else if (constrainedType.IsValueType)
{
pResult.thisTransform = CORINFO_THIS_TRANSFORM.CORINFO_BOX_THIS;
}
else
{
pResult.thisTransform = CORINFO_THIS_TRANSFORM.CORINFO_DEREF_THIS;
}
}
MethodDesc targetMethod = methodAfterConstraintResolution;
//
// Determine whether to perform direct call
//
bool directCall = false;
bool resolvedCallVirt = false;
if ((flags & CORINFO_CALLINFO_FLAGS.CORINFO_CALLINFO_LDFTN) != 0)
{
// Delegate targets are always treated as direct calls here. (It would be nice to clean it up...).
directCall = true;
}
else if (targetMethod.Signature.IsStatic)
{
// Static methods are always direct calls
directCall = true;
}
else if (targetMethod.OwningType.IsInterface)
{
// Force all interface calls to be interpreted as if they are virtual.
directCall = false;
}
else if ((flags & CORINFO_CALLINFO_FLAGS.CORINFO_CALLINFO_CALLVIRT) == 0 || resolvedConstraint)
{
directCall = true;
}
else
{
if (!targetMethod.IsVirtual || targetMethod.IsFinal || targetMethod.OwningType.GetClosestMetadataType().IsSealed)
{
//.........这里部分代码省略.........
示例6: GetRuntimeDeterminedObjectForToken
private object GetRuntimeDeterminedObjectForToken(ref CORINFO_RESOLVED_TOKEN pResolvedToken)
{
// Since RyuJIT operates on canonical types (as opposed to runtime determined ones), but the
// dependency analysis operates on runtime determined ones, we convert the resolved token
// to the runtime determined form (e.g. Foo<__Canon> becomes Foo<T__Canon>).
var methodIL = (MethodIL)HandleToObject((IntPtr)pResolvedToken.tokenScope);
if (methodIL.OwningMethod.IsSharedByGenericInstantiations)
{
MethodIL methodILUninstantiated = methodIL.GetMethodILDefinition();
MethodDesc sharedMethod = methodIL.OwningMethod.GetSharedRuntimeFormMethodTarget();
Instantiation typeInstantiation = sharedMethod.OwningType.Instantiation;
Instantiation methodInstantiation = sharedMethod.Instantiation;
object resultUninstantiated = methodILUninstantiated.GetObject((int)pResolvedToken.token);
if (resultUninstantiated is MethodDesc)
{
return ((MethodDesc)resultUninstantiated).InstantiateSignature(typeInstantiation, methodInstantiation);
}
else if (resultUninstantiated is FieldDesc)
{
return ((FieldDesc)resultUninstantiated).InstantiateSignature(typeInstantiation, methodInstantiation);
}
else
{
TypeDesc result = ((TypeDesc)resultUninstantiated).InstantiateSignature(typeInstantiation, methodInstantiation);
if (pResolvedToken.tokenType == CorInfoTokenKind.CORINFO_TOKENKIND_Newarr)
result = result.MakeArrayType();
return result;
}
}
return null;
}
示例7: tryResolveToken
private bool tryResolveToken(ref CORINFO_RESOLVED_TOKEN pResolvedToken)
{
resolveToken(ref pResolvedToken);
return true;
}
示例8: embedGenericHandle_wrapper
public virtual void embedGenericHandle_wrapper(IntPtr _this, out IntPtr exception, ref CORINFO_RESOLVED_TOKEN pResolvedToken, [MarshalAs(UnmanagedType.Bool)]bool fEmbedParent, ref CORINFO_GENERICHANDLE_RESULT pResult)
{
exception = IntPtr.Zero;
try
{
embedGenericHandle(ref pResolvedToken, fEmbedParent, ref pResult);
return;
}
catch (Exception ex)
{
exception = AllocException(ex);
}
}
示例9: getCallInfo_wrapper
public virtual void getCallInfo_wrapper(IntPtr _this, out IntPtr exception, ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, CORINFO_CALLINFO_FLAGS flags, ref CORINFO_CALL_INFO pResult)
{
exception = IntPtr.Zero;
try
{
getCallInfo(ref pResolvedToken, pConstrainedResolvedToken, callerHandle, flags, ref pResult);
return;
}
catch (Exception ex)
{
exception = AllocException(ex);
}
}
示例10: getReadyToRunDelegateCtorHelper_wrapper
public virtual void getReadyToRunDelegateCtorHelper_wrapper(IntPtr _this, out IntPtr exception, ref CORINFO_RESOLVED_TOKEN pTargetMethod, CORINFO_CLASS_STRUCT_* delegateType, ref CORINFO_CONST_LOOKUP pLookup)
{
exception = IntPtr.Zero;
try
{
getReadyToRunDelegateCtorHelper(ref pTargetMethod, delegateType, ref pLookup);
return;
}
catch (Exception ex)
{
exception = AllocException(ex);
}
}
示例11: canAccessClass_wrapper
public virtual CorInfoIsAccessAllowedResult canAccessClass_wrapper(IntPtr _this, out IntPtr exception, ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, ref CORINFO_HELPER_DESC pAccessHelper)
{
exception = IntPtr.Zero;
try
{
return canAccessClass(ref pResolvedToken, callerHandle, ref pAccessHelper);
}
catch (Exception ex)
{
exception = AllocException(ex);
}
return (CorInfoIsAccessAllowedResult)0;
}
示例12: getReadyToRunHelper_wrapper
public virtual void getReadyToRunHelper_wrapper(IntPtr _this, out IntPtr exception, ref CORINFO_RESOLVED_TOKEN pResolvedToken, CorInfoHelpFunc id, ref CORINFO_CONST_LOOKUP pLookup)
{
exception = IntPtr.Zero;
try
{
getReadyToRunHelper(ref pResolvedToken, id, ref pLookup);
return;
}
catch (Exception ex)
{
exception = AllocException(ex);
}
}
示例13: getCastingHelper_wrapper
public virtual CorInfoHelpFunc getCastingHelper_wrapper(IntPtr _this, out IntPtr exception, ref CORINFO_RESOLVED_TOKEN pResolvedToken, [MarshalAs(UnmanagedType.I1)]bool fThrowing)
{
exception = IntPtr.Zero;
try
{
return getCastingHelper(ref pResolvedToken, fThrowing);
}
catch (Exception ex)
{
exception = AllocException(ex);
}
return (CorInfoHelpFunc)0;
}
示例14: getNewHelper_wrapper
public virtual CorInfoHelpFunc getNewHelper_wrapper(IntPtr _this, out IntPtr exception, ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle)
{
exception = IntPtr.Zero;
try
{
return getNewHelper(ref pResolvedToken, callerHandle);
}
catch (Exception ex)
{
exception = AllocException(ex);
}
return (CorInfoHelpFunc)0;
}
示例15: embedGenericHandle
private void embedGenericHandle(ref CORINFO_RESOLVED_TOKEN pResolvedToken, [MarshalAs(UnmanagedType.Bool)]bool fEmbedParent, ref CORINFO_GENERICHANDLE_RESULT pResult)
{
#if DEBUG
// In debug, write some bogus data to the struct to ensure we have filled everything
// properly.
fixed (CORINFO_GENERICHANDLE_RESULT* tmp = &pResult)
MemoryHelper.FillMemory((byte*)tmp, 0xcc, Marshal.SizeOf<CORINFO_GENERICHANDLE_RESULT>());
#endif
bool runtimeLookup;
if (!fEmbedParent && pResolvedToken.hMethod != null)
{
MethodDesc md = HandleToObject(pResolvedToken.hMethod);
TypeDesc td = HandleToObject(pResolvedToken.hClass);
pResult.handleType = CorInfoGenericHandleType.CORINFO_HANDLETYPE_METHOD;
Debug.Assert(md.OwningType == td);
runtimeLookup = md.IsSharedByGenericInstantiations;
pResult.compileTimeHandle = (CORINFO_GENERIC_STRUCT_*)ObjectToHandle(md);
if (!runtimeLookup)
{
// TODO: LDTOKEN <method>?
}
else
{
pResult.lookup.lookupKind.runtimeLookupFlags = (ushort)ReadyToRunFixupKind.MethodHandle;
}
}
else if (!fEmbedParent && pResolvedToken.hField != null)
{
FieldDesc fd = HandleToObject(pResolvedToken.hField);
TypeDesc td = HandleToObject(pResolvedToken.hClass);
pResult.handleType = CorInfoGenericHandleType.CORINFO_HANDLETYPE_FIELD;
pResult.compileTimeHandle = (CORINFO_GENERIC_STRUCT_*)pResolvedToken.hField;
runtimeLookup = fd.IsStatic && td.IsCanonicalSubtype(CanonicalFormKind.Any);
if (!runtimeLookup)
{
// TODO: Handle should actually point to a dependency node (we don't have one yet)
pResult.lookup.constLookup.handle = (CORINFO_GENERIC_STRUCT_*)pResult.compileTimeHandle;
}
else
{
pResult.lookup.lookupKind.runtimeLookupFlags = (ushort)ReadyToRunFixupKind.FieldHandle;
}
}
else
{
TypeDesc td = HandleToObject(pResolvedToken.hClass);
pResult.handleType = CorInfoGenericHandleType.CORINFO_HANDLETYPE_CLASS;
pResult.compileTimeHandle = (CORINFO_GENERIC_STRUCT_*)pResolvedToken.hClass;
runtimeLookup = td.IsCanonicalSubtype(CanonicalFormKind.Any);
if (!runtimeLookup)
{
if (pResolvedToken.tokenType == CorInfoTokenKind.CORINFO_TOKENKIND_NewObj)
pResult.lookup.constLookup.handle = (CORINFO_GENERIC_STRUCT_*)ObjectToHandle(_compilation.NodeFactory.ConstructedTypeSymbol(td));
else
pResult.lookup.constLookup.handle = (CORINFO_GENERIC_STRUCT_*)ObjectToHandle(_compilation.NodeFactory.NecessaryTypeSymbol(td));
}
else
{
pResult.lookup.lookupKind.runtimeLookupFlags = (ushort)ReadyToRunFixupKind.TypeHandle;
}
}
Debug.Assert(pResult.compileTimeHandle != null);
if (runtimeLookup)
{
pResult.lookup.lookupKind.needsRuntimeLookup = true;
pResult.lookup.runtimeLookup.signature = null;
pResult.lookup.runtimeLookup.indirections = CORINFO.USEHELPER;
MethodDesc contextMethod = methodFromContext(pResolvedToken.tokenContext);
// Do not bother computing the runtime lookup if we are inlining. The JIT is going
// to abort the inlining attempt anyway.
if (contextMethod != MethodBeingCompiled)
return;
pResult.lookup.lookupKind.runtimeLookupKind = GetGenericRuntimeLookupKind(contextMethod);
}
else
{
// If the target is not shared then we've already got our result and
// can simply do a static look up
pResult.lookup.lookupKind.needsRuntimeLookup = false;
pResult.lookup.constLookup.accessType = InfoAccessType.IAT_VALUE;
}
}