I
I
Igor Petrov2012-08-30 18:34:55
Java
Igor Petrov, 2012-08-30 18:34:55

What is the reason for the fact that the JVM is implemented as a stack VM?

Actually, subject. Why a stack implementation, and not, say, a register one? And what are the pros/cons?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
dborovikov, 2012-08-30
@dborovikov

The bytecode for the stack VM is more compact. And apparently it is easier to translate a stack code into a register code than a register code into another register code. Registered VMs are faster, but we must not forget that in Java, performance is provided by JIT translation, apparently the developers chose it because of the convenience of a registered VM. You yourself try to write a compiler - for a stack VM it's easier.

G
gvsmirnov, 2012-08-31
@gvsmirnov

Among other things, it is worth remembering that cross-platform is extremely important for java. At the stage of compilation to bytecode, it is not clear which registers will be available at startup, so the stack is used. During JIT compilation, everything is known about the hardware, and it is easy to optimally scatter all the data over the available registers.

G
greefon, 2012-08-30
@greefon

Better portability of the code and the code itself is more compact

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question