如何使用DefineMethodSpec来定义IL中调用的泛型方法实例 [英] how to use DefineMethodSpec to define a generic method instance for called in IL

查看:162
本文介绍了如何使用DefineMethodSpec来定义IL中调用的泛型方法实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我需要使用通用方法。更清楚的是,当jit compile start时,我想写IL来调用检测的泛型方法。但现在我不知道如何定义可以在IL中调用的泛型方法。我知道需要使用  DefineMethodSpec
来定义methodspec。但如何使用  DefineMethodSpec?如何设置参数  pvSigBlob for
DefineMethodSpec?


解决方案

首先,使用
IMetaDataEmit :: DefineMethod
方法(签名的格式在ECMA-335 Partition II Section 23.2.1中定义)。


接下来,使用DefineMethodSpec创建一个元数据标记,它将您刚定义的方法与您想要的泛型类型参数组合在一起(签名的格式在ECMA-335 Partition II Section 23.2.15中定义) )。


传入DefineMethod的RVA是通过
IMethodMalloc.Alloc
,格式在ECMA-335 Partition II Section 25.4.2和25.4.3中定义。


Hi,

i need to instrument generic method. Be more clearly i want to write IL to call the instrumented generic method when jit compile start. but now i don't know how to define a generic method that can be called in the IL. i know it need to use DefineMethodSpec to define the methodspec. but how to use DefineMethodSpec? how to setup the parameter pvSigBlob for DefineMethodSpec?

解决方案

First, create the generic method definition using IMetaDataEmit::DefineMethod Method (the format of the signature is defined in ECMA-335 Partition II Section 23.2.1).

Next, use DefineMethodSpec to create a metadata token that combines the method you just defined with the generic type arguments you want (the format of the signature is defined in ECMA-335 Partition II Section 23.2.15).

The RVA passed into DefineMethod is allocated via IMethodMalloc.Alloc and the format is defined in ECMA-335 Partition II Sections 25.4.2 and 25.4.3.


这篇关于如何使用DefineMethodSpec来定义IL中调用的泛型方法实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