erikd
|
 |
«
Posted
2004-08-03 13:49:51 » |
|
On one hand I would expect so, OTOH I would expect javac to do this... Is HotSpot able to do dead code elimination on the fly?
|
|
|
|
princec
|
 |
«
Reply #1 - Posted
2004-08-03 16:16:50 » |
|
AFAIK, server yes, client no. Cas 
|
|
|
|
Azeem Jiva
Junior Member  
Java VM Engineer, Sun Microsystems
|
 |
«
Reply #2 - Posted
2004-08-03 16:26:04 » |
|
|
|
|
|
|
Games published by our own members! Check 'em out!
|
|
erikd
|
 |
«
Reply #3 - Posted
2004-08-03 19:44:06 » |
|
Thanks for that.
The PDF says at one point "Generated code can be problematic". Unfortunately, this is exactly the thing we (or rather, Toby) intend to do with dynamic recompilation of an emulated CPU. Are there any specific do's and (more importantly) don'ts here?
|
|
|
|
Azeem Jiva
Junior Member  
Java VM Engineer, Sun Microsystems
|
 |
«
Reply #4 - Posted
2004-08-03 22:07:27 » |
|
Thanks for that.
The PDF says at one point "Generated code can be problematic". Unfortunately, this is exactly the thing we (or rather, Toby) intend to do with dynamic recompilation of an emulated CPU. Are there any specific do's and (more importantly) don'ts here? I'm not sure, but the PDF is quite old (2001), and this may not be much of a problem anymore. The only suggestions I can give, is to make sure your outputed code is as clean as possible 
|
|
|
|
|
princec
|
 |
«
Reply #5 - Posted
2004-08-04 09:50:03 » |
|
I remember a while back that the client VM definitely didn't do dynamic dead code elimination in 1.4 as shown by some very simple tests... you're saying this is now sorted in 1.5? As I recall, code like this 1 2 3 4 5 6 7 8 9 10 11 12 13
| class Test { final boolean flag; Test(boolean flag) { this.flag = flag; } void loop() { if (flag) { } else { } } } |
under client kept the if() test; and under server it cleverly got removed. Cas 
|
|
|
|
pepe
Junior Member  
Nothing unreal exists
|
 |
«
Reply #6 - Posted
2004-08-04 11:25:31 » |
|
Is there a tool to get or inspect the code generated by hotspot?
|
|
|
|
rreyelts
Junior Member  
There is nothing Nu under the sun
|
 |
«
Reply #7 - Posted
2004-08-04 15:10:30 » |
|
Is there a tool to get or inspect the code generated by hotspot? Exactly. How do you know what was or was not removed Cas? I'd love to be able to know the exact transformation HotSpot performs on my code at runtime. God bless, -Toby Reyelts
|
|
|
|
Azeem Jiva
Junior Member  
Java VM Engineer, Sun Microsystems
|
 |
«
Reply #8 - Posted
2004-08-04 17:20:53 » |
|
under client kept the if() test; and under server it cleverly got removed. Cas  Client does dead code elimination, but only code that has a zero reference count and will not remove calls that return a null value. Something like an instanceOf, or in your case you if() statement are not dead code. Client does not know that removing the if() might change the structure of the code. Server on the other hand does much more extensive evaluation of the code. In this case Server realizes that the if() does nothing and removes it. Also if you want to know what the generated code from HotSpot looks like use: -XX:+PrintOptoAssembly // This dumps the generated assembly -XX:+PrintCompilation // This dumps the compiled methods Both are unsupported, they might destroy your machine, crash your OS, standard disclaimer applies (saving myself here). Oh and -XX:+PrintOptoAssembly only works in debug mode, so you'll need to use the JDK and run java_g vs java.
|
|
|
|
|
rreyelts
Junior Member  
There is nothing Nu under the sun
|
 |
«
Reply #9 - Posted
2004-08-04 17:31:00 » |
|
-XX:+PrintOptoAssembly // This dumps the generated assembly -XX:+PrintCompilation // This dumps the compiled methods
Oh and -XX:+PrintOptoAssembly only works in debug mode, so you'll need to use the JDK and run java_g vs java.
First, thanks for the info. Second, I'm running on x86 - where do I get debug mode java? I don't have a java_g, or any kind of jvm_g.dll or anything that I can spot. God bless, -Toby Reyelts
|
|
|
|
Games published by our own members! Check 'em out!
|
|
Azeem Jiva
Junior Member  
Java VM Engineer, Sun Microsystems
|
 |
