summaryrefslogtreecommitdiff
path: root/runtime/mirror/dex_cache-inl.h
AgeCommit message (Collapse)Author
2025-02-21Support loading an ART file from a zip file. Jiakai Zhang
Bug: 377474232 Test: art/test.py --host -g Change-Id: I1f8acd1d6eeff96cf83af8fcd5111865e114bcef
2024-08-08Use variable sized ref-offset bitmap for fast VisitReferences() Lokesh Gidra
Bug: 304325190 Test: art/test/testrunner/testrunner.py --host Change-Id: I6e25143b827acaa12ff5bd94e6196faaed461f4a
2024-05-17Move transaction records from `Runtime` to `AotClassLinker`. Vladimir Marko
Keep a simple flag for active transaction in `Runtime` but move all other transaction data to `AotClassLinker`. Make `IsActiveTransaction()` a pre-requisite for calling `IsTransactionAborted()`. Eliminate `AbortTransactionAndThrowAbortError()` by inlining into `AbortTransactionV()` and rewriting other callers to use `AbortTransactionF()` instead. Separate transaction-related test code to its own files. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: Ie6ee421fcfed1599049ab50ca692f19c71f395ce
2024-03-26Rename enums.h/.cc to pointer_size.h/.cc. Santiago Aboy Solanes
It was the only enum in the file Bug: 329378408 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: If0e385324afa3685f648135ba9b60e6bc79ba0ed
2024-01-24Add visibility attributes in runtime/mirror Dmitrii Ishcheikin
Bug: 260881207 Test: presubmit Test: abtd app_compat_drm Test: abtd app_compat_top_100 Test: abtd app_compat_banking Change-Id: I6f5eacb96d0ead8144f090624aa99610f78fe57c
2023-06-01Use seq-lock for DexCache David Srbecky
Avoid the need for 16-byte atomics. Test: ./art/test.py -b -r --host --optimizing Change-Id: I818916dd0429de9b0ef364579264868db1d4082c
2023-05-04Simplify deleting startup dex cache arrays. Nicolas Geoffray
- No need to be in a GC critical section. - Make sure the dex cache is in the expected state before registering it. Also remove now unused ScopedInterruptibleGCCriticalSection Test: test.py Change-Id: I27b1209c7a21b811f9e17677e5e2bf70456aad8c
2023-03-04Make entries in dex cache arrays atomic. Nicolas Geoffray
They are read / written concurrently, so tell it to the compiler. Test: m Change-Id: Iaf3e45100ac57d50a17098d8efacf53597a2882a
2022-11-03Optimistically update field and method cache on type update. Nicolas Geoffray
To save on future lookups, update the method and field caches as soon as we update the type cache, when the type has the same dex cache, and the dex cache is using full arrays. This saves the number of lookup of maps startup by ~30% (2100 -> 1500). Test: test.py Change-Id: I4cb708a04fb491fe65a75412bb2a8b9306e81f78
2022-10-28Reland "Allocate dex cache arrays at startup." Nicolas Geoffray
This reverts commit cc97f11fe689c1344bb04ab85e8bdc7baaeb3fb1. Reason for revert: be more selective when using full arrays. Test: test.py Change-Id: If941e81849d9e3b2c4ddcc03e46fb8442a608c82
2022-10-26Revert "Allocate dex cache arrays at startup." Nicolas Geoffray
This reverts commit a25aeadee55630760b521176d0813d12eebae8c8. Bug: 255465158 Reason for revert:b/255465158 Change-Id: Ic9c89532bfec75d2706b8dbcc599fad5c4c71735
2022-10-24Allocate dex cache arrays at startup. Nicolas Geoffray
And deallocate them post startup. Local measurements for app startup average of 1000 runs on Pixel 5 and master: - youtube: 1035 -> 985 - maps: 1142 -> 877 Test: test.py Change-Id: I4fb6e7e2cecdea8bf977ef3b59d47efd0b8b9b74
2022-10-18Add pure array versions of some dex cache fields. Nicolas Geoffray
These arrays will be used when: - The size in the dex file is below the threshold to create a dex cache array. - Startup (will do in a follow-up CL) Given they are pure arrays, they can also be accessed directly from nterp. This can be implemented in a follow-up CL. Test: test.py Change-Id: Ie1b8aca3ac45eefa9866127ffc96e94e3a694cc0
2022-10-13Refactor and cleanup DexCache. Nicolas Geoffray
- Introduce macros to avoid duplicating code for each dex cache kind. - Remove preResolvedStrings, this was unused. - Remove dex cache length fields, we can easily infer them. Test: test.py Change-Id: I1e0bc8cf078ce8e09c4d756c63be32cb344fcce1
2022-10-05Update native GC roots page-by-page Lokesh Gidra
This CL enables updating native GC-roots during compaction page by page. It does so by using a single-space linear allocator for allocating ArtMethods/ArtFields/DexCache etc. and using a per-object header to describe the kind of object/array and its size. Under the hood it still uses arena allocator but the arenas are page-aligned regions taken from a single-space. This allows us in a future CL to use userfaultfd to protect this space during the compaction pause and then concurrently update the pages independently. Bug: 160737021 Test: ART_USE_READ_BARRIER art/test/testrunner/testrunner.py --host Change-Id: Ie52243741360f6008feccec76117d34c77ab1dcf
2022-08-10Convert kUseReadBarrier to static const from constexpr Lokesh Gidra
This CL would compile both CC and userfaultfd GC in the art library, enabling us to choose either of the two during boot time depending on whether the device has userfaultfd kernel feature or not. The CC GC is still chosen unless we use ART_USE_READ_BARRIER=false during build time. This behavior will later be changed to choosing CC *only* if ART_USE_READ_BARRIER=true is used. In other cases, if the device has userfaultfd support then that GC will be chosen. Bug: 160737021 Bug: 230021033 Test: art/test/testrunner/testrunner.py Change-Id: I370f1a9f6b8cdff8c2ce3cf7aa936bccd7ed675f
2022-08-10Update native gc-roots separately in compaction pause Lokesh Gidra
The concurrent compaction algorithm requires all GC roots to be updated to post-compact addresses before resuming mutators for concurrent compaction. Therefore, unlike CC, we cannot update native roots in classes/dex-caches/class-loaders while visiting references (VisitReferences) on heap objects. This CL separates the two and updates all the gc-roots in the compaction pause. Bug: 160737021 Test: art/test/testrunner/testrunner.py Change-Id: I8a57472ba49b9dc30bc0f41a7db3f5efa7eafd9a
2022-02-17Avoid unnecessary read barriers in `ImageWriter`. Vladimir Marko
Also avoid visiting native roots during the same stages, namely layout and writing (including copy-and-fixup). Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 181943478 Change-Id: I0d62d67556109dbcbd8a04fd0e8408733dacce33
2022-02-07Extract atomic pair code from DexCache David Srbecky
Move it to its own header so the code can be reused. Test: test.py -b -r --interpreter Change-Id: I749a03c48df8b481efcf573a41feb67c9b15f393
2022-01-17Revert "Add thread-shared interpreter cache" Hans Boehm
This reverts commit fa40e6e318b21d4a1885a6ffea6efc3c0b5cc1cd. Reason for revert: Seeing several different failures that appear related, both test failures and b/214850618. And it appears a potentially significant unresolved comment was overlooked. Change-Id: I2b5260ac7f2168831f0d1b0d7c76b70ecc1fb77d
2022-01-15Add thread-shared interpreter cache David Srbecky
The thread-local interpreter cache handles around 75% of method/field lookups from the interpreter. Add thread-shared interpreter cache which can be much bigger (since we pay the memory just once rather then per thread). This increases the cache hit rate to 90%. This effectively halves the amount of time we spend in 'NterpGetMethod' (including DexCache lookups), which is the single most expensive method during startup. Furthermore, it also reduces the amount of time we spend resolving methods by around 25% since DexCache entries get evicted less often. The shared cache increases memory use by 256k per process, so also reduce the fixed-size DexCache fields array, which balances it back. Test: test.py --host Change-Id: I3cd369613d47de117ab69d5bee00d4cf89b87913
2021-11-09Modified revert of "Add couple DexCache read-barriers." David Srbecky
Remove the DexCache read-barriers again (the revert) since there is measurable performance difference in app startup (~1%). It turns out they are on very hot path in the interpreter. The lazy array initialization made the DexCache fields mutable. However, instead of the read-barriers, we can just ensure we get the right to-space object on the array-initialization slow path. Test: test.py -b -r --host Change-Id: I3f0123141e9a7875a26f088bff68d50641b66883
2021-10-07Revert^4 "Lazily allocate DexCache arrays." David Srbecky
We rarely need the DexCache for compiled code. Delay the allocation in hope we never need it. This reduces DexCache memory usage by ~25% at startup. Bug: b/181097963 Test: test.py -b --host Change-Id: I1f654aeb538dfed013705a61b1955af1f6b94fe7
2021-10-06DexCache: Remove pre-resolved string dead code. David Srbecky
Pre-resolved strings are no longer used, so remove some of the dead methods. Test: ./art/test.py -b -r --host --64 Change-Id: I02974b1910a8b455f787f9a791fb06de2b3c229a
2021-09-30Revert "Revert^2 "Lazily allocate DexCache arrays."" Nicolas Geoffray
This reverts commit e153a62e8e8a2c42f86d2db87c8188cd0d7bef6b. Bug: b/181097963 Reason for revert: Crashes seen on bots. Change-Id: I1b452d4a15adf42dd7170d77d1b79260d78400a3
2021-09-28Revert^2 "Lazily allocate DexCache arrays." David Srbecky
We rarely need the DexCache for compiled code. Delay the allocation in hope we never need it. This reduces DexCache memory usage by ~25% at startup. This reverts commit b9b7d91f5ceb0b738e1774992fd6fe205c6091e9. Bug: b/181097963 Test: test.py -b --host Test: run previously failing go/ab build in forrest Change-Id: I818ad8f75d2d5387891a96edec49bc7933cd171f
2021-06-29Transaction support for MethodType in dex cache. Vladimir Marko
Test: TransactionTest.ResolveMethodType Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --interpreter Bug: 191765508 Change-Id: I8c80e29fb84d50ca782d05db1bc4634fc002c726
2021-02-25Revert "Lazily allocate DexCache arrays." Orion Hodson
This reverts commit 1214319d27e7fb4c4ff00b39799df6f15288098a. Reason for revert: Post-submit fails Bug: b/181097963 Test: TH Change-Id: I9fd21140f1703d0020458b786f48bd39889a9948
2021-02-23Lazily allocate DexCache arrays. David Srbecky
We rarely need the DexCache for compiled code. Delay the allocation in hope we never need it. This reduces DexCache memory usage by ~25% at startup. Test: m test-art-host-gtest Test: test.py -r -b --host Change-Id: I680a59c905c2b821ee954e4b32abd5d24876bd11
2021-02-18Remove pointer-size arguments from DexCache. David Srbecky
The DexCache is always allocated at runtime now and thus it always has runtime pointer-size. Remove the dead code. Test: m test-art-host-gtest Change-Id: Ic21dc20649e1fd70f8981602d75b5690065aec20
2020-12-04Remove DexCache arrays from image. David Srbecky
Remove the hashtable storage from the image and allocate it at runtime instead (but keep the DexCache object in the image). For compiled code, we have largely moved to using .bss, so the DexCache just costs us unnecessary extra space and dirty pages. For interpreted code, the hashtables are too small and will be overridden many times over at run-time regardless. The next step will be to make DexCache variable-size so it can adapt to both of the extremes (taking minimal amount of memory for compiled code and avoiding cache evictions in interpreter). Test: test.py --host Change-Id: I9f89e8f19829b812cf85dea1a964259ed8b87f4d
2020-08-19Clear DexCache MethodTypes and CallSites in ImageWriter. Vladimir Marko
And clean up the rest of ImageWriter::ClearDexCache(). Test: m Change-Id: I975ce128d1ef7a14e972a17c70f1dee2b55914f6
2020-05-29Only put resolved classes inside the dex cache. Nicolas Geoffray
Users of the dex cache (like the verifier) rely on entries to be resolved. Bug: 155852343 Test: No crash doing "while adb shell stop && adb shell start && sleep 5; do :; done" Change-Id: Ie2a97f75c6cd49a7cf1a2c6529cd8900d7acba3b
2020-03-31Fix race condition in GetPreResolvedStrings Mathieu Chartier
DexCache::VisitReferences had a race condition where a null pointer could be accessed if there was another concurrent caller doing ClearPreResolvedStrings. Fix is to add an extra null check that prevents the race. Bug: 152716138 Test: test-art-host Change-Id: Ib447ce689e23f7c20d4cda8b457abeb89ade9291
2019-04-02ObjPtr<>-ify DexCache. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 31113334 Change-Id: Ic4747928255afca61aca6802e7fec0585c6c1226
2019-03-18Release app image metadata when startup is completed Mathieu Chartier
The app image startup cache is only required for startup. Release it after startup is completed. Note that the cache handles being zeroed out at any time. Bug: 123377072 Test: test-art-host Change-Id: Iaa1c800bd0de7290b44d814a21bda20298a10d5f
2019-02-06Add feature flag for loading app image startup cache Mathieu Chartier
Passed from the zygote. If false, app image string intern tables and preresolved strings are not loaded. This means the intern strings are generated by walking the image instead of looking at the app image intern table directly. Bug: 123524494 Bug: 116059983 Test: test-art-host Test: adb shell device_config put runtime_native use_app_image_startup_cache true (cherry picked from commit 5153419cba1cdfb6d5e5baba3e45fcf703c9daec) Merged-In: I6f800d1d989fd5e5b23166a115b1b241efac7ad2 Change-Id: I119948efd25c039a057f283c19b23431093659f4
2018-10-30Add PreResolved strings dex cache array Mathieu Chartier
For app images, this dex cache may be prepopulated to speed up application startup. This new dex cache array is created when --resolve-startup-const-strings=true. Test: test-art-host Bug: 116059983 Bug: 118385560 Change-Id: I379dc15174281665d7f4ceb106f7fbf51f89b921
2018-10-25ART: Do some include-what-you-use Andreas Gampe
Help with transitive includes. In preparation for new specialized headers reducing transitivity. Bug: 118385392 Test: mmma art Change-Id: Ib465ecceec3331ea81588fb4a43eb65e766b6904
2018-09-17ART: Clean up verify and read barrier flags. Vladimir Marko
Remove read barrier option from Class::IsArrayClass() and related functions. Comparison with null does not need the read barrier and the primitive type should be the same when read from the from-space version of a class as when read from the to-space version. Propagate the verify flags to a few more functions and simplify Class::IsClassClass(). Remove pointer size check from Class::EmbeddedVTableOffset() in preparation for patching the boot image in place before the Runtime and Thread are fully initialized. Test: m test-art-host-gtest Test: testrunner.py --host --gcstress Bug: 77856493 Change-Id: I8b7a6165fa8e25efd37778e0e6ea049fc2147b24
2018-07-19Move .art.rel data to a section in .art, part 1. Vladimir Marko
Refactor the code so that we can collect all relocation offsets while writing the image. Test: Manually verify that the aosp_taimen-userdebug boot image is identical before and after this change; using WIP follow-up code, check that we record the same locations as the patchoat-generated .rel files. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 77856493 Change-Id: Id8c78e417e77e859a82a680504253f41e84560d6
2018-06-20Refactor WriteBarrier logic into its own file Mathieu Chartier
Refactor write barrier logic to have the null check logic in the barrier if possible. Moved the logic into its own file. Test: test-art-host Change-Id: I8292cd7f01dbdddea7aeab6e01da4d309ab452fe
2018-06-11ART: Adds an entrypoint for invoke-custom Orion Hodson
Add support for the compiler to call into the runtime for invoke-custom bytecodes. Bug: 35337872 Test: art/test.py --host -r -t 952 Test: art/test.py --target --64 -r -t 952 Test: art/test.py --target --32 -r -t 952 Change-Id: I821432e7e5248c91b8e1d36c3112974c34171803
2018-05-31Remove static GcRoot<>s from Class and ClassExt. Vladimir Marko
And clean up gc_root includes in runtime/mirror/. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 31113334 Change-Id: Ib5c42a3a892ced4440720350a63a94bcf3a1ca75
2018-05-14ART: Add dex::ProtoIndex Orion Hodson
Test: m -j32 test-art-host Change-Id: Ic2d2a7a43be1b8590b97cdf3729200b043ffc6a3
2018-03-23ART: Simplify atomic.h Orion Hodson
Prefer std::atomic operations over wrappers in atomic.h. Exceptions are cases that relate to the Java data memory operations and CAS operations. Bug: 71621075 Test: art/test.py --host -j32 Test: art/test.py --target --64 -j4 Change-Id: I9a157e9dede852c1b2aa67d22e3e604a68a9ef1c
2018-02-07Remove unused methods. Nicolas Geoffray
Test: m Change-Id: I084f1442ef51b35f70cf0594b7affca49ae8c772
2018-01-05Create dex subdirectory David Sehr
Move all the DexFile related source to a common subdirectory dex/ of runtime. Bug: 71361973 Test: make -j 50 test-art-host Change-Id: I59e984ed660b93e0776556308be3d653722f5223
2018-01-03ART: Rename Atomic::CompareExchange methods Orion Hodson
Renames Atomic::CompareExchange methods to Atomic::CompareAndSet equivalents. These methods return a boolean and do not get the witness value. This makes space for Atomic::CompareAndExchange methods in a later commit that will return a boolean and get the witness value. This is pre-work for VarHandle accessors which require both forms. Bug: 65872996 Test: art/test.py --host -j32 Change-Id: I9c691250e5556cbfde7811381b06d2920247f1a1
2017-12-07ART: Replace base/logging with android-base/logging Andreas Gampe
Replace wherever possible. ART's base/logging is now mainly VLOG and initialization code that is unnecessary to pull in and makes changes to verbose logging more painful than they have to be. Test: m test-art-host Change-Id: I3e3a4672ba5b621e57590a526c7d1c8b749e4f6e