JVM Java Virtual Machine and stacks -
i have query interested in, full explanation though cannot find answers anywhere can explain me how jvm (java virtual machine) uses stacks , stack frames in order organise computations?
the java bytecode so-called stack-oriented programming language. model used lot of virtual machines - in contrast architecture of physical machines.
here example:
public static int foobar(int value) { return value + 42; }
the java bytecode of method looks follows:
iload_0 bipush 42 iadd ireturn
these instructions not use registers. instead use stack computation:
- push first argument onto stack.
- push constant
42
onto stack. - pop 2 elements stack, add them , push result onto stack.
- pop top element stack , return it.
it's same other java bytecode operations. there no registers can used. operations push and/or pop elements onto , stack.
Comments
Post a Comment