«
Reply #10 - Posted
2004-08-04 17:32:29 » |
|
First, thanks for the info.
Second, I'm running on x86 - where do I get debug mode java? I don't have a java_g, or any kind of jvm_g.dll or anything that I can spot.
God bless, -Toby Reyelts
You should be able to get java_g with the JDK, or you use to be able to. Maybe that's changed...
|
|
|
|
|
rreyelts
Junior Member  
There is nothing Nu under the sun
|
 |
«
Reply #11 - Posted
2004-08-04 17:42:49 » |
|
You should be able to get java_g with the JDK, or you use to be able to. Maybe that's changed...
I have both JDK 1.4.2_02 and and JDK 1.5.0-beta2, and neither have a java_g or anything similar (I should have been more specific - this is Windows x86 - not Solaris x86). I can point to several links off of Google that say that java_g was no longer distributed JDK1.2+. Oh, and btw, I tried -XX:+PrintOptoAssembly and it wasn't recognized, but -XX:+PrintCompilation was. God bless, -Toby Reyelts
|
|
|
|
swpalmer
|
 |
«
Reply #12 - Posted
2004-08-05 13:34:46 » |
|
You should be able to compile your own debug VM by getting the source through the Sun community license... I've never tried it myself, but I figured that would be how us mere mortals would get java_g.
There are a few flags that are marked as "debug only" in the docs for hotspot options that are on java.sun.com
|
|
|
|
rreyelts
Junior Member  
There is nothing Nu under the sun
|
 |
«
Reply #13 - Posted
2004-08-05 14:43:03 » |
|
You should be able to compile your own debug VM by getting the source through the Sun community license... There's got to be a better way than that. I don't think building the VM is a 1,2,3 step thing, and I don't have weeks to devote to it. On top of that, I would only get to see the output for the VM I built, as opposed to any VM I can run (i.e. JDK 1.5, etc...) God bless, -Toby Reyelts
|
|
|
|
swpalmer
|
 |
«
Reply #14 - Posted
2004-08-05 16:57:34 » |
|
I never said that option didn't suck  I get the impression that the debug stuff is otherwise internal to Sun. Shame, 'cause it would be quite cool to see what sort of code was produced. But I suspect then that Sun would get bombarded with complaints that the code produced wasn't the best possible code for the task, by people that don't understand that it can take time for a complier to produce really really optimized code and when you are compiling on-the-fly you don't have all the time (or memory, etc.) in the world to optimize.
|
|
|
|
rreyelts
Junior Member  
There is nothing Nu under the sun
|
 |
«
Reply #15 - Posted
2004-08-05 18:29:45 » |
|
I never said that option didn't suck  Lol. I get the impression that the debug stuff is otherwise internal to Sun. Well, they used to ship java_g in the early days. I'm more under the impression no one used it, so they just stopped shipping it. But I suspect then that Sun would get bombarded with complaints that the code produced wasn't the best possible code for the task Perhaps, but that's not the goal. The goal is to understand what the compiler is/is not optimizing, so you know if you need to hand optimize something yourself. God bless, -Toby Reyelts
|
|
|
|
Azeem Jiva
Junior Member  
Java VM Engineer, Sun Microsystems
|
 |
«
Reply #16 - Posted
2004-08-05 20:38:18 » |
|
Perhaps, but that's not the goal. The goal is to understand what the compiler is/is not optimizing, so you know if you need to hand optimize something yourself.
If that's your goal then you need a good profiler. Seeing what the compiler outputs is meaningless unless you understand assembly. Even then a good profiler (there are a bunch) will tell you much more than any stream of assembly.
|
|
|
|
|
rreyelts
Junior Member  
There is nothing Nu under the sun
|
 |
«
Reply #17 - Posted
2004-08-05 20:48:34 » |
|
If that's your goal then you need a good profiler. I don't see how that is the case. The profiler isn't going to tell me whether or not HotSpot performed a particular optimization for me - which is what I need to know. God bless, -Toby Reyelts
|
|
|
|
Azeem Jiva
Junior Member  
Java VM Engineer, Sun Microsystems
|
 |
