summaryrefslogtreecommitdiff
path: root/runtime/class_linker.cc
AgeCommit message (Collapse)Author
2024-03-21Reuse boot JNI stub for native methods (reland). hangl
Different native methods can share the same JNI stub as long as they have the same flag and shorty. Boot images loaded by zygote contain lots of JNI stubs that already compiled, so we can reuse them for native methods loaded later. For those methods having a matching JNI stub, we no longer need the GenericJNI and following JIT/AOT, which will bring an increase in program speed. Since there are many optimizations in JniCompile, we can also optimize the "shorty equals" criteria for some archs to let more methods find their matching stubs. Test performance improvement: run a simple addOne(Object, int) native method for multiple times at startup (microsecond, lower is better): Number of runs before after 5000 398.70 124.94 10000 792.21 234.23 50000 3919.20 1065.30 Test feature coverage: start and run the app for 30 seconds (top 10 apps in Chinese market, the closer to 100% the better): (count of native methods that reuse boot JNI stub / total count of app native methods = percentage) app1: 1055/1206 = 87.48% app2: 765/884 = 86.54% app3: 1267/1414 = 89.60% app4: 1577/1759 = 89.65% app5: 1698/1860 = 91.29% app6: 2528/2787 = 90.71% app7: 1058/1218 = 86.86% app8: 952/1092 = 87.18% app9: 1343/1483 = 90.56% app10: 2990/3492 = 85.62% This relands commit c8b6e26aa56bb6761bb781d1095b36f84c4c65d4. Reason for reland: - Fix the stack unwind issue of Thumb2. - We never use AOT code in debuggable. So restrict this optimization only to non-debuggable. - The original CL has conflict with aosp/2988923. That other CL is relanded so we can reland after resolving the conflict. Test: m test-art-host-gtest Test: run-gtest.sh Test: testrunner.py --host --all-debuggable Test: testrunner.py --target --all-debuggable Bug: 288983053 Change-Id: If7ba92d8a5f4bb9903b407d4f625e085de80cad7
2024-03-21Improve PointerSize in ImageHeader Santiago Aboy Solanes
We were saving it as a raw uint32 which meant that we were having unnecessary conversion and checks. Bug: 329379384 Bug: 329378408 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Test: m test-art-host-gtest Change-Id: Ib6d9a9abfec7588dad4ff345cc6b569df7144782
2024-03-14Make sure there are no lone UNREACHABLEs Santiago Aboy Solanes
Either remove them, or add a LOG(FATAL) before them. Bug: 328756212 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Test: m test-art-host-gtest Change-Id: Ibf2bddb0a4add5a844a515a040b3751acc7faf84
2024-03-08Revert "Reuse boot JNI stub for native methods" Nicolas Geoffray
This reverts commit c8b6e26aa56bb6761bb781d1095b36f84c4c65d4. Bug: 288983053 Reason for revert: Failure on luci bots. Change-Id: Ieae0f47f2114efbfcb0bc4d8ffb0868001c22653
2024-03-07Reuse boot JNI stub for native methods hangl
Different native methods can share the same JNI stub as long as they have the same flag and shorty. Boot images loaded by zygote contain lots of JNI stubs that already compiled, so we can reuse them for native methods loaded later. For those methods having a matching JNI stub, we no longer need the GenericJNI and following JIT/AOT, which will bring an increase in program speed. Since there are many optimizations in JniCompile, we also optimize the "shorty equals" criteria for some archs to let more methods find their matching stubs. Test performance improvement: run a simple addOne(Object, int) native method for multiple times at startup (microsecond, lower is better): Number of runs before after 5000 398.70 124.94 10000 792.21 234.23 50000 3919.20 1065.30 Test feature coverage: start and run the app for 30 seconds (top 10 apps in Chinese market, higher percentage is better): (count of native methods that reuse boot JNI stub / total count of app native methods = percentage) app1: 1055/1206 = 87.48% app2: 765/884 = 86.54% app3: 1267/1414 = 89.60% app4: 1577/1759 = 89.65% app5: 1698/1860 = 91.29% app6: 2528/2787 = 90.71% app7: 1058/1218 = 86.86% app8: 952/1092 = 87.18% app9: 1343/1483 = 90.56% app10: 2990/3492 = 85.62% Test: m test-art-host-gtest Test: testrunner.py --host Test: run-gtest.sh Test: testrunner.py --target Bug: 288983053 Change-Id: I72f27bcfcd4d4a360bd5d9478b8f7687f087e431
2024-01-24Add visibility attributes in runtime/c* Dmitrii Ishcheikin
Bug: 260881207 Test: presubmit Test: abtd app_compat_drm Test: abtd app_compat_top_100 Test: abtd app_compat_banking Change-Id: Id729aca1d8b6d003ff3e9755112f3283e9f2b507
2024-01-19Move files related to compiled code into oat/ directory Dmitrii Ishcheikin
Test: art/test.py -b --host Change-Id: Icedd3a82c6bca5147c3bc9dc50de5a729003d66f
2023-12-21Fix -Wformat warning Yi Kong
art/runtime/class_linker.cc:2090:31: warning: format specifies type 'size_t' (aka 'unsigned long') but the argument has type 'PointerSize' [-Wformat] Test: presubmit Bug: 315250603 Change-Id: I2724a8564207bde57c2596b0e9f6b1dc340f93f0
2023-12-18Revert "Remove the extra compilation sets in the JIT." Nicolas Geoffray
This reverts commit e39ccf2ea19ca241b7f1dbd9761db696f2055e29. Reason for revert: Issues during class unloading Change-Id: I6621ea1c4aa3d01bc0aae7a22b0b8105d61821a3
2023-12-14A weak reference can be null, so use VisitRootIfNonNull Nicolas Geoffray
Test: tet.py Change-Id: Ib13df3441bb700988ea0c14a00dc6cca477c4538
2023-12-13Remove the extra compilation sets in the JIT. Nicolas Geoffray
They were redundant with the compilation queue. For simplicity, we now always keep live class loaders if there is JIT activity. This prevents mutator threads from taking the JIT lock when requesting a new compilation. Test: test.py Bug: 315300060 Change-Id: Iba30078209906474fa9800a834e3a557dcd99cfc
2023-12-08Reapply "riscv64: re-enable an invoke fast path" Jaeheon Yi
This reverts commit 08d20ebe908d8230108fa64d871d69831c7587e6. Test: Cuttlefish boot (where the problem was first raised) (original commit message) The meaning of ART_METHOD_NTERP_INVOKE_FAST_PATH_FLAG_BIT for RISC-V narrows the condition to object refs only. See invoke.S for notes on code structure. (1) setup lunch aosp_riscv64-trunk-userdebug export ART_TEST_SSH_USER=ubuntu export ART_TEST_SSH_HOST=localhost export ART_TEST_SSH_PORT=10001 export ART_TEST_ON_VM=true . art/tools/buildbot-utils.sh art/tools/buildbot-build.sh --target # Create, boot and configure the VM. art/tools/buildbot-vm.sh create art/tools/buildbot-vm.sh boot art/tools/buildbot-vm.sh setup-ssh # password: 'ubuntu' art/tools/buildbot-cleanup-device.sh art/tools/buildbot-setup-device.sh art/tools/buildbot-sync.sh (2) test art/test.py --target -r --no-prebuild --ndebug --64 -j 12 --cdex-none --interpreter Test: Run these opcodes against all interpreter tests on a Linux RISC-V VM. Clean with `m check_cfi`. Bug: 283082047 Bug: 312482932 Change-Id: Iad7c8b4101f1167c0163bec7bb002fa73acb9622
2023-12-05Reland^2 "Don't use shared hotness counters for debuggable runtimes" Mythri Alle
This reverts commit fe1fcbf66c7ab2b10676647e2971ea91541cd5f3. Reason for revert: Relanding after the test got fixed in b/299090869 Change-Id: I6f55f9f05d30dc57d0f0f7d4dcabcb12f2bfae3b
2023-11-23Revert "riscv64: re-enable an invoke fast path" Prashanth Swaminathan
This reverts commit 301feae50e211656ec3ae1d0ac9445ca8bba623d. Reason for revert: b/312482932 - breaks RISC-V boot. Change-Id: Id5a506949abcb2bc85a10cf5efe9b65ac4ee8031
2023-11-22Revert^4 "Use the same cache for MethodType-s created in native..." Almaz Mingaleev
and managed code. Bug: 297147201 Test: ./art/test/testrunner/testrunner.py --host --64 --optimizing -b Test: ./art/test/testrunner/testrunner.py --jvm -b Test: ./art/test.py --host -b Change-Id: Ic7bf58add0bb3c79fceae8aeecff8976cb22cb07
2023-11-20Do not create `MethodType` during early init... Vladimir Marko
... when interpreting `VarHandle` invoke-polymorphic. Use `VariableSizedHandleScope` as a raw method type that can be converted to the managed `MethodType` when desires but can also be used directly without the conversion. Add helper templates that facilitate using either the raw method type or the managed `MethodType` easily by templated code. Change `VarHandleInvokeAccessorWithConversions()` to avoid allocating the `MethodType` (avoid unnecessary work). Change `VarHandle` invokes in the interpreter to avoid allocating the `MethodType` when the `ThreadLocalRandom` is not initialized. This can avoid circular initialization when we reland https://android-review.googlesource.com/2769639 . Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 297147201 Change-Id: I6a9372543a547366b28e5bf49d15d6140a75f770
2023-11-15riscv64: re-enable an invoke fast path Jaeheon Yi
The meaning of ART_METHOD_NTERP_INVOKE_FAST_PATH_FLAG_BIT for RISC-V narrows the condition to object refs only. See invoke.S for notes on code structure. Test: Run these opcodes against all interpreter tests on a Linux RISC-V VM. (1) setup lunch aosp_riscv64-trunk-userdebug export ART_TEST_SSH_USER=ubuntu export ART_TEST_SSH_HOST=localhost export ART_TEST_SSH_PORT=10001 export ART_TEST_ON_VM=true . art/tools/buildbot-utils.sh art/tools/buildbot-build.sh --target # Create, boot and configure the VM. art/tools/buildbot-vm.sh create art/tools/buildbot-vm.sh boot art/tools/buildbot-vm.sh setup-ssh # password: 'ubuntu' art/tools/buildbot-cleanup-device.sh art/tools/buildbot-setup-device.sh art/tools/buildbot-sync.sh (2) test art/test.py --target -r --no-prebuild --ndebug --64 -j 12 --cdex-none --interpreter Clean with `m check_cfi`. Bug: 283082047 Change-Id: Ie1ecee895cb6d8abad40970041e95388feb530e2
2023-11-10riscv64: Disable nterp invoke fast path. Vladimir Marko
This fast-path is currently broken because it passes references with sign-extension. Test: m Bug: 283082047 Change-Id: Ib554e5dfea5376538a6fa87426c57e8612734b17
2023-11-10Introduce boxed primitive caches in WellKnownClasses. Nicolas Geoffray
Test: test.py Change-Id: Ia8d2f03dea8dd01eeb337d4bc2e31c778b9543a2
2023-11-07Add boot-class-table strong-roots in new-roots for marking phase Lokesh Gidra
Otherwise we may miss marking the dex-cache/dex-file if it is inserted right before marking-pause as we only re-mark logged new roots at that time. Test: art/test/testrunner/testrunner.py --host Change-Id: Ie327c8b2313711dd6a8f1a03a1083d8491906319
2023-10-17Revert^2 "Update class-table and intern-table concurrently with uffd GC" Lokesh Gidra
This reverts commit 9faffd5c4e062ca45bd6f29a3b6d1b276e6c9839. Reason for revert: Reland after fixing null-pointer dereference Bug: 160737021 Test: art/testrunner/testrunner.py Change-Id: I80d3eda827ea805efc5a0e0eb0b80a9d8ceb9dd5
2023-10-17Revert "Update class-table and intern-table concurrently with uffd GC" Lokesh Gidra
This reverts commit 97a6f7cd191cde0abaaf6323ae2f67d8e42a1236. Reason for revert: LUCI failure in libcore test Change-Id: I381b261ae0f67103bf1d096d8f64c84ba3f3e19c
2023-10-17Update class-table and intern-table concurrently with uffd GC Lokesh Gidra
Bug: 160737021 Test: art/testrunner/testrunner.py Change-Id: I4413ead05947f3f865116ae8dc7d67d860106b37
2023-10-10Reland "Add trace points for class loading." Nicolas Geoffray
This reverts commit 99875ff2049f24ea13da8ded5d3433d8435d8513. Bug: 292294133 Reason for revert: avoid string construction Change-Id: Ibdc817bf155ab19ce3dac6a1a1b248ea6f415801
2023-10-09Revert^3 "Use the same cache for MethodType-s created in... Almaz Mingaleev
Revert submission 2768053-reland-methodtype-caching Reason for revert: another circular dependency - CHM->ThreadLocalRandom->ThreadLocal->AtomicInteger::getAndAdd Reverted changes: /q/submissionid:2768053-reland-methodtype-caching Change-Id: Ifc6d759271d819c165c12d47280e6542033a1913
2023-10-02Revert^2 "Use the same cache for MethodType-s created in native and managed ↵ Almaz Mingaleev
code." This reverts commit 52d0ba769ae791c8eac5160e03de7ad369f07ade and 11b1b75c1b6e15500a10288834e299e673010165. Reason for revert: aosp/2768053 should break initialisation cycle. Bug: 297147201 Test: ./art/test/testrunner/testrunner.py --host --64 --optimizing -b Test: ./art/test/testrunner/testrunner.py --jvm -b Test: ./art/test.py --host -b Change-Id: I15b8c1d1014b912ab7e4e9b2adab73736fe2b09b
2023-09-28Revert "Use the same cache for MethodType-s created in native and managed code." Almaz Mingaleev
This reverts commit 6c864435021a44110c39b93ca48fa960e382e4c0. Ignored unstarted_runtime changes because aosp/2760976 was merged. Reason for revert: circular dependency issue: ThreadLocalRandom.<clinit>() ends up calling ThreadLocalRandom.localInit() https://android-build.corp.google.com/artifact/submitted/10869943/art-generational-cc/latest/view/logs%2Fbuild.log Change-Id: I69b6984fd0bd39710a5bbbac6608d218919f9d07
2023-09-28Correct handling ArtMethod array during class linking Lokesh Gidra
In case of userfaultfd, we were setting declaring_class_ of all ArtMethods to nullptr. This could cause problem if a GC is taking place simultaneously and it is visiting the ArtMethod array at the same time. Instead, we should convert the array to a 'no gc-root array' so that compaction code skips it. The marking-phase will simply skips it as it will no longer be pointed by the class. Bug: 301880194 Test: test infra Change-Id: I72007dd94ad71aa9ccc6005eb6d99b5a8c1ad7ee
2023-09-25Detect and throw error if a class implements itself Santiago Aboy Solanes
Bug: 301108855 Fixes: 301108855 Test: art/test/testrunner/testrunner.py --host --64 -b --optimizing Test: Compile the app in the bug Change-Id: I66b529ea36013160e7d17c49bfb36606c268a8ff
2023-09-25Use the same cache for MethodType-s created in native and managed code. Almaz Mingaleev
Bug: 297147201 Test: ./art/test/testrunner/testrunner.py --host --64 --optimizing -b Test: ./art/test/testrunner/testrunner.py --jvm -b Test: ./art/test.py --host -b Change-Id: I55a47439682f1a5903b0e47491e739434e04470f
2023-09-13Revert "Reland "Don't use shared hotness counters for debuggable runtimes""" Mythri Alle
This reverts commit b63b4a28ed2cdbfae75fb5e550313ce3ccec1eae. Reason for revert: Failures on CtsSimpleperfTestCases.record_cmd#check_trampoline_after_art_jni_methods b/300064491 Change-Id: Ia666ae211b1f2cf4548bb5844ec22c3f878c8cab
2023-09-12Reland "Don't use shared hotness counters for debuggable runtimes"" Mythri Alle
This reverts commit 834fb38bc0fb16d7d79bc877fced920065bbff82. Reason for revert: Reland after a fix for the failing test landed b/299090869 Bug: 296416302 Change-Id: Iddbde561e292d8d9177538a5d2ff162355041d9a
2023-09-12Delete all allocators after deleting class loaders Lokesh Gidra
As things are currently, we could have a situation wherein the interface of some class is on a different class-loader, and both loaders are being deleted. If the interface's loader is deleted first, then we get a NPE in ResetSingleImplementationInHierarchy() while accessing interface's art-methods. Bug: 298575095 Test: manual Change-Id: Ib14180bc92d18916fd0c44e0d6c59dfca2f28466
2023-08-30Revert "Don't use shared hotness counters for debuggable runtimes" Mythri Alle
This reverts commit 8f13c9d50fdc8bc03d0091eefd19dda7d2234fcc. Reason for revert: Breaks CtsSimpleperfTestCases record_cmd#check_trampoline_after_art_jni_methods b/296416302 Bug: 296416302 Change-Id: I9079788e289407fdd1b417874a0abe4d2c5e1c9a
2023-08-25Don't use shared hotness counters for debuggable runtimes Mythri Alle
Shared hotness counters is an optimization to avoid dirtying pages shared with the zygote. The general idea is that most important methods already have AOT code so it is okay to use shared counters to monitor hotness of methods. In debuggable runtimes we don't use AOT code and using shared hotness counters makes JITing of these methods. So don't use shared hotness counters for debuggable runtime. Bug: 296298460 Test: art/test.py Change-Id: I1ce826dee6d03606c871093d6b3e69051c9a8760
2023-07-27Revert^2 "Add DEX SHA1 to oat files." David Srbecky
This reverts commit 0d59061cfaf5e60a4fe21f9031492b2a808bb37d. Add SHA1 since it is much more reliable then CRC32/Adler. CHECK that it matches with location checksum comparison. We sill rely on the location checksum, this just ensures that in the very unlikely case of CRC collision we crash, rather than accept the DEX and later mysteriously fail. Test: ./art/test.py -b --host --64 Test: UNSAFE_DISABLE_HIDDENAPI_FLAGS=true m Change-Id: Idf2d9368205771169d577b1ba7ea1bce28b6b22e
2023-07-20Fix a bug in image generation due to default conflict methods. Nicolas Geoffray
There were inconsistencies in HasCodeItem/IsInvokable which lead to the default conflict ArtMethod pointing to arbitrary data. Test: 845-data-image Bug: 290519059 Change-Id: I980c3fdac0ebf29474b166d0acfe27eef1d566c8
2023-07-20Revert "Add DEX SHA1 to oat files." Sebastian Pickl
This reverts commit ba2222f1e114603b42dfdb6dd1d11012d32a2739. Reason for revert: breaking aosp cf targets b/292059778 Bug:292059778 Change-Id: Ia26f8e297a2eb8455df759e92490789f08b41906
2023-07-20Add DEX SHA1 to oat files. David Srbecky
Add SHA1 since it is much more reliable then CRC32/Adler. CHECK that it matches with location checksum comparison. We sill rely on the location checksum, this just ensures that in the very unlikely case of CRC collision we crash, rather than accept the DEX and later mysteriously fail. Test: ./art/test.py -b --host --64 Change-Id: I51af02f63c9ce8b858e4e8b4363bb75f8774d477
2023-07-12Make classes visibly initialized with `membarrier`. Vladimir Marko
Keep the old checkpoint code as a fall-back for platforms that do not support the required `membarrier()` call. Test: run-gtests.sh Test: testrunner.py --target --optimizing Bug: 289195653 Change-Id: I9070e1852327618ccf9749d5af6a2cbdb7959fa6
2023-07-11Revert "Add a phony BootClassLoader instance to hold the boot class table." Nicolas Geoffray
This reverts commit e61fbd8bac612d2c0b7bfe4c1bfef13a6fe526cb. Reason for revert: Fails on gcstress Change-Id: I24c1121c7ec096e11acef29a684dde679ec156ec
2023-07-10Add a phony BootClassLoader instance to hold the boot class table. Nicolas Geoffray
This allows using the regular card table mechanism for aging. Test: test.py (cherry picked from https://android-review.googlesource.com/q/commit:e9c9704218de4683fdc6946cdca17a692c14bdca) Merged-In: I36d8ccb3c9fdbe6747af3b076bc4aab8a7df657c Change-Id: I36d8ccb3c9fdbe6747af3b076bc4aab8a7df657c
2023-06-28Fix new bss roots assertion during marking phase Lokesh Gidra
Earlier we are asserting that a bss root can only be a class. But it's also possible to be a string. Also enables 092-locale art-test. Bug: 288532125 Bug: 288603111 Test: art/test/testrunner/testrunner.py --host -t 092-locale Change-Id: I1e64f571b4ab7121b75c0902b2b4477dc086f13b
2023-06-27Disable the shared memory optimization for methods in non-zygote mode. Nicolas Geoffray
The optimization is only useful for apps forked from zygote. Test: test.py Change-Id: I9e02621bd7f152ec826c6ed0a61d81b193371f7c
2023-06-21Add more logging for b/279117765 Nicolas Geoffray
Test: test.py Bug: 279117765 Change-Id: Ie1a26de358470d48f10702f5944ca707838f1a14
2023-06-14Replace GcRoots in the verifier to use VariableSizedHandleScope. Nicolas Geoffray
This removes the cruft in creating static instances, and the need to explicitly visit verifier roots. Test: test.py Change-Id: Ia0f0a82cbc66bb57f30610587f080e75d4d32e92
2023-06-07Add more debugging logs for b/279117765. Nicolas Geoffray
Test: test.py Bug: 279117765 Change-Id: I8514db54290303362ba6be84c8a6b09b0c3aaad1
2023-05-24Clear startup linear alloc when we delete class loaders. Nicolas Geoffray
If the runtime still has a startup linear alloc, and we're deleting class loaders, we may have dangling references in the startup linear alloc. For simplicity, delete the startup linear alloc if we delete class loaders. Test: test.py Bug: 282967538 Bug: 260557058 Change-Id: Ieb65ab7c1d0c1965233ebfc9eeac3faa0715a9c0
2023-05-22Use C++17's [[maybe_unused]] attribute in ART Stefano Cianciulli
Bug: 169680875 Test: mmm art Change-Id: Ic0cc320891c42b07a2b5520a584d2b62052e7235
2023-05-11Don't use oat / runtime app images in debuggable runtimes Mythri Alle
Oat code even when compiled in debuggable mode lacks method entry / exit hooks. While runtime app images could be potentially used in debuggable runtimes, they don't impact the performance much. So to keep things simple, just don't load images in debuggable runtimes. Also, fix the entrypoints when initializing the classes. This is strictly not necessary but a safe thing to do. Test: art/testrunner.py --speed --debuggable Change-Id: I1c2b5c54a634ff3cde7f46f1077b5e16db2ecb0e