about non-compatible optimization (was: Re: patch to bring java vtables closer to g++ abi conformance)

Bryce McKinlay bryce@waitaki.otago.ac.nz
Fri Jan 25 13:06:00 GMT 2002


Tuomas Leikola wrote:
>combine that with section-gc (or whatever was the current name) and maybe it
>will be finally possible to write small command-line-tools (like gnutools)
>in java.
>Huh? Are you suggesting you want to statically link your small 
command-line-tools?
Closed world optimizations would certainly be nice in some cases. 
However they also:
- Prevent Java's dynamically extenisbility
- Prohibit dynamic linking (at least if you want to keep binary 
compatibility)
- Would require a lot of new compiler infrastructure in order to do them 
well
>>Tuomas> but compiler can "notice" many cases like this, like
>>>>Tuomas> Vector a = new Vector();
>>Tuomas> while (a.size() < 10)
>>Tuomas> {
>>Tuomas> a.add("");
>>Tuomas> }
>>Tuomas> the dynamic invocations could be avoided.
>>>>Type-based optimizations like this are one thing I hope to get out of
>>the `ast' (tree-based optimization) work being done. Another
>>optimization in this category is removing redundant cast checks. I've
>>looked at the ast code a little, but I haven't done any hacking on it
>>yet :-(
>>>>yes, there are alot more savings in higher level constructs than in
>assembler level.. optimizing cast check and method lookup seems quite futile
>(no offense!) if there are multiple redundant checks.
>
I agree that eliminating redundant checks is important. However, in many 
cases it is hard (hopefully the ast SSA stuff will make it easier). But 
if you can make a cast check 3x faster, then it is still 3x faster 
regardless of any redundant checks.
I am curious why you mentioned "dynamic invocations" or "method lookup" 
as being slow. It isn't. In fact a virtual method call (in a loop) in 
GCJ is *faster* than a static method call (in Java or C). Try it if you 
don't believe me! Or are you talking about runtime method lookup via 
reflection?
It is true however that virtual methods are harder to inline, which is 
where closed-world can help by proving that they are really final (and, 
in general, its not safe to inline across a shared-library boundary).
regards
Bryce.


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /