summaryrefslogtreecommitdiff
path: root/compiler/jni
AgeCommit message (Collapse)Author
2024-12-17Document and fix thread flags memory ordering Hans Boehm
Expand mutator_gc_coord.md with a discussion of memory ordering for state and flags accesses. Change ReadFlag() to take a non-defaulted memory order argument. Fix all calls to supply it. The prior memory_order_relaxed default does not make sense, since it is incorrect in a few places. And even when it is correct, the arguments behind that are extremely subtle and vary by call site. We want this to be very explicit and documented. Document ThreadList::RunCheckpoint memory ordering requirements. Document the fact that empty checkpoinst should also satisfy those requirements, but currently do not fully do so. Temporarily strengthen memory ordering to test kEmptyCheckpointRequest to partially work around the above issue. Strengthen some of the loads to test kRunningFlipFunction. We did not always perform an acquire load before concluding that the flip function had completed. Weaken one load in EnsureFlipFunctionStarted for consistency. In a corner case, reload a flag with acquire ordering in the same function. This is the result of a fairly complete pass over the flag setting and reading logic. The empty checkpoint issue still needs to be more completley addressed, most probably by switching empty checkpoints to use the general checkpoint logic. It currently uses an "optimization" that is very difficult, and probably expensive, to fully correct. It is not clear whether we have observed bugs caused by this in the field. Bug: 382722942 Bug: 380159893 Test: Build and boot aosp Test: Checked .md file with lowdown Change-Id: I793eac7ddf80fada36bb4f16ddfaaf317829caa3
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-06-20Change CreateInternalStackTrace to return a mirror::Object. Nicolas Geoffray
It might be called in a context where there isn't a JNI frame (for example when throwing in the runtime). So return a mirror::Object instead of jobject. Test: 107-int-math2 with gcstress Change-Id: I72ea87db8cf5092e636901d1114034e81de13146
2024-05-28Switch to the header-only library of libnativehelper in the tests. Martin Stjernholm
To avoid a linker dependency on libnativehelper that we actually don't use any symbols from. Test: Build all bundled and standalone gtests Bug: 247108425 Bug: 261703065 Change-Id: I2fbdefff77d16bc94a96c40f2037cc3c057c8e13
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-03-08Pass only shorty to `ArtQuickJniCompileMethod()`. Vladimir Marko
Passing a `dex_file` and `method_idx` makes testing unnecessarily difficult. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 288983053 Change-Id: Ice79423ec568e254547acd4448fb82e2ad11b79c
2024-02-12JNI: Keep previous LRT state in callee-save reg. Vladimir Marko
Golem results for art-opt-cc (higher is better): linux-armv7 (Odroid-C2) before after NativeDowncallStaticFast 21.622 21.923 (+1.395%) NativeDowncallStaticFast6 18.491 18.719 (+1.236%) NativeDowncallStaticFastRefs6 15.347 15.504 (+1.025%) NativeDowncallVirtualFast 20.741 21.319 (+2.787%) NativeDowncallVirtualFast6 18.953 19.183 (+1.218%) NativeDowncallVirtualFastRefs6 15.500 15.663 (+1.053%) NativeDowncallStaticNormal 14.620 14.757 (0.9495%) NativeDowncallStaticNormal6 13.120 13.235 (+0.8823%) NativeDowncallStaticNormalRefs6 11.454 11.538 (+0.7258%) NativeDowncallVirtualNormal 14.216 14.486 (+1.898%) NativeDowncallVirtualNormal6 13.347 13.466 (+0.8978%) NativeDowncallVirtualNormalRefs6 11.538 11.628 (+0.7752%) linux-armv7 (Raspberry Pi 4) before after NativeDowncallStaticFast 43.305 42.331 (-2.250%) NativeDowncallStaticFast6 35.608 37.369 (+4.945%) NativeDowncallStaticFastRefs6 31.390 31.793 (+1.285%) NativeDowncallVirtualFast 33.814 31.825 (-5.882%) NativeDowncallVirtualFast6 34.311 36.445 (+6.220%) NativeDowncallVirtualFastRefs6 31.762 32.419 (+2.069%) NativeDowncallStaticNormal 13.848 14.244 (+2.859%) NativeDowncallStaticNormal6 13.592 13.725 (+0.9804%) NativeDowncallStaticNormalRefs6 12.671 12.536 (-1.061%) NativeDowncallVirtualNormal 13.979 13.848 (-0.9397%) NativeDowncallVirtualNormal6 13.242 13.592 (+2.647%) NativeDowncallVirtualNormalRefs6 12.364 12.358 (-0.094%) linux-armv8 (Odroid-C2) before after NativeDowncallStaticFast 24.752 25.160 (+1.648%) NativeDowncallStaticFast6 22.571 22.908 (+1.494%) NativeDowncallStaticFastRefs6 19.183 19.183 (unchanged) NativeDowncallVirtualFast 21.622 22.244 (+2.879%) NativeDowncallVirtualFast6 21.319 21.934 (+2.887%) NativeDowncallVirtualFastRefs6 17.448 17.848 (+2.296%) NativeDowncallStaticNormal 17.048 17.250 (+1.183%) NativeDowncallStaticNormal6 15.992 16.161 (+1.054%) NativeDowncallStaticNormalRefs6 14.085 14.216 (+0.9314%) NativeDowncallVirtualNormal 15.504 15.826 (+2.077%) NativeDowncallVirtualNormal6 15.347 15.663 (+2.064%) NativeDowncallVirtualNormalRefs6 13.466 13.586 (+0.8859%) linux-armv8 (Raspberry Pi 4) before after NativeDowncallStaticFast 38.366 40.796 (+6.335%) NativeDowncallStaticFast6 38.347 40.419 (+5.405%) NativeDowncallStaticFastRefs6 31.636 32.528 (+2.820%) NativeDowncallVirtualFast 35.201 37.406 (+6.266%) NativeDowncallVirtualFast6 34.000 35.626 (+4.782%) NativeDowncallVirtualFastRefs6 27.201 27.201 (unchanged) NativeDowncallStaticNormal 14.808 15.107 (+2.024%) NativeDowncallStaticNormal6 14.955 14.428 (-3.526%) NativeDowncallStaticNormalRefs6 14.174 13.855 (-2.254%) NativeDowncallVirtualNormal 14.735 14.307 (-2.904%) NativeDowncallVirtualNormal6 14.244 14.385 (+0.9921%) NativeDowncallVirtualNormalRefs6 14.105 14.244 (+0.9823%) linux-ia32 before after NativeDowncallStaticFast 223.66 233.77 (+4.516%) NativeDowncallStaticFast6 159.76 163.92 (+2.602%) NativeDowncallStaticFastRefs6 137.16 141.72 (+3.324%) NativeDowncallVirtualFast 211.79 224.05 (+5.791%) NativeDowncallVirtualFast6 149.85 154.00 (+2.769%) NativeDowncallVirtualFastRefs6 132.17 136.93 (+3.603%) NativeDowncallStaticNormal 51.091 51.091 (unchanged) NativeDowncallStaticNormal6 45.680 45.703 (+0.0497%) NativeDowncallStaticNormalRefs6 44.732 45.161 (+0.9606%) NativeDowncallVirtualNormal 50.450 50.450 (unchanged) NativeDowncallVirtualNormal6 45.161 45.161 (unchanged) NativeDowncallVirtualNormalRefs6 44.125 44.147 (+0.496%) linux-x64 before after NativeDowncallStaticFast 173.07 181.05 (+4.611%) NativeDowncallStaticFast6 156.50 161.34 (+3.092%) NativeDowncallStaticFastRefs6 130.37 131.61 (+0.9499%) NativeDowncallVirtualFast 169.00 174.83 (+3.447%) NativeDowncallVirtualFast6 148.13 149.35 (+0.8243%) NativeDowncallVirtualFastRefs6 127.31 130.11 (+2.200%) NativeDowncallStaticNormal 47.952 47.952 (unchanged) NativeDowncallStaticNormal6 46.789 46.789 (unchanged) NativeDowncallStaticNormalRefs6 44.643 44.643 (unchanged) NativeDowncallVirtualNormal 47.358 47.358 (unchanged) NativeDowncallVirtualNormal6 45.703 45.680 (-0.0497%) NativeDowncallVirtualNormalRefs6 44.643 44.643 (unchanged) Test: m test-art-host-gtest Test: testrunner.py --host Test: run-gtests.sh Test: testrunner.py --target --optimizing Bug: 172332525 Change-Id: I9606412c658cae8b7583308facf5ba095a982349
2024-02-08Use register pair loads/stores in JNI stubs... Vladimir Marko
... on arm/arm64 for local reference frame manipulation. Golem results for art-opt-cc (higher is better): linux-armv7 (Odroid-C2) before after NativeDowncallStaticFast 21.622 21.622 (unchanged) NativeDowncallStaticFast6 18.500 18.491 (-0.0500%) NativeDowncallStaticFastRefs6 15.354 15.354 (unchanged) NativeDowncallVirtualFast 21.027 20.741 (-1.361%) NativeDowncallVirtualFast6 18.953 18.953 (unchanged) NativeDowncallVirtualFastRefs6 15.504 15.504 (unchanged) NativeDowncallStaticNormal 14.620 14.620 (unchanged) NativeDowncallStaticNormal6 13.120 13.120 (unchanged) NativeDowncallStaticNormalRefs6 11.454 11.454 (unchanged) NativeDowncallVirtualNormal 14.342 14.216 (-0.8823%) NativeDowncallVirtualNormal6 13.347 13.347 (unchanged) NativeDowncallVirtualNormalRefs6 11.538 11.544 (+0.0481%) linux-armv7 (Raspberry Pi 4) before after NativeDowncallStaticFast 41.937 41.564 (-0.8906%) NativeDowncallStaticFast6 33.234 35.608 (+7.144%) NativeDowncallStaticFastRefs6 30.527 31.469 (+3.085%) NativeDowncallVirtualFast 37.531 35.429 (-5.600%) NativeDowncallVirtualFast6 32.803 34.125 (+4.028%) NativeDowncallVirtualFastRefs6 30.500 31.500 (+3.279%) NativeDowncallStaticNormal 13.599 14.112 (+3.773%) NativeDowncallStaticNormal6 13.599 13.599 (unchanged) NativeDowncallStaticNormalRefs6 12.358 12.677 (+2.580%) NativeDowncallVirtualNormal 13.473 13.848 (+2.781%) NativeDowncallVirtualNormal6 13.235 13.242 (+0.0495%) NativeDowncallVirtualNormalRefs6 12.165 12.364 (+1.632%) linux-armv8 (Odroid-C2) before after NativeDowncallStaticFast 23.988 24.765 (+3.238%) NativeDowncallStaticFast6 21.923 22.571 (+2.955%) NativeDowncallStaticFastRefs6 18.719 19.183 (+2.480%) NativeDowncallVirtualFast 21.027 21.622 (+2.828%) NativeDowncallVirtualFast6 20.267 21.319 (+5.190%) NativeDowncallVirtualFastRefs6 16.683 17.448 (+4.583%) NativeDowncallStaticNormal 16.683 17.057 (+2.239%) NativeDowncallStaticNormal6 15.656 15.992 (+2.149%) NativeDowncallStaticNormalRefs6 13.958 14.085 (+0.9054) NativeDowncallVirtualNormal 15.196 15.504 (+2.026%) NativeDowncallVirtualNormal6 15.049 15.347 (+1.980%) NativeDowncallVirtualNormalRefs6 13.006 13.466 (+3.541%) linux-armv8 (Raspberry Pi 4) before after NativeDowncallStaticFast 36.482 38.366 (+5.164%) NativeDowncallStaticFast6 37.406 38.366 (+2.564%) NativeDowncallStaticFastRefs6 28.770 31.652 (+10.02%) NativeDowncallVirtualFast 34.000 35.201 (+3.532%) NativeDowncallVirtualFast6 33.251 34.000 (+2.254%) NativeDowncallVirtualFastRefs6 26.474 27.201 (+2.747%) NativeDowncallStaticNormal 14.237 14.606 (+2.592%) NativeDowncallStaticNormal6 14.244 14.948 (+4.942%) NativeDowncallStaticNormalRefs6 13.012 14.181 (+8.983%) NativeDowncallVirtualNormal 14.105 14.663 (+3.954%) NativeDowncallVirtualNormal6 13.979 14.735 (+5.406%) NativeDowncallVirtualNormalRefs6 13.725 14.244 (+3.775%) The Odroid-C2 results appear essentially unchanged for armv7 (with some minor regressions within noise) and only little better for armv8 (but still likely within noise). On the Raspberry Pi 4, there appears to be some improvement for armv7 and a decent improvement for armv8 but there is higher level of noise than on Odroid-C2. Results from this single run are not very conclusive but we expect to see a clear trend in the data after submission. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: run-gtest.sh Test: testrunner.py --target --optimizing Bug: 172332525 Change-Id: I01033950355c988c8a0e7ed6bdb6e585587dcfb4
2024-01-19Move files related to compiled code into oat/ directory Dmitrii Ishcheikin
Test: art/test.py -b --host Change-Id: Icedd3a82c6bca5147c3bc9dc50de5a729003d66f
2023-12-20Revert^18 "Thread suspension cleanup and deadlock fix" Hans Boehm
This reverts commit 8bc6a58df7046b4d6f4b51eb274c7e60fea396ff. PS1 is identical to https://android-review.git.corp.google.com/c/platform/art/+/2746640 PS2 makes the following changes: - Remove one DCHECK each from the two WaitForFlipFunction variants. The DCHECK could fail if another GC was started in the interim. - Break up the WaitForSuspendBarrier timeout into shorter ones. so we don't time out as easily if our process is frozen. - Include the thread name for ThreadSuspendByThreadIdWarning, since we don't get complete tombstones for some failures. Test: Treehugger, host tests. Bug: 240742796 Bug: 203363895 Bug: 238032384 Bug: 253671779 Bug: 276660630 Bug: 295880862 Bug: 294334417 Bug: 301090887 Bug: 313347640 (and more) Change-Id: I12c5c01b1e006baab4ee4148aadbc721723fb89e
2023-12-19Revert^17 "Thread suspension cleanup and deadlock fix" Hans Boehm
This reverts commit c6371b52df0da31acc174a3526274417b7aac0a7. Reason for revert: This seems to have two remaining issues: 1. The second DCHECK in WaitForFlipFunction is not completely guaranteed to hold, resulting in failures for 658-fp-read-barrier. 2. WaitForSuspendBarrier seems to time out occasionally, possibly spuriously so. We fail when the futex times out once. That's probably incompatible with the app freezer. We should retry a few times. Change-Id: Ibd8909b31083fc29e6d4f1fcde003d08eb16fc0a
2023-12-19Revert^16 "Thread suspension cleanup and deadlock fix" Hans Boehm
This reverts commit a43e67ea1a314e5c6faf77457ffc5ea39c24d4ca. PS1 is identical to aosp/2725875 . PS2 improves static and dynamic lock checking and makes the documentation more precise. ThreadList::Unregister for a thread that wasn't registered becomes fatal; I can't convince myself that any reasonable recovery is possible, and we could otherwise turn an obvious error into a very subtle and potentially dangerous one. Perhaps controversially, we now REQUIRE thread_list_lock_ for IncrementSuspendCount, eventhough that requires a kludge in the one case in which we legitimately don't have it. But after thinking about it, the extra checking and documentation outweighs the kludge, and we may want to consider this elsewhere as well. Added FakeMutexLock to enable the kludge here and elsewhere. PS3 adds some documentation for thread lifetime rules and enforces a sufficient, though in some cases overly strong, set of related restrictions for EnsureFlipFunctionStarted. It ensures that callers conform to this stronger restriction. This required a simplification in StackUtil::GetThreadListStackTraces. PS4 Fix lint issue. Add Thread lifetime DCHECK to WaitForFlipFunction. Rebase to adjust for the fact that aosp/2813551 effectively merged a small piece of this. PS5 Add Thread::VerifyState(). We previouslly checked for kTerminated in a couple of places. That doesn't make sense, since we have no way to tell whether the thread has been deallocated and reallocated at that point. Instead of checking that the state is not kTerminated, just check that it is a sane value. Address some old reviewer comments. Add more output for EnsureFlipFunctionStarted DCHECK. RequestSynchronousCheckpoint now aborts rather than returning false when invoked on a terminated thread. Seeing kTerminated would mean the thread could have been destroyed, and thus this call was unsafe. PS6 Add another VerifyState call to RequestSynchronousCheckpoint. PS7 Rebase and add more ThreadExitFlag tests. PS8 Rebase. Temporary workaround for compile error. PS9 Remove PS8 workaround. Add a version of GetPeerFromOtherThread that expects thread_list_lock_ to be initially held, and relies on ThreadExitFlag to detect terminated threads. Modify several jvmti clients to use this correctly. This effectively includes a fixed version of aosp/2847246. PS10 Work around the fact that GetReferenceKind in ti_heap.cc may call GetPeerFromOtherThread with or without thread_list_lock_. I think this is kind of benign, though it makes reasoning harder, and weakens our debug checking. PS11 Remove extra semicolon. PS12 Add another DCHECK in UnregisterThreadExitFlag. PS13 Minor tweaks to address reviewer comments. PS14 More tweaks to address reviewer comments. PS15 Do not report that a thread exited while its flip-function is still running. PS16 Fix comment typo. Test: Treehugger Bug: 240742796 Bug: 203363895 Bug: 238032384 Bug: 253671779 Bug: 276660630 Bug: 295880862 Bug: 294334417 Bug: 301090887 Bug: 313347640 (and more) Change-Id: I44caa30a0a4da8ab105fedd4d2238f59efc1d675
2023-12-14riscv64: Fix wrong sign-extension for references. Vladimir Marko
Test: Modify kPreferredAllocSpaceBegin = 0x90000000, then testrunner.py --target --64 --ndebug --optimizing Bug: 283082089 Change-Id: Ifb82d616a0d9664a2e7f5f96a1a79ddce5862cdf
2023-11-07Change JNI `ArgumentScratchRegisters()` implementations. Vladimir Marko
Always return the same scratch registers, regardless of the return type. This helps making more JNI stubs identical for better reuse, such as deduplicating them in oat files. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: testrunner.py --target --optimizing Bug: 288983053 Change-Id: I7e7cebde1555de5a9d36e2bfca539a3bb918e6fa
2023-11-02Clean up `gUseReadBarrier` uses in JNI compiler. Vladimir Marko
Also clean up `gUseReadBarrier` uses in dex2oat/ and move some host tests to `art_compiler_host_tests`. Test: m test-art-host-gtest Bug: 289805127 Change-Id: I0909480d3346a611e4b1dd066d7484a9656ec890
2023-10-30Replace `gUseReadBarrier` with compiler option in compiler. Vladimir Marko
Leave a few `gUseReadBarrier` uses in JNI macro assemblers. We shall deaal with these later. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: run-gtests.sh Test: testrunner.py --target --optimizing Bug: 289805127 Change-Id: I9d2aa245cee4c650129f169a82beda7dc0dd6a35
2023-09-09Revert "Revert^14 "Thread suspension cleanup and deadlock fix"" Hans Boehm
This reverts commit f9fdd3ce0180972dc8d4f0c8410ea7702828a703. Reason for revert: Very suspicious host-x86_64-debug failure on LUCI. Change-Id: Ia01dd3df8d64d6bc0d12319b06a8380f64a46785
2023-09-09Revert^14 "Thread suspension cleanup and deadlock fix" Hans Boehm
This reverts commit 2a52e8a50c3bc9011713a085f058130bb13fd6a6. PS1 is identical to aosp/2710354. PS2 fixes a serious bug in the ThreadExitFlag list handling code. This didn't show up in presubmit because the list rarely contains more than a single element. Added an explicit gtest, and a bunch of DCHECKS around this. PS3 Rebase and fix oat version. Once more. PS4 Weaken CheckEmptyCheckpointFromWeakRefAccess check to allow weak reference access in a checkpoint. This happens via DumpLavaStack -> ... -> MonitorObjectsStackVisitor -> ... -> FindResolvedMethod -> ... -> IsDexFileRegistered. I haven't yet been able to convince myself that this is inherently broken, though it is trickier than I would like. PS5 Move cp_placeholder_mutex_ declaration higher in thread.h. Test: m test-art-host-gtest Change-Id: I66342ef1de27bfa0272702b5e1d3063ef8da7394
2023-08-24Revert "Revert^12 "Thread suspension cleanup and deadlock fix"" Hans Boehm
This reverts commit 996cbb566a5521ca3b0653007e7921469f58981a. Reason for revert: Some new intermittent master-art-host buildbot failures look related and need investigation. PS2: Fix oat.h merge conflict by not letting the revert touch it. PS3: Correct PS2 to actually bump the version once more instead. Change-Id: I70c46dc4494b585768f36e5074d34645d2fb562a
2023-08-23Revert^12 "Thread suspension cleanup and deadlock fix" Hans Boehm
This reverts commit b6f3b439d4f12e89393ba8101eea8671c94ba237. PS1: Identical to aosp/2652371 . PS2: Introduce kSuspensionImmune to disable suspension of a thread that is being relied upon to execute ResumeAll(). This replaces the test in SuspendAll() to check whether the caller was being asked to suspend itself. That test was deadlock-prone, since a SuspendAll request from e.g. the GC to block, and GC progress might be required to resume the thread running the GC. Since SuspendAll() now only loops for a single reason, we no longer need to track why we looped. Reduce the number of iterations in each 129-ThreadGetId thread drammatically. PS3: Address reviewer comments, including fixing a newly introduced bug in CheckSuspend(). Fix 129-GetThreadId by drammatically reducing the iteration count when we appear to be running slowly, which is normally the case for gcstress. Earlier versions of this CL were apparently also failing on this test, but the failure was hidden by other failures. This mostly undoes the PS2 change to this test, now that the failure is better understood. PS4: Rebase. PS5: Fix 129-GetThreadId code formatting. PS6: Address more reviewer comments related to 129-GetThreadId. PS7: Remove DCHECK in EnsureFlipFunctionStarted. It was unsafe, since the thread may no longer be around. Test: Treehugger. Bug: 240742796 Bug: 203363895 Bug: 238032384 Bug: 253671779 Bug: 276660630 Bug: 295880862 Bug: 294334417 (and more) Change-Id: I99260fdc4feb9bcdc8b8b566e40912532f1a4937
2023-08-15Revert "Revert^10 "Thread suspension cleanup and deadlock fix"""" Hans Boehm
This reverts commit 2caa640269faabd2455ec29cfe6ad330d442b715. Reason for revert: It looks like there may be some new timeout failures on the master-art-host buildbot. I'll go ahead and generate a revert. Please submit once there are enough failures to investigate. Change-Id: I272e4ac5f4367a12a2eb027e456d789e8fd26ae6
2023-08-14Revert^10 "Thread suspension cleanup and deadlock fix""" Hans Boehm
This reverts commit 63af30b8fe8d4e1dc32db4dcb5e5dae1efdc7f31. master (aosp/2530206) PS1 is identical to aosp/2377951 . master (aosp/2530206) PS2 is a rebase. At this point, master branch was replaced by main, and this CL moved. PS1: Restructure documentation for the IncrementSuspendCount handshake to install a suspend barrier. Document a couple of additional mutator lock assumptions. Add some DCHECKs to check that suspended threads really are suspended. Weaken seq_cst memory order in a couple of places where it really didn't make sense here. Clearly not a correctness fix. Includes a rebase and merge with aosp/2587606. PS2: Another rebase. Fix thumb assembler test to compensate for Thread structure layout changes. PS3: Messy rebase, primarily to handle aosp/2670108, which included both new fixes around this and a few small snippets of this CL. Call EnsureFlipFunctionStarted without a state-and-flags argument only when we actually hold the mutator lock, as promised. PS4: Minor rebase, some lint fixes. PS5: Another minor lint fix that I had missed in PS4. PS6: Fix for RunCheckpoint bug introduced around PS3. Fix expectations in jni_cfi_test to compensate for thread structure layout changes. PS7: In PS3+, EnsureFlipFunctionStarted could access a destroyed "this" thread. Fix that, and make the function static to make this constraint more explicit. (And running a method on a potentially destroyed object just seemed unclean.) PS8: Address reviewer comments. The major issue was that we released the suspend_count_lock too early in FlipThreadRoots, potentially allowing an intervening SuspendAll to block us. The fix involved a very minor extention of the mutex API. PS9: Comment typo fix. PS10: Address new reviewer comments. Rebase. MUST_SLEEP for 129_ThreadGetId debug output. Test: Treehugger. Bug: 240742796 Bug: 203363895 Bug: 238032384 Bug: 253671779 Bug: 276660630 (and more) Change-Id: I0f2450e394c03c17eece3698286b2f3e45727967
2023-06-29riscv64: Enable JNI compiler. Vladimir Marko
Implement the required `WriteCIE()`, fix a bug in the `art_jni_dlsym_lookup_critical_stub`, fix reference loads to be zero-extended and enable the JNI compiler for riscv64. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: run-gtests.sh Test: testrunner.py --target --64 --ndebug --prebuild --no-prebuild -t 178 Test: # Edit `run-test` to disable checker, then testrunner.py --target --64 --ndebug --cdex-none --optimizing # 7 tests fail (pre-existing failures): 004-StackWalk, 137-cfi, # 2042-reference-processing, 597-deopt-busy-loop, 629-vdex-speed, # 638-checker-inline-cache-intrinsic and 661-oat-writer-layout. Test: aosp_cf_riscv64_phone-userdebug boots without crashes. Bug: 283082089 Change-Id: Ifd47098b7428919b601dd22a130ad1bd51ae516d
2023-06-27riscv64: Implement JNI compiler for normal native. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: run-gtests.sh Bug: 283082089 Change-Id: I2d6e8d029a74004076b6d514205a147ce1145f03
2023-06-22riscv64: Fix FP argument passing in GenericJNI. Vladimir Marko
Test: run-gtests.sh Bug: 271573990 Change-Id: I028ac0431ef7b809a49f9b7c78c50003820329d7
2023-06-22riscv64: Clean up `Riscv64JNIMacroAssembler::MoveArguments()`. Vladimir Marko
Change `Riscv64JNIMacroAssembler::MoveArguments()` to delay creating `jobject`s and remove some code that is effectively dead due to the calling convention. Add tests that exercise all the code paths in this function. Add some missing `HIDDEN` annotations on `namespace art`. Remove FIXME for NaN-boxing FP args passed in GPRs. This was based on a misreading of the C/C++ calling convention. Test: m test-art-host-gtest Test: run-gtests.sh Bug: 283082089 Change-Id: Ifaba892a7d66707df03422b59ca171aebc91edf0
2023-06-21riscv64: Implement JNI compiler for @FastNative. Vladimir Marko
Implement all JNI macro assembler functions needed by the JNI compiler to compile stubs for @FastNative methods. Enable JNI compiler tests for @FastNative methods. Test: m test-art-host-gtest Test: run-gtests.sh Bug: 283082089 Change-Id: I34ccc3a89de4833a18e2140b656e251a354fec01
2023-06-21riscv64: Implement `art_jni_dlsym_lookup_critical_stub`. Vladimir Marko
Test: run-gtests.sh Bug: 283082089 Change-Id: I96c7ff79278f7563c1c2cbc10258f6862fc27111
2023-06-21Remove CodeAllocator and the extra copy of generated code. Nicolas Geoffray
The code used to copy the final generated code twice: from assembler to CodeAllocator, and then to CodeAllocator to SwapAllocator/JitMemory. The assemblers never depended on the exact location of the generated code, so just drop that feature. Test: test.py Change-Id: I8dc82e4926097092b9aac336a5a5d40f79dc62ca
2023-06-15riscv64: Implement JNI compiler for @CriticalNative. Vladimir Marko
Implement all JNI macro assembler functions needed by the JNI compiler to compile stubs for @CriticalNative methods. Enable most JNI compiler tests for @CriticalNative methods and document the reasons for keeping the remaining few tests disabled. Change `Riscv64Assembler::AddConst*` to store intermediate results in `TMP` to avoid unaligned SP in the middle of a macro operation. Test: m test-art-host-gtest Test: run-gtests.sh Bug: 283082089 Change-Id: I226cab7b2ffcab375a67eb37efdd093779c5c8c4
2023-06-13riscv64: Add JNI calling convention. Vladimir Marko
Test: m test-art-host-gtest Bug: 283082089 Change-Id: Ie088ad01f6170ecea9c96c10199cc7efd722210c
2023-05-22Use C++17's [[maybe_unused]] attribute in ART Stefano Cianciulli
Bug: 169680875 Test: mmm art Change-Id: Ic0cc320891c42b07a2b5520a584d2b62052e7235
2023-05-04Reland "Support FastVerify with speed-profile." Nicolas Geoffray
This reverts commit 4297f22d902cf156e14c330147215d5f2fa9bd7f. Bug: 279728780 Reason for revert: Resolve classes in inliner. Change-Id: I4f93ac5d195eb2f473ec50fe7cc70881dcddee6f
2023-05-03Revert "Support FastVerify with speed-profile." Santiago Aboy Solanes
This reverts commit 1c262ad3f1fd9f9b07d16afe70990cd8bfdc3bda. Reason for revert: CHECKer failures e.g. https://ci.chromium.org/ui/p/art/builders/ci/host-x86-cms/8703/overview Change-Id: I48fd251a52b5f18e3ea192bc2102df509d578aaf
2023-05-03Support FastVerify with speed-profile. Nicolas Geoffray
Tweak a few compiler behavior to make it work and match test expectations. Test: test.py Bug: 279728780 Change-Id: I350ff313ca53e2c19b637af7521683cc2b09d66f
2023-05-02riscv64: disable gtests for unsupported components. Ulya Trafimovich
Bug: b/271573990 Test: gtests on host: lunch aosp_riscv64-userdebug && m test-art-host-gtest Test: gtests on target (on a Linux RISC-V VM): lunch aosp_riscv64-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 art/tools/run-gtests.sh Change-Id: I278e3453406a91a5e9d03645cafb9a9d1f82d896
2023-04-04JNI: Fast-path for decoding returned jobject. Vladimir Marko
Results for the timeGetBytesAscii#EMPTY benchmark from the libcore's StringToBytesBenchmark suite on blueline-userdebug with the cpu frequencies fixed at 1420800 (cpus 0-3; little) and 1459200 (cpus 4-7; big): 32-bit little: ~415 -> ~390 64-bit little: ~415 -> ~390 32-bit big: ~180 -> ~170 64-bit big: ~180 -> ~170 Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --debug --ndebug Test: run-gtests.sh Test: testrunner.py --target --optimizing --debug --ndebug Bug: 172332525 Change-Id: I0e19d583e5141e99a8b8c6fd9ae125fe7c9e02e7
2023-02-03riscv64: add missing UNUSED annotations. Ulya Trafimovich
The code compiles on other architectures that implement JNI compiler, because they use these variables. However the code won't compile for RISC-V as it falls into the default (unsupported) case. Test: lunch aosp_riscv64-userdebug && m dist Change-Id: I16010e806fe6c51fb0a7a20111e0d1feefde018c
2023-01-17Cleanup instrumentation_levels and instrumentation_stubs_installed Mythri Alle
We had instrumentation_levels and instrumentation_stubs_installed which were kind of similar but slightly different in what they actually represent. Their meaning also changed with the recent changes to avoid instrumentation stubs. They were used sometimes incorrectly in the code. This CL: 1. Renames instrumentation_stubs_installed to run_exit_hooks 2. Renames the instrumentation level to not refer instrumentation stubs 3. Fixes a few places that should have checked for the instrumentation level but checked for instrumention_stubs_installed. Bug: 206029744 Test: art/test.py Change-Id: I20a6e9442661a6465c92321904c846d35ebb1e53
2022-12-02Remove class root duplicates from well known classes. Vladimir Marko
And get well known exception classes as declaring classes of their constructors. Also change function `ThreadForEnv()` to `Thread::ForEnv()` and use it where appropriate, mostly in code added recently while cleaning up well-known methods. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I2ededa429863a6cddbcbb879a223277fd6245557
2022-11-16Make compiler/jni/ symbols hidden. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I04dc99e1491219442ba128f57a08112ae4783b92
2022-11-04Update method exit hooks from JITed code to not use Stack visitor Mythri Alle
Using NthCallerStackVisitor is expensive since that involves decoding method header and other tasks that are reasonably expensive especially when called on every method exit. When calling method exit hooks from JITed code a lot of this information like the frame_size, calling method are already known and can be directly passed to the method exit hook instead of computing them. Locally this change improves the performance by 70% on debuggable-cc config of golem benchmarks. Bug: 253232638 Test: art/test.py Change-Id: I3a1d80748c6d85e5fa1d3bd4aec0b29962ba0156
2022-10-24Call method entry hooks only when we have method entry listeners Mythri Alle
We don't need to anything when there are no method entry listeners on method entry. So tighten the check so we call method entry hook only when method entry listeners are installed. Earlier, we used to call whenever the stack is instrumented or instrumentation stubs are installed. Drive by fix: remove unused constant from runtime.def Bug: 253232638 Test: art/test.py Change-Id: I6bdb4207804fd9c79fd7f21500c00b47e12beef3
2022-10-17Revert^2 "Don't wait with mutator lock"" Hans Boehm
This reverts commit f2298b784e3b57905fdc4eb720df54cb2a257a23. PS1 is the same as aosp/2199339 PS2 fixes a bug in CompileForTest that caused failures in MakeInitializedClassesVisiblyInitialized. Due to incomplete stack traces, it is unclear whether this was the only cause of failures. It also adds a check in DoCompilation that may help with tracking down others. PS3-4 fix a code typo and the commit message. PS5 adds a thread suspension around the call to MakeInitializedClassesVisiblyInitialized in EnterTransactionMode. PS6 fixes a small problem with the PS5 change. PS7 was an incorrect attempt to undo PS5 and PS6 and instead weaken the assertion in MakeInitializedClassesVisiblyInitialized. PS8 redoes this correctly by just not checking for the EnterTransaction call. This is a stopgap, since PS5 results (not entirely unexpectedly) in heap posisoning failures. PS9 also disables checking inside ClassLinkerTest::AssertObjectClass. Test: Build and boot AOSP. Bug: 243086427 Bug: 253691761 Change-Id: I3673b0cbee4b156338088d9783269dc2a0388cba
2022-08-10Fix gtest failures due to userfaultfd GC Lokesh Gidra
Mostly involved replacing compile-test check for read-barrier with runtime one. Bug: 160737021 Test: art/test/testrunner/run_build_test_target.py -j <core-count> art-test Change-Id: I685e4b717d314a19f7714ece5c8b84f23154cc66
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-07-14Reland "Introduce a flag to check if JITed code has instrumentation support" Mythri Alle
This reverts commit 26aef1213dbdd7ab03688d898cf802c8c8d7e610. Reason for revert: Relanding after a fix. When checking if the caller is deoptimizaeble we should consider the outer caller and not the inlined method that we could be executing currently. Bug: 222479430 Change-Id: I37cbc8f1b34113a36a92c3801db72b16d2b9c81a
2022-07-13Revert "Introduce a flag to check if JITed code has instrumentation support" Mythri Alle
This reverts commit fc067a360d14db5f84fd4b58e0dee6cb04ee759b. Reason for revert: test failures on jit-on-first-use: https://android-build.googleplex.com/builds/submitted/8821659/art-jit-on-first-use/latest/view/logs/build_error.log Change-Id: Ie9bc243baac777ecc4f47cc961494ca6ab3ef4c6
2022-07-12Introduce a flag to check if JITed code has instrumentation support Mythri Alle
Introduce a new flag to identify if JITed code was compiled with instrumentation support. We used to check if the runtime is java debuggable to check for instrumentation support of JITed code. We only set the java debuggable at runtime init and never changed it after. So this check was sufficient since we always JIT code with instrumentation support in debuggable runtimes. We want to be able to change the runtime to debuggable after the runtime has started. As a first step, introduce a new flag to explicitly check if JITed code was compiled with instrumentation support. Use this flag to check if code needs entry / exit stubs and to check if code is async deoptimizeable. Bug: 222479430 Test: art/test.py Change-Id: Ibcaeab869aa8ce153920a801dcc60988411c775b
2022-07-06Reland^2 "Don't use instrumentation stubs for native methods in debuggable" Mythri Alle
This reverts commit 1d1d25eea72cf22aed802352a82588d97403f7b6. Reason for revert: Relanding after fix to failures: https://android-review.googlesource.com/c/platform/cts/+/2145979 Bug: 206029744 Change-Id: Id3c7508c86f9aeb0ddfc1c4792ed54f003b88e77