Dalvik 文件格式 (*.dx) 是否支持比 Java .class 文件更多的指令?
是否存在 Dalvik VM 支持的任何内容(就字节码而言)目前未使用,因为 .class 文件没有它?
举个例子,如果人们为他们的函数语言 XYZ 编写自己的 Source-to-DX 转换器,他们是否能够实现例如完整的尾部调用,尽管 .class 文件仅在某些情况下支持尾部调用?
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 only under certain circumstances?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不是专家,但据我所知,答案是否定的。
以下两个站点列出了 Dalvik 和 JVM 操作码,抛开 Dalvik 是基于寄存器的 VM 而 JVM 是基于堆栈这一事实,操作码非常相似。
http://pallergabor.uw.hu/androidblog/dalvik_opcodes.html
http://en.wikipedia.org/wiki/Java_bytecode
两者都是专门为处理 Java -语言(尽管有建议在 JVM 的未来版本中解除此限制)。
Java 尾部调用优化的问题之一是调用堆栈实际上可用于程序(例如通过 new Throwable().getStackTrace(),这也存在于 Android 上) 。如果虚拟机进行尾部调用优化,则需要对刚刚“优化掉”的内容进行一些记录,以便能够正确实现 getStackTrace 方法。
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 thegetStackTrace
method.