Open voinokin opened 6 years ago
IACA relies on inline assembly to generate those markers. Needless to say that this doesn't work in C# and I don't know a reasonable workaround. I suppose you could use a disassembler and a hex editor to manually insert those markers in the native image.
How do you think - if I would clone and build my personal version of JIT with couple new IL instructions crafted which would map to such magic byte marks when emitted, will this make a viable solution? (The code does not need to be runnable)
if I would clone and build my personal version of JIT with couple new IL instructions
That could work. But adding some intrinsic methods somewhere might be easier and more usable (you could simply call these methods from C#, but to use those new IL instructions you'd either need to modify Roslyn or insert them manually).
Thanks, I will consider this. Another question is - how do I dump the JIT output to PE/COFF/whatever? I believe RVAs are free to be resolved to any addresses, since the tool does not analyze their values, but will only consider the influence of the encoding of instructions they are used by.
how do I dump the JIT output to PE/COFF/whatever?
Hmm, that may be tricky. If you want a PE file containing the native code generated by the JIT then you can use crossgen. But if you work with SSE/AVX intrinsics you'll run into a problem - crossgen doesn't want to generate code for methods that contain intrinsics. And it's also possible that the code generated by crossgen is different from the code generated at runtime by the JIT (e.g. crossgen will generate SSE instructions for floating point code but it won't use the VEX encoding).
An alternative my be CoreRT, that will give you a true native PE file. And it also generates PDBs that can then be used by a disassembler. But AFAIR it too doesn't handle intrinsics.
It looks like I'll have to dig into JIT source code to figure out. But anyway thanks for pointing out that CoreRT and crossgen will not help - I was thinking to use crossgen before.
Question: Is there any way I could get a dump of native executable code that .NET Core JIT creates, with some additional custom markup? It is not required to be runnable when transferred to different PC.
I'd like to try to run the tool called "Intel Architecture Code Analyzer" (https://software.intel.com/en-us/articles/intel-architecture-code-analyzer) to analyze the performance of my tool which is currently under development, in context of different CPUs - this is what the IACA tool does, but it normally accepts compiled native binary file with "magic" byte sequences inserted telling the region of code which is subject for the analysis. Thanks. category:design theme:ngen skill-level:expert cost:large