Sufficiently Smart Virtual Machine

Extracted from SufficientlySmartCompiler:

A related issue is the SufficientlySmartVirtualMachine; early JavaLanguage proponents hypothesized about ultra-advanced VirtualMachines which, by employing various adaptive strategies (profile-directed optimizations and such), would achieve runtimes AsFastAsCee or faster. The logic was that C/C++, being languages which are compiled in advance, could only use static optimizations whereas the Java code could tailor the optimizations being performed to each running instance of the program/class.

Certainly Sun and others have developed some rather advanced VM technology; but none of 'em are AsFastAsCee yet. Given that many optimization strategies employed by C/C++ compilers are NpHard, I suspect that a runtime optimizer will not be able to avail itself of many of them.

Actually, there's no reason a JIT compiler can't use whatever algorithms it wants. By default the JVM interprets bytecode and only uses compilation where it sees fit (i.e. in the "hot spots", hence HotSpotVM. Compilation can also run in background threads out of band with normal execution, and can even avail itself of idle CPUs when they aren't being consumed by the running program.


Hrm. Was the Java-specific CPU ever released? I remember hearing about it years ago - that it would "run Java not at VirtualMachine speed, but at hardware speed". . . never saw anything come of it though.

There are quite a few CPUs, especially the various ARM derivatives used in PDAs, which have "Java accelerators" in them. However, JavaByteCode is not a particularly good instruction set for efficient silicon implementation. Java's bytecode structure is optimized for loading into a compiler, not a processor.

Actually the traditional x86 machine code is also 'not a particularly good instruction set for efficient silicon implementation'. That is the reason why our beloved Intel processors internally decode (read: compile) it into a (very simplified and optimized) data flow machine instruction set and execute that. I don't see any reason why this coudn't be done with bytecode too. After all the http://en.wikipedia.org/wiki/Efficeon (aka Crusoe) also does this. So it is quite possible. It's just not done for historical reasons.


As far as I have seen in a former project (in a team that built a 32bit VM) the "Java accelerators" don't usually help very much. The ones available at the time only helped to speed up the inner interpreter loop - i.e. looking up an address for a bytecode. Some of them provide some stack manipulation shortcuts, possibly even simple mathematical computations using a stack, but as soon as you have to touch a 'real' object or perform a more complex function, you are on your own. Which in turn means that

So - at least for common general-purpose processors - I doubt that a performance-boosting "Java accelerator" in hardware is possible. Of course this does not rule out specific architectures that are tailor-made for efficient Java execution.


But sometimes the time of a SufficientlySmartVirtualMachine comes. An example is GarbageCollection. There are now a few studies that show that programs with automatic GarbageCollection are faster as their more complex counterparts with manual collection.

Which is related to the virtual machine because ...? Because a garbage collector is a part of the hardware abstraction that makes up a VM.


See VirtualMachine


EditText of this page (last edited November 24, 2014) or FindPage with title or text search