简体   繁体   English

DVM是解释器还是编译器?

[英]Is the DVM an interpreter or a Compiler?

Is the DVM an interpreter or a compiler? DVM是解释器还是编译器? Why did google have to come up with the DVM when there is already the JVM? 为什么已经有JVM的Google为什么要提出DVM? Can the JVM not be used in mobile platforms? JVM不能在移动平台上使用吗? If not why not? 如果不是,为什么不呢?

Is the DVM an interpreter or a compiler? DVM是解释器还是编译器?

There's a tool called dx that converts your java bytecode to a dex file. 有一个名为dx的工具可将您的Java字节码转换为dex文件。 So, you compile with java to create a java bytecode (a class file) and a dx tool converts these bytecodes to a .dex file (executable). 因此,使用Java进行编译以创建Java字节码(类文件),然后dx工具将这些字节码转换为.dex文件(可执行文件)。

Why did google have to come up with the DVM when there is already the JVM? 为什么已经有JVM的Google为什么要提出DVM?

Dalvik is optimised to run on mobile devices or devices with low memory requirement. Dalvik经过优化,可在移动设备或内存需求较低的设备上运行。 Dalvik VM takes less space to run compared to the JVM. 与JVM相比,Dalvik VM占用的运行空间更少。

One important factor is LICENSE . 一个重要因素是许可 If Google had to go to J2ME, the application had to be licensed, etc and Google wanted to avoid being licensed. 如果Google必须使用J2ME,则该应用程序必须获得许可等,因此Google希望避免获得许可。

Also a quote from @leo's - Is Dalvik the better J2ME? 也来自@ leo's的报价-Dalvik是更好的J2ME吗? :

As J2ME is not really a strong framework, you have a single programming language, but it's up to the vendor which functionality he likes to integrate, every single phone is different. 由于J2ME并不是真正强大的框架,因此您只有一种编程语言,但取决于供应商,他喜欢集成哪些功能,每部电话都不一样。 That makes porting J2ME to a real pain. 这使得将J2ME移植起来确实很痛苦。

3) 3)

Can the JVM not be used in mobile platforms? JVM不能在移动平台上使用吗? If not why not? 如果不是,为什么不呢?

At the present moment, no as it requires resources (that's available on PC) to run. 目前,还没有,因为它需要资源(在PC上可用)来运行。 Also, it's a stack machine, so it uses "instructions to load data on the stack and manipulate that data, and, thus, require more instructions than register machines to implement the same high level code" ( source ). 另外,它是一台堆栈计算机,因此它使用“指令将数据加载到堆栈上并操纵该数据,因此,与注册计算机相比,需要更多指令才能实现相同的高级代码”( )。

We can expect future mobile/portable devices to be able to have the processing power, storage capability and security features to run the JVM, but for now, Dalvik is king! 我们可以预期未来的移动/便携式设备将具有运行JVM的处理能力,存储功能和安全功能,但就目前而言,Dalvik是王者! :-) :-)

Hope this helps. 希望这可以帮助。

DVM = Interpreter wiki DVM =解释器Wiki

Dalvik is very optimized and has different architecture to support Android features. Dalvik经过了非常优化,并具有不同的体系结构来支持Android功能。 Do look at the wiki link above you will have answers for everything. 请查看上面的Wiki链接,您将获得所有答案。 JVM can be used in mobile platforms. JVM可以在移动平台中使用。 Infact, J2ME is based on JVM. 实际上,J2ME是基于JVM的。

Is the DVM an interpreter or a compiler? DVM是解释器还是编译器?

Given that the version of Dalvik that shipped with 2.2 has just-in-time compilation, the answer is "yes." 鉴于2.2版随附的Dalvik版本具有即时编译功能,答案是“是”。

Why did google have to come up with the DVM when there is already the JVM? 为什么已经有JVM的Google为什么要提出DVM?

Can the JVM not be used in mobile platforms? JVM不能在移动平台上使用吗? If not why not? 如果不是,为什么不呢?

When you say "the" JVM, I'll assume you mean Sun's* JVM. 当您说“ the” JVM时,我假设您的意思是Sun的* JVM。 There's no reason why it can't be used in a mobile platform, and it has been. 没有理由不能在移动平台中使用它,并且已经如此。 ("Mobile" being a very broad term.) However, that particular implementation is not ideal in every environment, and Java was always intended to have many ways to run its bytecode ranging from VMs on desktops to silicon that runs it directly. (“移动”是一个非常宽泛的术语。)但是,这种特定的实现并非在每种环境中都是理想的,并且Java一直打算通过多种方式来运行其字节码,从台式机上的VM到直接运行其的芯片。

Exactly what drove the decision to implement Dalvik is a question only the people who wrote it can answer, although it may have come down to licensing or having the ability to fine-tune it as they pleased. 决定实施Dalvik的决定的确切原因是只有编写它的人才能回答的问题,尽管它可能归结为许可或具有按其意愿进行微调的能力。 In general, though, Dalvik's more compact executable format (DEX) makes it better suited to environments where on-board memory is precious as was the case with early Android devices. 总的来说,Dalvik更紧凑的可执行格式(DEX)使它更适合于机载内存非常宝贵的环境,就像早期的Android设备一样。 Its register-based implementation may also provide better compute performance and lower power consumption than Sun's stack-based JVM on the kinds of CPUs that the OS targets. 与基于Sun的基于堆栈的JVM相比,基于OS的目标CPU的基于寄存器的实现还可以提供更好的计算性能和更低的功耗。

*Sorry, Larry, no soup for you. *对不起,拉里,没有汤给你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM