我需要使用通用方法。更清楚的是,当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 useDefineMethodSpec to define the methodspec. but how to useDefineMethodSpec? how to setup the parameterpvSigBlob 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中调用的泛型方法实例
发布评论