Escape Analysis?

I’m aware that Flash’s VM still can’t touch Java’s. For Flash 8 there was at least a 10x performance lag versus Java when I checked; I think 9 is closer, but still quite a ways off. So I’m not saying that the performance is there yet. But it’s getting closer, and Flash just seems like it’s being developed in a much more flexible manner than Java. The past two versions of Actionscript have each seriously broken code from the previous versions, to the point that you’re essentially learning a new language. I see absolutely no pandering to the pathetic lower 10% of programmers when design decisions are made regarding Actionscript, whereas Java’s evolution is almost completely determined by the fact that too many Java programmers suck at programming to add much complexity to the language.

For instance, this whole stack allocation thing has one extremely simple solution. Forget escape analysis, just allow classes or structs with value semantics - this has been suggested a thousand times for a thousand reasons. If you can never pass a pointer or a reference, then BAM!, the thing can never escape, so you can safely allocate it to the stack. Easy to implement, proven to work (built-in types prove this). But no. As Sun sees it, any possible means of declaring and manipulating a value type is far too complex for the rubes that program Java, so the idea gets flushed every time it’s brought up.

I’m not saying this is totally a bad move on Sun’s part. It probably lessens the overall amount of whining that they hear, especially given that their installed base contains a whole lot of terrible programmers (banks are filled with them) that really would have trouble learning another syntax element or compiler hint. But it does mean that the language becomes a haven for that type of programmer, and the rest of us have to live without certain features that would really help us.

From what I can see, Flash’s performance is currently bottlenecked at the development level - they are working hard to improve, but it takes a lot of work. They just got a JIT compiler in, so they still have a lot of catch up to do, and we have no idea how far they’ll take it. But Java’s performance is quite often bound by choice, not development time. Many of the reasons it is slower than native code could be addressed in relatively easy to implement ways, at the cost of changing pieces of the language, breaking code, or making people learn new syntax. Which they are extremely hesitant (justifiably or otherwise) to do. Maybe it’s naive to expect Flash to ultimately win out, but unless Adobe starts pandering to their lower 10% more than they do now I don’t think it’s completely out of the question.

In my opinion this just shows how bad the initial design of flash was - and where it comes from.
First it was just a thing for dynamic vector graohics, them some poor scripting was added and somehow married ith the video-design they stll had in mind.
The developers found that because flash is so widely deployed that they could make webapps with it, so again some pieces were added some where broken.
So from my point of view flash only focuses what developers are currently crying for, no matter how it would influence the “whole picture” - it may sound dynamic but in my opionion its a tradeof to produce something useable (any hypeable) for now no matter what will be tomorrow.
Very much like MS blowing up C# wih all feature developers can imagine, just to ride on the “hype-wave”.
It also to some degree shows that flash is not realy used for very serious stuff, unlike java, because enterprises really don’t like stuff to be broken - code has to work for decades instead of just a few versions. Take some Java-1.1 code and you stll can perfectly extend and enhance it with the current JDK/IDEs.

If you look at Java, which has been initially designed for applets and web-devices, it later evolved on the server.
It was ported to mobile devics and lately to blu-ray players … its extremly flexible.
And on the server it did not feel like a misfit, java was perfectly capable handling the server stuff - as well as the stuff on the client (which unfourtunatly was a bit out of SUN’s focus at that time). Could you ever imagine flash would be used outside the area it was developed for?

This has always been a problem point - and if you look almost no languages add that.
Value types add some kind of complexity to the system which affects all developers, whereas only relativly few would really benefit a lot from them.
So … if flash is so cool why does actionscript not have value types :wink:

lg Clemens

By the way my style is a bit of … well … agressive so don’t take any offense please

I reckon value types would add vast amounts of benefit to lots of developers. The real problem is inertia in the massive JRE platform and the VM etc.

Cas :slight_smile:

Most likely for game developers, not for me, nor for the server guys :wink:

I don’t see them solving all problems and they increase complexity for the developer while having a alternative doesn’t and introducing it doesn’t remove the need for escape analysis and … and …

