summaryrefslogtreecommitdiff
path: root/runtime/vdex_file.cc
AgeCommit message (Collapse)Author
2025-03-13Clean up code that invalidated vdex files containing cdex. Martin Stjernholm
Mostly reverts https://r.android.com/2587148. Test: m Bug: 325430813 Change-Id: Id7a0952d0ea83ff69fbd031d1be636e75d4d2d47
2025-03-03Flag classes that have unresolved type checks. Nicolas Geoffray
This allows skipping resolving the field type when setting a field. Test: test.py Change-Id: I1945deca5fdcccca7e67297eca8765b1f2f516f3
2025-02-28Reject compact dex files on load. Martin Stjernholm
We don't want to bump the vdex version, so check all dex files inside a vdex directly when it's loaded. Test: atest art_standalone_runtime_tests art_standalone_libdexfile_tests Bug: 325430813 Bug: 399472993 Change-Id: Icf63cba35a30c609b369e80781e7de732b3a0605
2025-02-18Support loading a VDEX file from a zip file at an address. Jiakai Zhang
We cannot use the existing VdexFile::OpenFromDm because loading dm along with sdm has additional map address, map size, and alignment requirements. Bug: 377474232 Test: art/test.py --host -g Change-Id: I9adf7daf0dad440e181ef324a207b359742e2747
2025-02-14Refactor OatFileAssistant - Step 2. Jiakai Zhang
This change contains some behavioral changes. Particularly, - Consolidate dm_for_oat_ and dm_for_odex_ into one: They are duplicates. - Only check IsUseable if the file exists: This reduces some logging. - Propagate the error message of VdexFile::OpenFromDm to the parent. Bug: 377474232 Bug: 345762752 Test: atest art_standalone_runtime_tests Change-Id: Ia75b7f5b00ca06dda77204a562c6761ef2d5eecf
2025-02-11Remove more dead code for ELF file. Jiakai Zhang
`writable` is always false. `program_header_only` is always true except for in some tests. The code that obtains information through ElfFile with `program_header_only=true` in tests are replaced by code that uses libelf. Bug: 377474232 Bug: 6527146 Test: art/test.py --host -g Change-Id: Icc9b4dbae612a90f54b50e090e191fad0a19f709
2024-11-11Avoid `strlen()` for `ClassLinker::FindClass()`... Vladimir Marko
... and related functions in most cases. Note that the `CompilerDriver` previously resolved the `ClassLoader` and `TransactionAbortError` using the provided class loaders. We're now using the `ClassLoader` from the class roots and resolving the `TransactionAbortError` in the BCP class loader. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 181943478 Bug: 338123769 Change-Id: I38e480cdcdb8bf02c958e4d0773437f5766f6be0
2024-04-11Clean up string data access in `DexFile`. Vladimir Marko
The `*ByIdx()` and `*ByTypeIdx()` functions were doing validity checks that were needed only for processing the debug data, so move the checks to these callers. Replace these functions with new overloads of other functions to provide consistent naming. In a few cases, rewrite calls to these functions to fetch and work with a `string_view` instead. Rename `GetStringLength()` to `GetStringUtf16Length()` and change its return type to `uint32_t`. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I561899606f6e5ec5f23aa4be617349dacdb376e3
2024-01-31Add visibility attributes in runtime/v* Dmitrii Ishcheikin
Bug: 260881207 Test: presubmit Test: abtd app_compat_drm Test: abtd app_compat_top_100 Test: abtd app_compat_banking Change-Id: Iac48967b3f72147d61f0120281875cb9aa370964
2023-12-05Fix CtsSimpleperfTestCases for container dex David Srbecky
ADexFile_create should use the overload that explicitly allows loading just one dex file from container. Rename this overload to make it clearer in the callers. Test: atest CtsSimpleperfTestCases Change-Id: I998b5e68c6966212e49cd32bd812c8062533a98e
2023-10-25Extend memory range of DexFileContainer passed to Dex loader. David Srbecky
Pass the whole relevant memory range (possibly including some surrounding non-dex data). If dex file shares data with other dex files, this will make it possible to verify that all referred data is within bounds of valid memory. Test: ./art/test.py -b --host 001 Change-Id: I5e0058411db4baa3dbe74bfbd7c99d75c9afd694
2023-07-06Remove code related to quicken Santiago Aboy Solanes
It was obsolete (and in some cases dead code). Update our code to use `verify` instead of `quicken` for compiler filters. Bug: 289199192 Change-Id: I39048d50b4d8a3f48e0e88e752a2fd7ad73559a7
2023-05-26Recompile packages with cdex in vdex'es in background dexopt when the Martin Stjernholm
disable cdex experiment is enabled. Test: adb install out/dist/com.google.android.art.apex adb reboot && adb wait-for-device m AppUsedByOtherApp adb install-multiple out/target/product/vsoc_x86_64/testcases/AppUsedByOtherApp/x86_64/AppUsedByOtherApp.apk AppUsedByOtherApp.dm # where AppUsedByOtherApp.dm is created from a non-empty profile adb root && adb wait-for-device adb shell pm bg-dexopt-job adb shell find data/app data/dalvik-cache -name \*.vdex \ \| xargs grep cdex001 # -> matches are found, e.g. in system apps adb shell pm compile -f -m speed-profile \ android.compilation.cts.appusedbyotherapp adb shell grep cdex001 \ /data/app/\*/android.compilation.cts.appusedbyotherapp-\*/oat/x86_64/base.vdex # -> check that a match is found adb shell setprop \ persist.device_config.runtime_native_boot.disable_compact_dex \ true adb shell pm bg-dexopt-job adb shell find data/app data/dalvik-cache -name \*.vdex \ \| xargs grep cdex001 # -> check that no matches are found on SC, TM and UDC platform images Bug: 256664509 Bug: 282137215 Change-Id: I720ffc5861768dc43f70789c0dfbad7ceedc5c9a (cherry picked from commit 35ea7e066db64f4c9c740894d2c428707015a8c0) Merged-In: I720ffc5861768dc43f70789c0dfbad7ceedc5c9a
2023-05-22Use C++17's [[maybe_unused]] attribute in ART Stefano Cianciulli
Bug: 169680875 Test: mmm art Change-Id: Ic0cc320891c42b07a2b5520a584d2b62052e7235
2023-05-09Revert "Fix bug where the output vdex could get compact dex data even when" Nicolas Geoffray
This reverts commit d66a3bb588c21f8a1d13e5c77043f3a62a0d522b. Bug: 256664509 Reason for revert: Breaks bots. Change-Id: I966c1e44873ca195be4f5a40fbfc0c2de9180009
2023-05-05Fix bug where the output vdex could get compact dex data even when Martin Stjernholm
--compact-dex-level is none. If an input vdex containing cdex was given (which is typically the already existing vdex), then it was used as dex files source even when the resulting vdex shouldn't contain cdex. Correct the file magic check to detect that, and ignore the input vdex in that case. Test: m AppUsedByOtherApp adb install-multiple out/target/product/vsoc_x86_64/testcases/AppUsedByOtherApp/x86_64/AppUsedByOtherApp.apk AppUsedByOtherApp.dm # where AppUsedByOtherApp.dm is created from a non-empty profile adb shell pm bg-dexopt-job adb root && adb wait-for-device adb pull `adb shell ls /data/app/\*/android.compilation.cts.appusedbyotherapp-\*/oat/x86_64/base.vdex` grep cdex001 base.vdex # -> check that a match is found adb shell setprop persist.device_config.runtime_native_boot.disable_compact_dex true adb reboot && adb wait-for-device adb shell pm bg-dexopt-job adb root && adb wait-for-device adb pull `adb shell ls /data/app/\*/android.compilation.cts.appusedbyotherapp-\*/oat/x86_64/base.vdex` grep cdex001 base.vdex # -> check that no match is found Bug: 256664509 Change-Id: I222c48c2e29d545e799f0b2faa7f6a7d952e21f6
2023-02-21Refactor DexFileLoader David Srbecky
The first parameter of the Open methods specifies the data source, that we intend to load the dex file(s) from. This creates large number of overloads when multiplied by diversity of the other arguments. Move the data source parameters to the constructor of DexFileLoader. Specifically, the constructor just creates the right DexFileContainer, and the rest of the loader is independent of the data source used. This removes large amount of the overloads as well as large amount of copy-pasted code. Majority of ArtDexFileLoader has been removed. Bug: 266950186 Test: ./art/test.py -b --host --optimizing --64 Change-Id: I6580b49e65441eec93a7e0124be23bd8c859904a
2023-02-02Dex: Use DexFileContainer instead of begin/size. David Srbecky
Cleanup. The DexFileContainer already specifies memory range of the dex file, so there is no need to pass it separately. Remove unused GetPermissions from DexFileContainer. Bug: 266950186 Test: ./art/test.py -b --host --64 Change-Id: I94e4547edaa807d9b9c082e7c2c4c2493abe3a64
2022-09-30Remove redundant definitions of constexpr data. Vladimir Marko
Avoid compiler warning: out-of-line definition of constexpr static data member is redundant in C++17 and is deprecated Test: buildbot-build.sh Change-Id: I213260298833db843a9e4153afd8814af7efa994
2022-02-25Update runtime/ implications to use (D)CHECK_IMPLIES Santiago Aboy Solanes
Follow-up to aosp/1988868 in which we added the (D)CHECK_IMPLIES macro. This CL uses it on compiler/ occurrences found by a regex. Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: Id4ee45b41bad85a1f0d98c1e88af6baa3e34a662
2022-01-12Reland "Remove old unquickening of vdex logic." Nicolas Geoffray
This reverts commit dcf9570d756aa74a2330406c13330c18c34e0db2. Bug: 170086509 Reason for revert: Fix handling of input-vdex file. Change-Id: Idbd59d4fe2be672858f33668a8564933518c28df
2022-01-10Do not continue loading a vdex if we don't have enough reserved space. Nicolas Geoffray
It's always a sign that something is off and the oat file should be rejected. Note that if we continue loading, and the oat file somehow does not get rejected, we will end up in a bogus situation where the OatFile has a wrong value for vdex_begin_ and vdex_end_. Test: test.py Bug: 211367695 Change-Id: I6d6db4bc35f103c2aa935e91b2d329974cbd2d6b
2022-01-06Revert "Remove old unquickening of vdex logic." Nicolas Geoffray
This reverts commit 537f477453823db37130f9c1562f328ad3360b6a. Bug: 170086509 Reason for revert: Fails some tests. Change-Id: I965884b5039f4bce42450091fce04d2c87129c02
2022-01-05Remove old unquickening of vdex logic. Nicolas Geoffray
Test: test.py Bug: 170086509 Change-Id: I30bdacd0cbc966af697c465e29ba4ec885a4c6b4
2021-12-01Suppress vdex madvise calls for metadata access Jared Duke
The vdex madvise calls were made to improve app startup. However, vdex files can also be loaded in other scenarios, like when system_server queries the dex optimization status for various packages during app transitions, or during a global dumpsys. Avoid calling madvise in such situations, as it incurs unnecessary latency/memory overhead. A follow-up CL will consolidate the different dex and vdex madvise paths; much of the dex madvise behavior was conditioned on 512MB Go devices, and is no longer actively used. Test: Verified madvise only called on app startup, and not from deprecated calls to DexFile opt status queries from system_server. Bug: 195793112 Change-Id: I715af7f34b31f2e9060f3d3d57a2a3171f01187b
2021-10-20Use the .dm file at runtime for verification. Nicolas Geoffray
Bug: 112284845 Test: 674-HelloWorld-Dm Change-Id: Icd07f86cfb2b5428186a4c086f042890eaad249b
2021-09-10vdex: add checks in the event of file corruption. Nicolas Geoffray
It's unclear yet why the vdex files are being corrupted. But system server, which is reading these vdex files should be robust to any vdex corruption. Bug: 199309980 Bug: 199395272 Test: test.py Change-Id: Ia85ab8b23a0be4069cfa058a86fdf561f1ceb432
2021-04-28Remove RETURN_VOID_NO_BARRIER byte-code. David Srbecky
Unused and obsolete quickened byte-code. Bug: 170086509 Test: test.py -b --host --64 Change-Id: I1e917c189da7bf64418412522676dc6b081d5c0b
2021-04-19Reland "Move the type lookup table to vdex." Nicolas Geoffray
This reverts commit 640c448bad41c00599f8f8fb056eba679edc891e. Reason for revert: CL is not the culprit Change-Id: Ia9a404980601998ade118b0e14008e2bc6317d76
2021-04-16Revert "Move the type lookup table to vdex." Nicolas Geoffray
This reverts commit c005ada78df5edebac74739b2c344e1a2a3efcba. Bug: 112676029 Reason for revert: Fails on asan Change-Id: Id21b84f1f078d6b1c701559e0cbbd3704d269dfb
2021-04-15Move the type lookup table to vdex. Nicolas Geoffray
The table format has been stable for many releases now, so "promote" it to .vdex, which remains post-OTA. Test: test.py Bug: 112676029 Change-Id: Ie1bbb24b4ab9c7864ae7e69e97db5ee5d1fc9ea1
2021-03-31Restore code inadvertently removed. Nicolas Geoffray
Code was removed by accident in: https://android-review.googlesource.com/c/platform/art/+/1652387 Test: app startup Bug: 183954825 Change-Id: I06d697a0b29a90d2d13dd0a19fb7f381933a6e29
2021-03-31Support background verification of secondary dex files. Nicolas Geoffray
Re-use the infrastructure for background verification of in-memory dex files to also trigger for secondary dex files. Test: 692-vdex-secondary-loader Bug: 160294863 Change-Id: I754d519b6a903c51e439ccab100d2d8f22f45df3
2021-03-25Revamp vdex format for better extensibility. Nicolas Geoffray
- Remove class loader context and boot classpath checksum sections. Those are not needed now that VerifierDeps don't depend on them. - Remove remaining quickening encoding. - Introduce sections in a vdex file, which can be extended without requiring a version change. Test: test.py Bug: 160294863 Change-Id: I4e3e25f34d242dc4de37f30ba9d78bcffbc1436d
2021-03-12Add madvising of .odex, .vdex and .art files Jagadeesh Pakaravoor
1. When mmaping {.art, .odex, .vdex} files madvise them to MADV_WILLNEED 2. Add system properties to limit the madvise size/range Test: presubmit Bug: 178853586 Change-Id: I14afc7cc038ebbf6bba5a393ef222050284dd86d
2021-02-16Use vdex assignability types at runtime. Nicolas Geoffray
When the oat file mentions the class needs to be verified at runtime, check whether the vdex has assignability types. If it has, and the checks are successful, then the class is verified. Otherwise do a full verification to report the actual verification error. Test: test.py Bug: 176960283 Change-Id: I2ba14b72c1d8be3d33f7a699721496a8c15c39f2
2019-12-10Proactively dequicken on debuggable switch. Alex Light
Previously we would generally not really consider dex2dex quickening with debuggable processes. This could cause problems for structural redefinition since the -quick opcodes are incompatible with the types of changes structural redefinition allows. Furthermore this can cause some unexpected behavior where (for example) check-casts might appear to pass even if debugger activity should cause it to fail. In order to fix these issues we make the runtime more proactively dequicken dex-files when we start or switch to JAVA_DEBUGGABLE mode. Test: ./test.py --target --host Test: adb install -t ~/misc/Bandhook-Kotlin/app/build/outputs/apk/debug/app-debug.apk && adb shell monkey -p com.antonioleiva.bandhookkotlin -c android.intent.category.LAUNCHER 1 Bug: 134162467 Bug: 144168550 Change-Id: I2673c91b72ae7048d2ff71a1cf68cf552d4e8004
2019-10-30Oat file checksums for boot image extensions. Vladimir Marko
Modify the oat checksums check for boot image extensions. There may be more extensions loaded at runtime than when the oat file was compiled, so we need to check the checksum type from the checksums string to determine whether to use an image checksum or dex file checksum. Different checksums can be valid for the same boot class path. The creation of boot image extensions and other aspects of loading them shall be implemented in separate CLs. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: aosp_taimen-userdebug boots. Change-Id: I43d1f9464678784e902ad72f4a89cf38b4786122
2019-05-17Add extra systrace for app startup Mathieu Chartier
Added traces for OatFileAssistant, a non trivial amount of time is spent in DexChecksumUpToDate. There should be no significant overhead from the tracing since we don't load oat files very often. Test: test-art-host Bug: 132971994 Change-Id: I2cd63f17e948a27174b27148d5dd5b9310bdf457
2019-04-03Preverify InMemoryDexClassLoader-loaded classes from vdex David Brazdil
This patch creates a new subclass of OatFile - OatFileBackedByVdex - which initializes OatDexClass instances using the verification info in a vdex file created by a previous instance of the class loader. The OatFile is not backed by an actual .oat file. Bug: 72131483 Test: art/tools/run-libcore-tests.sh Test: art/test.py -b -r -t 692 -t 693 Change-Id: I3fd055abe17ee9739c07f2e2f4fc2543e4ec8c9e
2019-04-02Create vdex file for dex loaded with InMemoryDexClassLoader David Brazdil
Previous CL introduced a background verification thread for dex bytecode loaded with InMemoryDexClassLoader. Extend the logic to collect the results of class verification into an instance of VerifierDeps and dump it into a vdex file in the app's data folder. The background thread does not collect full VerifierDeps (e.g. assignability dependencies, etc), just a bit vector of whether a class was successfully verified or not. The vdex format is extended to include boot classpath checksums and the class loader context it was created for. These are optional and currently left empty for regular vdex files. The generated vdex files are treated as a cache with a limited capacity, currently capped at 8 files. The least recently used file (in terms of atime reported by stat()) is unlinked if the cache is full and a new vdex is about to be generated. Bug: 72131483 Test: art/tools/run-libcore-tests.sh Test: art/test.py -b -r -t 692 -t 693 Change-Id: I26080d894d34d8f35f00c7925db569f22f008d2c
2019-02-27Revert "Revert "Add support for booting with a boot classpath not fully AOTed."" Nicolas Geoffray
This reverts commit 14bfeddf2e434954f0ca36687ac0fc5dc6412bd3. Reason for revert: Removes obsolete DCHECK Bug: 119800099 Change-Id: Ia984f95300c6b96165f0179bfc2f66b012bf5dbe
2019-02-26Revert "Add support for booting with a boot classpath not fully AOTed." Andreas Gampe
This reverts commit 7417ce97c4dcabbd7423d46ff9b7cdaf95c1e0f9. Reason for revert: Breaks debug mode Bug: 119800099 Bug: 126239181 Change-Id: I2d4a79f957a020cc6404a130536a416daebc94e3
2019-02-19Add support for booting with a boot classpath not fully AOTed. Nicolas Geoffray
Bug: 119800099 Test: adb shell setprop dalvik.vm.boot-image "/system/framework/nonexistent.art" Change-Id: I6641399f43c24702f19f4d976c6054d77186799e
2019-01-02ART: Move dex structs into own header Andreas Gampe
Separating out the structs from DexFile allows them to be forward- declared, which reduces the need to include the dex_file header. Bug: 119869270 Test: m Change-Id: I32dde5a632884bca7435cd584b4a81883de2e7b4
2018-11-22Rename and reorganize hiddenapi::ApiList David Brazdil
Change values of ApiList flags to make them easier to extend in the future and unify naming across all components. Light greylist is now just "Greylist", dark greylist becomes "GreylistMaxO". Note that the version code in "GreylistMaxO" must also include any maintenance releases, i.e. entries on "GreylistMaxO" are accessible to apps with targetSdkVersion<=27 (O MR1). Test: m, phone boots Test: m test-art Change-Id: I9622e0646eb265008a8bb2652270876ae95dac84
2018-10-23ART: Refactor for bugprone-argument-comment Andreas Gampe
Handles runtime. Bug: 116054210 Test: WITH_TIDY=1 mmma art Change-Id: Ibc0d5086809d647f0ce4df5452eb84442d27ecf0
2018-08-31Reserve boot image memory in one go. Vladimir Marko
Load boot image components into the reserved memory. Test: m test-art-host-gtest Test: testrunner.py --host Test: Pixel 2 XL boots. Test: m test-art-target-gtest Test: testrunner.py --target --optimizing Bug: 77856493 Change-Id: I214f947979bc0bbfc6df4312527504e90b88a01d
2018-08-21Merge "Remove unnecessary indirection from MemMap." Vladimir Marko
2018-08-21Remove unnecessary indirection from MemMap. Vladimir Marko
Avoid plain MemMap pointers being passed around by changing the MemMap to moveable and return MemMap objects by value. Previously we could have a valid zero-size MemMap but this is now forbidden. MemMap::RemapAtEnd() is changed to avoid the explicit call to munmap(); mmap() with MAP_FIXED automatically removes old mappings for overlapping regions. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: Pixel 2 XL boots. Test: m test-art-target-gtest Test: testrunner.py --target --optimizing Change-Id: I12bd453c26a396edc20eb141bfd4dad20923f170