JITted machine instructions at program restart

早过忘川 提交于 2019-12-12 01:13:28

问题


What happens to the machine code/instructions that are generated by the JIT compiler when a program is terminated or restarted. Does the JIT compilation occur again? If so, why would it use this approach?

To keep the scope simple, I would like to know specifically about .NET but for the benefit of others, answers about other implementations are welcome


回答1:


Does the JIT compilation occur again?

Yes, in general.

If so, why would it use this approach?

For one thing, it avoids questions about where the JITted code should be stored, how long for etc. For another, it avoids the code becoming invalid due to someone moving their hard drive to a machine with a different CPU, for example. I suspect it's felt that JIT compilation is a relatively small part of the total time taken for most programs.

Now you can "pre-JIT" an assembly using NGen - but there are some optimizations I believe it can't make, and again the generated code becomes invalid if you change CPU etc.

Also note that the .NET framework itself will run a background service when it's first installed, to JIT compile the framework libraries (which will probably form the bulk of the code run for most apps). Presumably it has some smarts to recompile if necessary... I've never looked into it in too much detail.



来源:https://stackoverflow.com/questions/12398760/jitted-machine-instructions-at-program-restart

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!