summaryrefslogtreecommitdiff
path: root/compiler/optimizing/optimizing_compiler.cc
AgeCommit message (Collapse)Author
2025-03-24Address review comments from aosp/2671457. Nicolas Geoffray
Test: test.py Change-Id: I5b6b667847727d4de3944467885576a15f72846f
2025-02-19[Sim] Add a restricted mode setup Chris Jones
This CL introduces a special ART setup for all modes (host, target), which is going to be a base for VIXL Simulator Stage 1 setup. This setup can be enabled by exporting ART_USE_RESTRICTED_MODE=true to the environment before building ART. The setup limits ART by doing the following: - Limits the GC to only non-concurent Mark&Sweep. - Turns off the Nterp (so only switch C++ intepreter to be used). - Turns off the JNI compiler (GenericJNITrampoline to be used). - Rejects the compilation of all method (except for the allow list). - Turns off compilation and support of intrinsics. - Turns off implicit null checks. - Turns off implicit suspend checks. - Turns off introspection entrypoints. - Turns off special behavior for critical native methods. - Turns off compiler CHECKER tool. With these limitations it will be easier to start off an initial Simulator Stage 1 setup. As the limitations are set for all the modes, it will be easy to compare/debug the workflow for the simulator mode and to compare it to host and target runs. The CL also adds sections in knownfailures.json for tests that fail in this special setup. Also cleanup some read barrier entrypoint declarations in entrypoints_init_arm64.cc to match the definitions in quick_entrypoints_arm64.S and slightly refactor Runtime::Init to stay below the 500 line limit. Author: Artem Serov <artem.serov@linaro.org> Artem Serov <artem.serov@arm.com> Chris Jones <christopher.jones@arm.com> Test: export ART_USE_RESTRICTED_MODE=true test.py --host --target Change-Id: I87319cf339646dc13b9086b00af08882b01603c8
2025-01-27Add a one-pass baseline compiler for arm64. Nicolas Geoffray
Currently handles 50% of methods by supporting methods that: - don't branch - don't have try/catch - don't have float/double - <= 8 registers - opcodes are const/invokes/iget/iput/const-string/new-instance/checkcast. Cost of compilation is 10 times less than current baseline compiler. Performance of generated code: jit-baseline-cc configuration shows no impact on go/lem Test: test.py Change-Id: I8c99b8a8a7552c09c900c5c3e831e8897aef73e5
2025-01-24Optimizing: Rename `HCodeFlowSimplifier`... Vladimir Marko
... to `HControlFlowSimplifier` because "control flow" is the correct technical term. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I2607ac699fa33c3e7ca7f54364e1e8497148412b
2025-01-17Optimizing: Rename `HSelectGenerator`... Vladimir Marko
... to `HCodeFlowSimplifier` in preparation for adding more optimizations to this pass. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: Icb05c3455d93a7b939f82ced9b08165e533bb21a
2024-11-05Rename ResolveMethodWithoutInvokeType and use it more. Nicolas Geoffray
Rename it to ResolveMethodId as a more precise name, and use it in places where that's the thing we need. Test: test.py Change-Id: I906371585e9fa208093eed9affba552fd135a184
2024-10-30Run RTP after GVN to remove more NullCheck instructions Santiago Aboy Solanes
After GVN, we deduplicate instructions and we might have more information regarding the nullability of the SSA variable. We can run RTP to insert the BoundType instructions, which will later be used by InstructionSimplifier to remove the NullCheck. RTP will be run conditionally, only if GVN did at least one replacement. It improves ~0.1% of odex size for speed compiled apps. Bug: 369206455 Test: art/test/testrunner/testrunner.py --host --64 -b --optimizing Change-Id: I0a4a104690b3fe9ac4118642ab9e9916dc30a9c5
2024-07-23Mark methods that failed compilation as kAccCompileDontBother Mythri Alle
We might fail to compile methods for several reasons like large methods, have invalid bytecode and others. There is no need to retry compilations on such methods since they will fail again. So mark such methods with kAccCompileDontBother. Bug: 350094426 Test: art/test.py Change-Id: I86b7b62bafcd4d4461cec2aa3459a50726043de7
2024-06-12Reland "Rewrite how we identify hot methods." Nicolas Geoffray
This reverts commit e5d59342bcfdb7f6d2e7d7b4a4ce8dd97ca39091. With this CL, startup methods which do not reach the JIT threshold will just be marked as startup. The compiler driver now decides whether they should be compiled. Reason for revert: Move the decision of compiling startup methods in the compiler driver. Change-Id: Iba8ac7f092e1ce0f412a579a93da57e82fdea4a6
2024-06-07Revert "Rewrite how we identify hot methods." Nicolas Geoffray
This reverts commit 85ee2c92239fbafc22c2c47b22faa817a0a4b034. Bug: 345267352 Reason for revert: b/345267352 Change-Id: If5b5057e86493aea97ed3ffd02d7069da0187ce7
2024-06-03Rewrite how we identify hot methods. Nicolas Geoffray
Use the kAccPreviouslyWarm as soon as a method gets scheduled for JITting. The profile saver now only uses that flag. For benefiting simplicity, deprecate the -Xps-hot-startup-method-samples flag (unused in the code base). Test: second run after speed-profile contains less JITting Bug: 333614471 Bug: 333701031 Change-Id: I2b846026f7d74d20ea761421b857db3834b3011c
2024-05-10Revert "Workaround for b/336842546" Nicolas Geoffray
This reverts commit a4ac01044c50f4da02c40b8da5520d2eb65b41d9. Bug: 336842546 Bug: 73760543 Reason for revert: Fix for the bug has been submitted. CL also has an issue with thread suspension. Change-Id: I06785d58f3e473a13e18876e481fff9118851f53
2024-05-03Workaround for b/336842546 Santiago Aboy Solanes
Resolve the type if it hasn't been resolved before. Also, change to use Handles instead of ObjPtr since ResolveType can potentially suspend. Bug: 336842546 Bug: 73760543 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: I8ad77e63d6d9cc76fee8aac88742d4a4b678abf5
2024-04-04Remove RegisterAllocator::Strategy Santiago Aboy Solanes
It has been obsolete since graph color was removed. Bug: 281793697 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Test: m test-art-host-gtest Change-Id: I8b42b0fe39a8601da7aa1288a8581ab8b4742614
2024-04-04riscv64: Create InstructionSimplifierRiscv64, ShiftAdd Anton Romanov
Create InstructionSimplifierRiscv64 optimization. Replace Shl (1|2|3) and Add with Riscv64ShiftAdd IR instruction. By compiling with dex2oat all the methods of applications below I got: Facebook: 45 cases TikTok: 26 cases YouTube: 19 cases of the pattern. Test: art/test/testrunner/testrunner.py --target --64 --ndebug --optimizing Change-Id: I88903450d998983bb2a628942112d7518099c3f5
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-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-13Reland "Only compile optimized if it is useful." Nicolas Geoffray
This reverts commit 35a1479ab434257e9db629fda5f4ca96bfbef3fc. Reason for revert: Disable failing test on debuggable Change-Id: Icd012ac9e3b37c1187adf5e915ba7c1ffc415805
2024-02-09Revert "Only compile optimized if it is useful." Nicolas Geoffray
This reverts commit e872656585952f993eb84633a66e0aedcbdf52ac. Reason for revert: Test failures Change-Id: I05aadb695b87f661063ff87f63eb68048d16e050
2024-02-08Only compile optimized if it is useful. Nicolas Geoffray
If profiling doesn't benefit the method, switch a baseline compilation into optimized. Reduces the number of JIT compilations on the Sheets benchmark from ~3100 (2250 baseline, 850 optimized) to ~2750 (2250 baseline, 500 optimized). Test: test.py Change-Id: I94760481d130d2dc168152daa94429baf201f66e
2024-02-05Make sure the frame size isn't unreasonably large when compiling Santiago Aboy Solanes
This CLs adds a check that we don't have an unreasonably large frame size, and bails out from the compile if we detect it. We had a similar check on RISC-V but not in other archs. Bug: 323309447 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: I4619dbbbc12c6e22ce335a17d15d90af8878808e
2024-01-30Reland^2 "Run optimizations with baseline compilation." Nicolas Geoffray
This reverts commit 3dccb13f4e92db37a13359e126c5ddc12cb674b5. Also includes the fix for incrementing hotness that got reverted: aosp/2906378 Bug: 313040662 Reduces jank on compose view scrolling for 4 iterations: - For Go Mokey: - Before: ~698 frames drawn / ~13.87% janky frames - After: ~937 frames drawn / ~5.52% janky frames - For Pixel 8 pro: - Before: ~2440 frames drawn / ~0.90% janky frames - After: ~2450 frames drawn / ~0.55% janky frames Reason for revert: Reduce inlining threshold for baseline. Change-Id: Iee5cd4c3ceb7715caf9299b56551aae6f0259769
2024-01-19Move files related to compiled code into oat/ directory Dmitrii Ishcheikin
Test: art/test.py -b --host Change-Id: Icedd3a82c6bca5147c3bc9dc50de5a729003d66f
2024-01-15Revert "Restrict the use of ConstantFolding's VisitIf" Santiago Aboy Solanes
This reverts commit 5eb1fd0dae3832ceee2102613bb08c291daca6f3. Reason for revert: In aosp/2903248 we implemented a faster way of doing `ReplaceUsesDominatedBy` which is used by `VisitIf`. The impact of `VisitIf` is now small enough that running VisitIf in all passes is faster that the previous implementation running some of the time. This CLs re-enables the optimization in all constant folding passes because: A) Lets this optimization (and others that can use the result) kick in earlier B) Run it for callee graphs in the inliner (which has been disabled as of CL aosp/2543831) C) Consistency of the ConstantFolding pass, which helps to have a simpler mental model Bug: 278626992 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Test: Locally compiled GMS and compared time to compile Change-Id: I5dc5f591557c8de0bc4d23dbfd0b91b5b7e56ab5
2024-01-15Revert "Reland "Run optimizations with baseline compilation."" Nicolas Geoffray
This reverts commit 1a6b5b318aa69903a74dd10312a77bd8ee7c4cf6. Reason for revert: asan failure Change-Id: Ie9da0b04c899d6cb37148e7a3542190e65737787
2024-01-05Reland "Run optimizations with baseline compilation." Nicolas Geoffray
This reverts commit c8309515d099992b7cab8f2b8c6db3ed77671ff4. Bug: 313040662 Reason for revert: remove call to slow path on back edges. Change-Id: I3fe52295afcb0be4b4062f8d9060adb4abb64375
2024-01-04Revert "Run optimizations with baseline compilation." Almaz Mingaleev
This reverts commit 41c5dde40d1c75d36a7f984c8d72ec65fbff3111. Reason for revert: breaks test.java.util.Arrays.Sorting Change-Id: I03385c9f1efff4b8e8bd315827dde6ed774bbb52
2024-01-03Run optimizations with baseline compilation. Nicolas Geoffray
And introduce inlined inline caches, which customize an inline cache for the top-level method being compiled. Reduces jank on compose view scrolling for 20 seconds: - For Go Mokey: - Before: ~525 frames drawn / ~14.64% janky frames - After: ~891 frames drawn / ~4.74% janky frames - For Pixel 8 pro: - Before: ~2443 frames drawn / ~0.91% janky frames - After: ~2447 frames drawn / ~0.65% janky frames Bug: 313040662 Test: test.py Change-Id: Ibaa746c6bd3c665b18ec9cd29cb477cf21023467
2023-12-19Reland "Move the construction of ProfilingInfo in the compiler." Nicolas Geoffray
This reverts commit 9fedb9f473fd77f31285203f5baa9533b8e21ce6. Reason for reland: - Use CodeGenerator::IsImplementedIntrinsic in IsInlineCacheUseful, to match inliner behavior. - Address some missing type propagation opportunities in aosp/2880687 - Be robust when there is a missing inline cache. Test: test.py Change-Id: Ib6e4a624174d6891a0fd425af88a9c16e09afa99
2023-12-15Revert "Move the construction of ProfilingInfo in the compiler." Javier Molina
This reverts commit d4faa43efb17e75fc99930f798103b29553a6a5e. Reason for revert: b/316397902 Test [v2/android-virtual-infra/avd/avd_boot_health_check] com.android.devicehealthchecks.SystemCheck#system_tombstone failing Change-Id: I5daee96d7c00de35fe6f403114c50dc6b6b85080
2023-12-14Move the construction of ProfilingInfo in the compiler. Nicolas Geoffray
This reduces the number of inline caches when the compiler can statically determine the target is fixed. The removal of some inline cache profiling also improves performance of compose scrolling. Jank data for 20 seconds, average of 50 runs: - For Go Mokey: - Before: ~485 frames drawn / ~17.02% janky frames - After: ~525 frames drawn / ~14.64% janky frames - For Pixel 8 pro: - Before: ~2433 frames drawn / 1.02% janky frames - After: ~2443 frames drawn / 0.91% janky frames Test: test.py Change-Id: Ide4fab058d55b65b66dcf10e835f05877e71b7fc
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-10-25riscv64: Add a "GVN$after_arch" pass. Vladimir Marko
This makes 3 previously failing checker tests pass. Test: testrunner.py --target --optimizing # Ignore 3 pre-existing failures (137-cfi and 2x checker). Bug: 283082089 Change-Id: Ie45a32fbdd5439e2abd123d83fc9992debae06f2
2023-10-24riscv64: Fix type conversions, enable codegen. Vladimir Marko
Enable codegen for all remaining instructions. Test: m # aosp_cf_riscv64_phone-userdebug Test: # Edit `run-test` to disable checker, then testrunner.py --target --64 --ndebug --optimizing --jit # Ignore pre-existing failures (optimzing: 3 -> 1, # jit: 18 -> 4). Bug: 283082089 Change-Id: I4dab3cdc49b9c979c97096d14db16007715bd05e
2023-10-23riscv64: Add entrypoints for unresolved fields. Vladimir Marko
And enable `*Unresolved*` instructions in codegen. Test: m # aosp_cf_riscv64_phone-userdebug Test: # Edit `run-test` to disable checker, then testrunner.py --target --64 --ndebug --optimizing # Ignore 3 pre-existing failures. Bug: 283082089 Change-Id: I04f23161d96f9eefdbe1e3b17ed0f7ae695deb07
2023-10-19riscv64: [codegen] Fix and enable InvokeCustom/-Polymorphic. Vladimir Marko
Test: m # aosp_cf_riscv64_phone-userdebug Test: # Edit `run-test` to disable checker, then testrunner.py --target --64 --ndebug --optimizing # Ignore 3 pre-existing failures. Bug: 283082089 Change-Id: I9802386b32fe6b98142454748404105e5b345c3b
2023-10-19riscv64: Implement `art_quick_check_instance_of`... Vladimir Marko
... and two other entrypoints. Enable codegen for several instructions and fix exposed new-array and proxy bugs. Test: m # aosp_cf_riscv64_phone-userdebug Test: # Edit `run-test` to disable checker, then testrunner.py --target --64 --ndebug --optimizing # Ignore 3 pre-existing failures (down from 6). Bug: 283082089 Change-Id: I7764fa1b578639d4871c11a79c3980defada3e7d
2023-10-19Reland "riscv64: [codegen] Rewrite and enable Select." VladimĂ­r Marko
This reverts commit 98c15524d7da162dd2571fbeed0e3d7c713a6b75. Reason for revert: Reland with a fix - delay `AsCondition()` call to avoid triggering a DCHECK(). Test: m # aosp_cf_riscv64_phone-userdebug Test: # Edit `run-test` to disable checker, then testrunner.py --target --64 --ndebug --optimizing # Ignore 6 pre-existing failures. Bug: 283082089 Change-Id: I5a270f23d43786e0b422f8fb697a7113c423f1d6
2023-10-19Revert "riscv64: [codegen] Rewrite and enable Select." Sebastian Pickl
This reverts commit 7b01eef7a1bb1f02a4388a3e2a12066af0f0ce92. Reason for revert: this change is breaking builds b/306335122 Bug:306335122 Change-Id: I5d7427ecc26a74f548229874a0c26e1e1a647abe
2023-10-19riscv64: [codegen] Rewrite and enable Select. Vladimir Marko
Test: # Edit `run-test` to disable checker, then testrunner.py --target --64 --ndebug --optimizing # Ignore 6 pre-existing failures. Bug: 283082089 Change-Id: I0486b89116755990ca1de0955d4a913f9cd893e8
2023-10-17riscv64: Implement `CriticalNativeAbiFixupRiscv64`. Vladimir Marko
And pass integral stack args sign-extended to 64 bits for direct @CriticalNative calls. Enable direct @CriticalNative call codegen unconditionally and also enable `HClinitCheck` codegen and extend the 178-app-image-native-method run-test to properly test these use cases. Test: # Edit `run-test` to disable checker, then testrunner.py --target --64 --ndebug --optimizing # Ignore 6 pre-existing failures (down from 7). Bug: 283082089 Change-Id: Ia514c62006c7079b04182cc39e413eb2deb089c1
2023-10-13riscv64: Implement allocation entrypoints. Vladimir Marko
Test: # Edit `run-test` to disable checker, then testrunner.py --target --64 --ndebug --optimizing # Ignore 7 pre-existing failures. Bug: 283082089 Change-Id: Ie5a874c5d3e03cec828fdfb471f0f96470b6c7e1
2023-10-12riscv64: [codegen] Implement method entry/exit hooks. Vladimir Marko
Test: testrunner.py --target --64 --jit --debuggable # Ignore 28 pre-existing failures (down from 50). Bug: 283082089 Change-Id: I4c96c847b6d4d34b31cd5ec4b9ebced683dd42a2
2023-10-11riscv64: Implement `art_quick_aput_obj`. Vladimir Marko
And enable some instructions in codegen, mainly `*Set`. Test: # Edit `run-test` to disable checker, then testrunner.py --target --64 --ndebug --optimizing # Ignore 7 pre-existing failures. Bug: 283082089 Change-Id: I4bbc213874317239851c1a9e01b0f86eda7c9da5
2023-10-02riscv64: [codegen] Implement Baker read barriers. Vladimir Marko
Implement codegen changes and entrypoints for Baker read barriers. Also implement resolution and initialization entrypoints and enable codegen for certain instructions to allow stress-testing the Baker read barrier implementation. Fix `CodeGeneratorRISCV64::Finalize()` to avoid finalizing the code twice. This double finaization bug was exposed by enabling compilation of some larger methods. Test: # Edit `run-test` to disable checker, then testrunner.py --target --64 --ndebug --optimizing # Ignore 7 pre-existing failures. Bug: 283082089 Change-Id: I55a128921b388fae1bf818bfbda0bcb18f6dbfb3
2023-09-08riscv64: [codegen] Add VisitNullCheck Vladimir Marko
Also enable codegen for NullCheck and fix related entrypoint issues. For now, this is using explicit null checks. Change the default value of the implicit null checks flag in the `CompilerOptions`. In `dex2oat` we expect the default value to be false and override it to true when needed by the selected architecture. This aligns with the behaviour in `Runtime` which is the source of this information for JIT. We do not change the default value for implicit stack overflow checks flag yet because it requires additional adjustments to avoid breaking certain gtests. Test: m test-art-host-gtest Test: aosp_cf_riscv64_phone-userdebug boots. Test: run-gtests.sh # Ignore pre-existing timeout in `TestImageLayout`. Test: testrunner.py --target --64 --optimizing # Ignore 49 pre-existing failures. Bug: 283082089 Change-Id: If663d3279da5e6c53669860cefa7185c53e7e146
2023-09-08riscv64: Fix VisitMin/-Max for FP args. Vladimir Marko
Test: testrunner.py --target --64 --optimizing -t 082 -t 083 Bug: 283082089 Change-Id: I35276dc86f00e0e4ee8208498e1cdc21b0ae510d
2023-09-06riscv64: Enable Optimizing compiler for invokes. Vladimir Marko
Enable InvokeVirtual, InvokeInterface, InvokeStaticOrDirect and a few other instructions. Note that this also enables some implemented intrinsics that were previously excluded. Test: aosp_cf_riscv64_phone-userdebug boots. Test: run-gtests.sh # Ignore pre-existing timeout in `TestImageLayout`. Test: testrunner.py --target --64 --ndebug --optimizing --jit # Ignore pre-existing failures (51 for --optimizing, # down from 58; 65 for --jit, down from 69). Bug: 283082089 Change-Id: I02a18e4ccf244205e78d6376cdaa6e32cf8c55e5
2023-08-30Move HasShouldDeoptimizeFlag from method header to CodeInfo. David Srbecky
We don't have room for the extra bit if the code size is greater than 1GB. Bug: 288215378 Bug: 288833213 Bug: 297093110 Test: ./art/test.py -b --host --64 Change-Id: I0070b270c7fe03f2f6fbb26223e78de41305c547
2023-08-24riscv64: Enable Optimizing compiler for more instructions. Vladimir Marko
And fix a bad DCHECK() in disassembler that failed for some checker tests. Test: run-gtests.sh # Ignore pre-existing timeout in `TestImageLayout`. Test: testrunner.py --target --64 --ndebug --optimizing --jit # Ignore flakes in 004-ThreadStress. Ignore pre-existing # failures (57 for --optimizing, down from 68; 98 for # --jit, down from 104). Bug: 283082089 Change-Id: I9aef19a0791afa231111d45409e775b394bff847