Does the .NET CLR Really Optimize for the Current Processor

前端 未结 7 474
耶瑟儿~
耶瑟儿~ 2020-12-23 10:45

When I read about the performance of JITted languages like C# or Java, authors usually say that they should/could theoretically outperform many native-compiled applications.

7条回答
  •  一个人的身影
    2020-12-23 11:47

    I'll point out that the main reason that I hear cited for the potential of JIT-compiled languages to outperform statically compiled languages has nothing to do with processor specific instructions. Instead, it's that information about the dynamic state of the program can be used to optimize code paths. For instance, inline caching can be used to make virtual method calls roughly as fast as non-virtual method calls. Roughly, this works by assuming that at a particular call site the method is called only on a single type and emitting code that jumps directly to that implementation (and then rewriting the code if this assumption is not born out later).

提交回复
热议问题