简体   繁体   中英

Does dex2oat compile all methods?

I understand that on recent versions of Android, Dex files are compiled into OAT files on-device. Do OAT files contain compiled versions of all methods in a Dex file, or are some methods left as Dex bytecode and interpreted at run time?

Dex2oat does not compile all methods if the level of application compilation options is not high, or if the method is not considered hot after running for a while.
As we know, dex2oat has many compile filter options: Verify, Quicken, space-profile, space, speed-profile, speed, everything. From Verify to everything, compilations take longer and longer, more and more classes and methods are compiled to bytecode.
You can use the oatdump command to check the compiled status of the methods in a specific package (check the OatClassAllCompiled oatclasssomecomcompiled keyword).
eg Lcom/android/listviewtest/MainActivity$1; (offset=0x000015c8) (type_idx=98) (Verified) ( OatClassAllCompiled )

In addition, Android dex2oat is configured with properties in different scenarios:

[pm.dexopt.ab-ota]: [speed-profile]
[pm.dexopt.bg-dexopt]: [speed-profile]
[pm.dexopt.boot]: [verify]
[pm.dexopt.first-boot]: [quicken]
[pm.dexopt.inactive]: [verify]
[pm.dexopt.install]: [speed-profile]
[pm.dexopt.shared]: [speed]

Refs: https://source.android.com/devices/tech/dalvik/configure

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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