开发者

Does the Dalvik file format (*.dx) support more instructions than a Java .class file?

Is there anything the Dalvik VM supports (in terms of bytecode) which is not used currently because the .class files don't have it?

As an example, if people would write their own Source-to-DX converter for their functional language XYZ, would they be able to implement e. g. full tail calls although the .class file does support tail calls o开发者_Go百科nly under certain circumstances?


I'm no expert, but from what I can see, the answer would be no.

The following two sites lists the Dalvik and JVM opcodes, and put aside the fact that Dalvik is a register based VM and the JVM is stack based, the opcodes are fairly similar.

http://pallergabor.uw.hu/androidblog/dalvik_opcodes.html

http://en.wikipedia.org/wiki/Java_bytecode

Both of them are tailored specifically to handle the Java-language, (even though there are suggestions to lift this constraint, in future versions of the JVM).

One of the problems with tail call optimization on Java, is that the call stack is actually available for the program (through for instance new Throwable().getStackTrace(), which is also present on the Android). If the VM did tail call optimizations, it would need to have some bookkeeping for what it just "optimized away" in order to be able to properly implement the getStackTrace method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