How does Java embed virtual function boundaries?

I am reading some materials to explain whether Java can be faster than C, and I encounter the following quotation:

"Java can be faster than C because JIT can be embedded in the boundary of virtual functions."

( http://www.jelovic.com/articles/why_java_is_slow.htm )

What's the meaning of this? Does this mean that JIT can inline virtual function calls (because it can probably access runtime information), and C must call the function through its VTable?

thank you

Talas

Solution

The answer to your question is yes: that's what the quoted text means

The JIT will analyze all loaded classes Derivation and (if applicable) inline method bodies can be avoided if it can be determined that only one method can be called at any given point

In contrast, the C compiler does not know all possible subtypes, so it cannot determine whether this optimization can be done for (virtual) methods (when the linker runs, it's too late...)

Other answers mean that you can manually perform this optimization in C, but suppose you (Programmer) can analyze it yourself and change the method from virtual to non virtual But if you are wrong, you have an error to track

By the way, we can assume that this optimization is worth it for general Java applications If not, the JIT compiler guy won't implement it After all, worthless optimization will only make Java applications start slower

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>