简体   繁体   English

Android ART 运行时是否具有与 Dalvik 相同的方法限制限制?

[英]Does the Android ART runtime have the same method limit limitations as Dalvik?

Does the Android ART runtime have the same method limit limitations as Dalvik? Android ART 运行时是否具有与 Dalvik 相同的方法限制限制? Currently, there's a limit of 64k methods in the primary dex file目前,主 dex 文件中的方法限制为 64k

The issue is not with the Dalvik runtime nor the DEX file format, but with the current set of Dalvik instructions .问题不在于 Dalvik 运行时或 DEX 文件格式,而在于当前的Dalvik 指令集 Specifically, the various method invocation methods, which look like this:具体来说,各种方法调用方法,如下所示:

invoke-kind {vC, vD, vE, vF, vG}, meth@BBBB

B: method reference index (16 bits)

You can reference a very large number of methods in a DEX file, but you can only invoke the first 65536, because that's all the room you have in the method invocation instruction.你可以在一个 DEX 文件中引用非常多的方法,但你只能调用前 65536 个,因为这是你在方法调用指令中的全部空间。

I'd like to point out that the limitation is on the number of methods referenced , not the number of methods defined .我想指出,限制在于引用的方法数量,而不是定义的方法数量。 If your DEX file has only a few methods, but together they call 70,000 different externally-defined methods, you're going to exceed the limit.如果您的 DEX 文件只有几个方法,但它们一起调用了 70,000 个不同的外部定义方法,那么您将超出限制。

One way to fix this is to add additional instructions that take wider method references.解决此问题的一种方法是添加采用更广泛方法引用的附加指令。 An approach called "jumbo opcodes" was implemented and released in Android 4.0 (ICS), but was never fully put into action, and was later removed from the tree .在 Android 4.0 (ICS) 中实现并发布了一种称为“巨型操作码”的方法,但从未完全付诸实施,后来从树中删除 (I occasionally see posts here with error messages from "dx" that reference jumbo ops, or from developers who stumbled over them .) (我偶尔会在这里看到一些帖子,其中包含来自“dx”的错误消息,这些消息引用了巨型操作,或者来自偶然发现它们的开发人员。)

Note this is not the problem solved by the Facebook hack .请注意,这不是Facebook hack解决的问题。 That's due to a fixed-size buffer for holding class/method/field meta-data.这是由于用于保存类/方法/字段元数据的固定大小缓冲区。 There's no method-specific limit there;那里没有特定于方法的限制; you can blow out the buffer by having lots of fields.您可以通过拥有大量字段来耗尽缓冲区。

My understanding is that the current implementation of ART handles the same set of instructions that Dalvik does, so the situation will be no different.我的理解是,当前的 ART 实现处理的指令集与 Dalvik 处理的指令集相同,因此情况不会有什么不同。

Anwar Ghuloum told in this Android Developers Backstage episode that they're not going to fix the bytecode in the near future. Anwar Ghuloum 在这个Android Developers Backstage 插曲中告诉他们,他们不会在不久的将来修复字节码。
Instead, starting from Android L they will natively support multi-dex by collapsing all the dex files (from an APK) into a single oat file.相反,从 Android L 开始,他们将通过将所有 dex 文件(来自 APK)折叠成一个 oat 文件来原生支持多 dex。

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

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