Questions about preliminary JIT-using using RuntimeHelpers.PrepareMethod ()

I am exploring the use of RuntimeHelpers.PrepareMethod () to reduce startup time in thin client applications using powerful user interface libraries.

I created a JIT-helper class to run in the background thread and iterate using type or assembly methods and calls PrepareMethod on them

First of all, is there a flaw in this? (and I don't mean JIT-throughout the application, I mean only heavy libraries like Infragistics, DevExpress and classes representing window classes in WPF)

Secondly, is there a way to determine if the JIT method has already been run? (although I did not notice any delays or problems from accidentally calling it several times)

Finally, what happens if I do JIT-ing in a background thread and another thread calls the method that is currently in JIT-ed?

+4
source share
1 answer

Since what you ask depends on the implementation, there is no final answer ... I would expect that there will be some kind of method lock when it will be JITted ... but besides the fact that it digs deeper into specific .NET and etc. This remains an assumption ...

BTW: there is a (non-public) field called IsJitted in the corresponding MethodDesc , which the JIT compiler sets to true after jitting ... for more information see here ...

+2
source

Source: https://habr.com/ru/post/1446699/


All Articles