Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
108 views
in Technique[技术] by (71.8m points)

java - JVM: what language can be used for JVM instruction implementation?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

So, basically whenever JVM implements its instruction set in C then the implementation can use native method stack.

The JVM spec says that when the JVM is implemented in "a language such as C" (emphasis added) it may use so called "C stacks". This is very nearly meaningless. The most plausible interpretation is that if the implementation of the language with which a particular JVM is itself implemented relies on C stacks, then that JVM itself is permitted to rely on C stacks.

The context of the quote is a discussion of memory areas used by the JVM, so the main point being made is simply that the JVM may devote some of its runtime memory to C stacks. An entirely separate provision is made for the Java stack, though the specification does not require that this is distinct from the area for C stacks in a JVM that uses C stacks.

Note, however, that although one would ordinarily expect C itself to be considered a language such as C, its specification has nothing whatever to say about stacks. "C stacks" are not a property of C, but rather of hardware and ABI.

This makes me think about what other languages can JVM instruction set be implemented in

The JVM can, in principle, be implemented in any Turing-complete language. Examples include C, C++, Fortran, Python, Lisp, Perl, Ruby, Bash, BASIC, Java itself, and many others, past, present, and future. Some are more attractive candidates than others.

and what kind of stack is used in those cases ?

If the chosen implementation of the chosen language uses C stacks, then the JVM may reserve space for C stacks. There is also the Java stack, which every JVM has. The JVM spec does not make explicit provision for any other kind of stack.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...