gpt4 book ai didi

dart - Dart是静态编译的,还是在解析并加载到VM时在运行时插入代码?

转载 作者:行者123 更新时间:2023-12-03 02:51:45 33 4
gpt4 key购买 nike

我试图理解为什么向Dart添加特征会导致内存中对象的形状发生变化,因此很好奇它现在如何在代码中加载。

最佳答案

Dart是一种动态类型化的语言,可以直接从源代码生成自己的机器语言等效项,而无需中间字节代码步骤。没有通用的字节码(如JVM或llvm),而是直接编译为机器代码。

我要补充一点,尽管直接编译为机器代码,但语言本身的设计方式却不允许C / C++样式的编译器有效地生成快速高效的代码。这是设计使然的,因为Dart似乎是试图填补JavaScript和Java之间的空白,而不是Java和C / C++之间的空白。 Dart解决了许多使JavaScript难以最重要地优化数字变量输入的问题。

尽管有一些努力将Dart环境移植到Windows / Mac / Linux以外的各种平台上,但是我还没有看到真正的Dart机器语言直接编译器。那并不意味着它们不存在,我只是没有看到Linux Dart环境移植到Beagleboard和其他小型Linux发行版的东西。

从Dart常见问题解答

Q. Why didn’t Google build a bytecode VM targetable by multiple languages including Dart? Each approach has advantages and disadvantages, but we feel that in the context of Dart it made sense to build a language-specific VM for the following reasons:

Google already works on a multi-language bytecode: LLVM bitcode in PNaCl.

Even if a bytecode VM is specialized for Dart, a language VM will be simpler and faster because it can work under stronger assumptions—for instance, a structured control flow. These assumptions make the implementation cleaner and optimizations easier.

A general-purpose bytecode VM would be even larger and slower, as it generalizes assumptions and adds functionality that for Dart is dead code: for example, multithreading with a shared heap.

No bytecode VM is truly general-purpose; they all make assumptions that privilege some class of languages. A language VM leaves more room to improve the VM and make deep changes to optimization of the language. Some Dart engineers wrote an article talking about the VM question in more detail.



关于 Compiling Dart to Efficient Machine Code的不错的演示

关于dart - Dart是静态编译的,还是在解析并加载到VM时在运行时插入代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21342378/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com