«
Reply #18 - Posted
2004-08-05 21:33:44 » |
|
Maybe I misunderstood you, but I'm guessing the reason you want to see what optimizations are being applied is because you are trying to improve performance. Am I right? If you really want to see what optimizations are being applied, then you'll need to start reading the HotSpot source code (I'm sure its on java.sun.com) and build a debug version and go from there. If you want to improve performance, than you need to profile your code and see which methods are taking up the majority of CPU cycles, etc and go from there.
Either way to see the assembly output, you'll need the debug bits (and I guess we don't give them out anymore). Building HotSpot isn't difficult under any of the unixes (make fastdebug), but Windows requires a bit more work
|
|
|
|
|
rreyelts
Junior Member  
There is nothing Nu under the sun
|
 |
«
Reply #19 - Posted
2004-08-05 21:43:05 » |
|
Maybe I misunderstood you, but I'm guessing the reason you want to see what optimizations are being applied is because you are trying to improve performance. You're working under the assumption that I don't know what will speed up the program. It's well known in emulation circles that the dead code removal that dynamic recompilation brings is a huge win. The question is whether or not HotSpot will provide that dead code removal, or if I need to implement it myself. If I can't easily determine whether or not HotSpot performs that optimization, it will be a darn shame, because it means that I will have no choice but to implement the optimization myself. And as far as reading assembly goes, I think you'll find that a fair share of the people on this board know how to do just that. God bless, -Toby Reyelts
|
|
|
|
swpalmer
|
 |
«
Reply #20 - Posted
2004-08-06 00:14:21 » |
|
Building HotSpot isn't difficult under any of the unixes (make fastdebug), but Windows requires a bit more work I bet Mac OS X isn't included in "any unixes"  Are you saying there is no Developer Studio project to just load and click "build"  ? I'd love to know if for your own release builds you use something like Intel's compiler and you didn't cheap out on something known to produce inferior intel code like gcc.
|
|
|
|
Azeem Jiva
Junior Member  
Java VM Engineer, Sun Microsystems
|
 |
«
Reply #21 - Posted
2004-08-06 15:26:49 » |
|
I bet Mac OS X isn't included in "any unixes"  Are you saying there is no Developer Studio project to just load and click "build"  ? I'd love to know if for your own release builds you use something like Intel's compiler and you didn't cheap out on something known to produce inferior intel code like gcc. Well Apple does the porting for OSX, so you'll have to ask one of them. Well for our platforms, we use the Sun Compilers for Solaris (SPARC and X86), we use GCC for the Linux platforms and MSVC++ for Windows. A long time ago I tried using Intel's compilers and at least back then the resulting binaries were horrible broken, and I didn't try very hard to figure out why. Although other people have done similar tests (when we changed Solaris compilers for example), and we've found that the C++ compilers didn't make much of a difference in performance for Java. Mostly because Java spends most of its time in generated code.
|
|
|
|
|
trembovetski
|
 |
«
Reply #22 - Posted
2004-08-14 23:05:39 » |
|
. Although other people have done similar tests (when we changed Solaris compilers for example), and we've found that the C++ compilers didn't make much of a difference in performance for Java...
This depends on the library used by the java app. Java2D, for example, has a lot of native code (most of the rendering loops are native), and recent experiments with VC7 free MS toolkit showed some promising results - generated code was smaller and faster (at least, on 2D benchmarks).
|
|
|
|
|
swpalmer
|
 |
«
Reply #23 - Posted
2004-08-16 05:12:04 » |
|
This depends on the library used by the java app. Java2D, for example, has a lot of native code (most of the rendering loops are native), and recent experiments with VC7 free MS toolkit showed some promising results - generated code was smaller and faster (at least, on 2D benchmarks). If you went with hand optimized SIMD instructions for things like blitting loops you would get a HUGE performance boost. If you are going to change this area don't go half way. SIMD instructions would be perfect for the sort of multiply-accumulate operations needed to blit with transparency or translucent areas. Not to mention the filtering used for smooth scaling of image. (But I guess you leave that to the JAI APIs?) Have you experimented with SIMD for blitting loops?
|
|
|
|
princec
|
 |
«
Reply #24 - Posted
2004-08-16 10:03:26 » |
|
Hell, just hire a game programmer contractor to write your blit routines and be amazed at the 4x speed increase. It'll come out of a different budget too so it'll be easy to get approval for it. And there won't be any need to wait for 1.6 either, it could go into 1.5.0_01  Cas 
|
|
|
|
abies
|
 |
«
Reply #25 - Posted
2004-09-01 18:50:10 » |
|
On a bit side note, has anybody managed to use java with AMD CodeAnalyst ? So far, I was able to use it only with statically compiled binaries, which is a shame - seems to be a really powerful tool for profiling.
|
Artur Biesiadowski
|
|
|
|