News for hackers. Stuff that matters.
Re:The Next Twenty Years of Java: Where We've Been and Where... by chrisseaton on Thursday June 04, 2015 @07:26PM (#9662886)
You say the JVM is hard to run fast because it has a stack-based architecture.

That argument doesn't make any sense to me - by the time you are in your dynamic compiler, and you have an IR in something like sea of nodes, what difference does it make in what format the program was represented on disk? The stack part of it has long gone by then.

Re:The Next Twenty Years of Java: Where We've Been and Where... by codesushi42 on Thursday June 04, 2015 @08:22PM (#9663115)
His argument is hearsay. There's no conclusive evidence that a stack-based VM will always perform worse than a registered based one. There are tradeoffs between both designs. With all of the optimizations you see from register based VMs, you end up with larger instructions due to the lack of a stack pointer.

You can claim that the JVM runs faster than Dalvik though, because it has a better JIT that has had years more to improve.

But I don't know why JVM is being compared against Dalvik when ART is where Android is going in the long run, and has AOT compilation that beats Dalvik's JIT.

Re:The Next Twenty Years of Java: Where We've Been and Where... by mkramlich on Thursday June 04, 2015 @08:21PM (#9663111)
wait til they hear that Linux has a stack-based architecture. that all C-based software has a stack based architecture. threads with stacks everywhere: surprisingly fast. it's usually things like higher-level architectural patterns and algorithm choices which make a MUCH bigger impact on latency and throughput, than whether you have stacks or not.
Re:The Next Twenty Years of Java: Where We've Been and Where... by mikeash on Thursday June 04, 2015 @09:55PM (#9663426)
That's not what that means. In the context of bytecode, a stack-based architecture is one where instructions directly manipulate stack entries. For example, the Java bytecode instruction iadd takes the top two entries from the stack, adds them together, and pushes the result onto the stack. This is in contrast to a register architecture, where you might have an instruction of the form `add x, y, z`, which takes the values in two registers, adds them, and stores the result in another register.

To say that Linux or C is stack-based is nonsensical, as it applies to an instruction set architecture. Virtually all hardware ISAs you're likely to encounter are register-based these days.

Re:The Next Twenty Years of Java: Where We've Been and Where... by pron on Thursday June 04, 2015 @11:34PM (#9663761)
C compiles down to register-based machine instructions, just as Java bytecode does. Bytecode is merely an intermediate represenation.
Re:The Next Twenty Years of Java: Where We've Been and Where... by abc_lisper on Friday June 05, 2015 @01:44AM (#9664046)
But in doing so, Java runs by simulating a stack machine, hence the name virtual machine.
Re:The Next Twenty Years of Java: Where We've Been and Where... by pron on Friday June 05, 2015 @02:04AM (#9664084)
Java bytecode is instructions for a stack machine -- but that's an abstraction. Then the bytecode compiles down to (register) machine instructions, and that compiled implementation is highly efficient and highly optimized.

The virtual machine itself is a complete abstraction. Modern JVMs do not run a simulation of a stack machine at runtime (after compilation, that is).

Re:The Next Twenty Years of Java: Where We've Been and Where... by pcwalton on Thursday June 04, 2015 @09:07PM (#9663268)
The thread is talking more about stack versus register-based VMs than call stacks.

The great stack vs. register-based debate is, in my mind, somewhat like the CISC vs. RISC debate—a fun water cooler conversation, but not too relevant in practice. All performance-focused language VMs lower into a (usually SSA-based) IR soon anyway, so the difference only ends up mattering for VMs that are deliberately kept simple for code size, simplicity, or legacy reasons (like Lua, or CPython).

Re:The Next Twenty Years of Java: Where We've Been and Where... by mkramlich on Thursday June 04, 2015 @09:10PM (#9663279)
fair points