I think I can even think up situations where they decrease performance.

When used right they would be definitivly a way to improve performance, the other way round to opposite happens.
Look at C++ where you have almost all possibilities when it comes down to tell the compiler what you really want it to generate - it requires a lot of knowledge to keep the complexity manageable. Worst is, when available they will be used, so even the 98% that won’t benefit of value types would have a hard time learning things they don’t even seriously need.

lg Clemens

I’m happy for the Java programming language to serve the corporate need for large numbers of warm bodies on seats, but I wish the JVM was more flexible.

[quote]…IBM article seemed to strongly advise against that type of stuff (the author all but implied that anyone that would consider it is a freaking idiot)…
[/quote]
lol, forget about what IBM said… they are not reallly an example in quality… they can give advice on commercial stuff and how to sell innefficient software, but I think they cant give any advice about technical part…

Implementing your own object heap using a static array of Vec2D may be a good solution. this is always a deal on readability and efficiency… but you cant do all for readability or all for efficiency, both are wrong way.

EDIT:
I did this test for you :wink:
http://www.java-gaming.org/forums/index.php?topic=18318.0

IBM promotes / forces its employees to write paper and articles this provides a steady stream of papers/articles of very varible quality. You have to digg for good stuff and filter out bad stuff. dismissing it all because a bundle are bad gets you on the short end.

I don’t know that I would say almost no languages use value types - C++ and C# both have this ability, people successfully put it to good use all the time, and I don’t see all the claimed negative side effects in those areas. In languages like Python, even though you can’t declare your own value types (as far as I know - I’m a bit of a Python noob, to be fair) the need for them is much reduced because of the presence of immutable tuples as a built in type (which is another potential solution with minimal learning curve and simple implementation - I’d totally shut up forever about this if these were added to Java).

Yeah, I think my ode to actionscript was probably a bit overblown - you’re right, it still has all the problems of Java, and more. I agree with the comment that most of its recent progress is largely due to its initial crappiness. But I am hopeful that a day will come again when you can code browser-based games in Java without the current stigma of the applet (or - God forbid! - the dreaded signed applet plus security dialog, or worse, web start).

None taken at all - same disclaimer here (we only argue because we care!). I really do love Java, I prefer it to pretty much every language I’ve coded in, so please take anything negative I say about it with a hefty grain of salt!

Implementation Status

Now Java SE 6 has escape analysis !

Java 6u11 -server -XX:+AggressiveOpts:

Testing 1.0E7 allocation of an Object   : 208 ms.
Testing 1.0E7 Local objects allocation (method scope) : 313 ms.
Testing 1.0E7 allocation of object in a loop  : 433 ms.

Java 6u14 -server -XX:+AggressiveOpts:

Testing 1.0E7 allocation of an Object   : 61 ms. 
Testing 1.0E7 Local objects allocation (method scope) : 94 ms.
Testing 1.0E7 allocation of object in a loop  : 79 ms.

You can download it from http://download.java.net/jdk6/binaries.

Regards
Angelo

Yay! I’ll wait for an official release tho’.

Cas :slight_smile:

what you see is probably object vectorization (EA are a precondition for this)

Oh this looks like a significant performance improvement especially for gaming, wonder if it’ll ever be enabled by default.

Hopefully we’ll see this enabled once two-tier compilation is added. (any news on two tier compilation?)

The main engineer behind tiered compilation died in the middle of last year. I have not seen any changesets that mention it so I’d guess it’s not a high priority.

oh, crap - is that Steve Goldman ?
http://blogs.sun.com/fatcatair/ - warning nasty eye thingy on front page warning nasty eye thingy on front page

oh dear, looks like it was Steve Goldman that passed away. Sad news indeed.

And it looks like he did loads more interesting things than tinker with JVMs as well. That is a great shame.

Cas :slight_smile:

Needs bigger warning.

Ew.

Ewww ewww ewww. EWW!

Where is the mind bleach!? :v