summaryrefslogtreecommitdiff
path: root/compiler/optimizing/inliner.cc
AgeCommit message (Collapse)Author
2025-02-18Do not inline a method that was marked as un-compilable. Nicolas Geoffray
The compiler may have internally mark a method as not compilable. Do not clear the verification results from the compiler callbacks, we still need them during compilation. Test: 860-vdex-failure Bug: 395243275 Change-Id: I79ba61eb8a7ba6729b22c4c27fa83d8373fce03a
2025-01-21Add new WellKnownClasses fields to avoid harcoded constants. Nicolas Geoffray
Test: test.py Change-Id: I3a065dd5582269792032df0c6446c3c4b6cd72be
2025-01-16Merge sFields and iFields. Nicolas Geoffray
Test: test.py Change-Id: Ib97fca637a8866a41a4389b150c6000d9fb6d99b
2024-12-19Add back a test that was missed from a previous CL. Nicolas Geoffray
CL aosp/3370562 refactored method resolution but accidentally removed an ICCE check. Test: 733-icce Bug: 381631627 Change-Id: Ic9ad2f13053c0c81844ee09ed12a99a9fe9b8b99
2024-11-21Allow the inliner to devirtualize intrinsics Santiago Aboy Solanes
To do so update: * TryReplaceStringBuilderAppend * Code paths relevant to previously InvokeVirtual that are now InvokeStaticOrDirect * checker tests. Bug: 369206455 Test: art/test/testrunner/testrunner.py --host --64 -b --optimizing Change-Id: I4d40980e416f3130d3c344c5f07b7b331deb5c97
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-10-22Fix marking methods as always throws Santiago Aboy Solanes
Bug: 373867314 Fixes: 373867314 Test: art/test/testrunner/testrunner.py --host --64 -b --optimizing Change-Id: I18b5e03021e6eec841050bd39c79480c0378dda2
2024-10-17fix inliner bug wangmingming1
I see field index of a class member variable is 0xFFFF which will cause TryPatternSubstitution throw away the iput-xxx instruction ```code void zyb.<init>(com.mi.fitness.netproxy.NetProxyManager) (dex_method_idx=20258) DEX CODE: 0x0000: 7010 273f 0000 | invoke-direct {v0}, void java.lang.Object.<init>() // method@16167 0x0003: 5b01 ffff | iput-object v1, v0, Lcom/mi/fitness/netproxy/NetProxyManager; zyb.a // field@65535 0x0005: 0e00 | return-void ``` Bug: 368471540 Test: the above bug doesn't reproduce Change-Id: I6bee31e07e17982e00e0e22d476a36f554081c3d Signed-off-by: wangmingming1 <wangmingming1@xiaomi.com>
2024-10-11Refactor `HandleCache` out of `nodes.{h,cc}`. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I4989657309b46c1e8fec3e9eb4024f1fc329fbe0
2024-10-11Do not record dex PC in constant HIR. Vladimir Marko
Due to the dedplication of constants, the dex PC can be useless or even misleading. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I501abc3cca920415b3118e92b06a01b173b2406a
2024-10-07Reland "Calculate the number of out vregs." Vladimír Marko
This reverts commit 434a327234f74eed3ef4072314d2e2bdb73e4dda. Reason for revert: Relanding with no change. The regressions that were the reason for the revert may reappear. However, these regressions are probably caused by subtle effects that are not directly related to this change. For example, a code size improvement can regress performance simply by moving the start of a loop from an aligned address to an unaligned address, or by splitting a loop across two cache lines. Bug: 358519867 Bug: 359722268 Change-Id: I997b8a4219418f79b3a5fc4e7e50817911f0a737
2024-09-02cleanup: change Set/GetIntrinsic in ArtMethod to use Intrinsics Santiago Aboy Solanes
Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: I253a6bfe6bba7e02e527722c4632cb60938fe1c6
2024-09-02Don't devirtualize to an intrinsic invalid after the builder phase Santiago Aboy Solanes
As a drive-by, print the intrisic itself and not its index in graph_checker.cc. Bug: 362091596 Test: Compile the app in the bug Change-Id: I55c857f193d334d1a40cac637dfedf6334522f00
2024-08-21Revert "Calculate the number of out vregs." Vladimír Marko
This reverts commit 3e75615ad25b6af1842b194e78b429b0f585b46a. Reason for revert: Regressed some micro-benchmarks, see bug 359722268. Bug: 358519867 Bug: 359722268 Change-Id: I207cc78c88193564e90c98eda2c96a5ba354a588
2024-08-13Calculate the number of out vregs. Vladimir Marko
Determine the number of out vregs needed by invokes that actually make a call, and by `HStringBuilderAppend`s. This can yield smaller frame sizes of compiled methods when some calls are inlined or fully intrinsified. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 358519867 Change-Id: I4930a9bd811b1de14658f5ef44e65eadea6a7961
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-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-12Remove default cases when all cases are defined Santiago Aboy Solanes
Bug: 328756212 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Test: m test-art-host-gtest Change-Id: I9584e1b93e49265b84a9e45c8b283ebaf8ad3eb2
2024-03-07Inliner: Update instruction count for pattern substitution. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 181943478 Change-Id: I807ebb5b43117fa46fdbc80c605b525606d014cb
2024-02-29Inliner: Always try code pattern recognition. Vladimir Marko
Try code pattern recognition whenever we're allowed to inline. The pattern recognition is fast and when we find a match, we avoid costly processing, such as building the callee graph. The pattern replacement is always better than the invoke, so do it even when inlining is not "encouraged", for example in blocks that end with a `throw`. Reorder the code so that the pattern recognition respects the @NeverInline annotation. Enable run-test 569 for target and add a test for the @NeverInline annotation. Also remove some duplicated helper functions and reduce the number of arguments we pass around. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: testrunner.py --jvm Test: run-gtests.sh Test: testrunner.py --target --optimizing Bug: 181943478 Change-Id: I863fe1190eb38c7decf0c5e34a00c103e8e559f1
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-06CompilerOptions refactor after aosp/2808063 Santiago Aboy Solanes
* Updated comments * Made constants constexpr * Renamed kBaselineMaxCodeUnits to include "Inline" Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: I37569b3d9e5eecfd65a505a79945bbe5b290fbbf
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-23Fix crash when inlining intrinsics with specialized HIR Santiago Aboy Solanes
During the inliner phase if we recognize an intrinsic, we insert it. This is problematic since there are some intrinsics which we only expect during the instruction builder phase. This CL skips inlining those intrinsics. Potentially, we could generate the graphs for those intrinsics and inline it, but it needs refactoring of inliner.cc. Bug: 319045458 Fixes: 319045458 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Test: Locally compiling the app in the bug Change-Id: Ied3ec87e5655cec3bdfd978eb5c7411ddb102360
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-08Delay typing of guards with RTI in the inliner Santiago Aboy Solanes
There are some cases (e.g. polymorphic inlines) where we add a type guard while inlining. In those cases we ran RTI to properly type them. This CL delays that type propagation to when its needed, or at the latest at the end of HInliner::Run(). Bug: 317243144 Test: Compiling the app in the bug with dex2oatd Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: Id1656d39495387852f815a16d3e357376e1c7918
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-04Remove requirement that receiver must be exact for inlining. Nicolas Geoffray
We can still resolve to a final method and try to inline it. Test: test.py Bug: 316970619 Change-Id: Idd03622afc20322a4c5cf11e7c2d734dfdf72781
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-19Always pass the receiver type. Nicolas Geoffray
There were some missed opportunities when inlining, where we were not passing the type of the receiver, and so were not using it when doing local optimizations. Test: test.py Change-Id: I927be763590d7331db009a149090b7106a20b0db
2023-11-30Constant fold DivideUnsigned intrinsic Santiago Aboy Solanes
Bug: 309886589 Test: art/test/testrunner/testrunner.py --host --64 -b --optimizing Change-Id: If60ccbea30b3fe16b86c1630409b540b05b14c56
2023-11-13Clean up `HandleScope`. Vladimir Marko
Implement `Size()` and rename `NumberOfReferences()` to `Capacity()`. Replace `Capacity()` with `Size()` where appropriate, for example to avoid visiting unused slots. Remove some obsolete dead code and move some functions from `FixedSizeHandleScope<.>` to `HandleScope`. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I1e49fb6144f77692ff22c6fbd0578d995b5a01f1
2023-05-09Don't inline unresolved invokes Santiago Aboy Solanes
Bug: 280354288 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: I1652d3f310791036da5ae6ea36266ecb89aaa080
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-04-27Optimizing: Add `HInstruction::As##type()`. Vladimir Marko
After the old implementation was renamed in https://android-review.googlesource.com/2526708 , we introduce a new function with the old name but new behavior, just `DCHECK()`-ing the instruction kind before casting down the pointer. We change appropriate calls from `As##type##OrNull()` to `As##type()` to avoid unncessary run-time checks and reduce the size of libart-compiler.so. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: run-gtests.sh Test: testrunner.py --target --optimizing Bug: 181943478 Change-Id: I025681612a77ca2157fed4886ca47f2053975d4e
2023-04-27Optimizing: Rename `As##type` to `As##type##OrNull`. Vladimir Marko
The null type check in the current implementation of `HInstruction::As##type()` often cannot be optimized away by clang++. It is therefore beneficial to have two functions HInstruction::As##type() HInstruction::As##type##OrNull() where the first function never returns null but the second one can return null. The additional text "OrNull" shall also flag the possibility of yielding null to the developer which may help avoid bugs similar to what we have seen previously. This requires renaming the existing function that can return null and introducing new function that cannot. However, defining the new function `HInstruction::As##type()` in the same change as renaming the old one would risk introducing bugs by missing a rename. Therefore we simply rename the old function here and the new function shall be introduced in a separate change with all behavioral changes being explicit. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: buildbot-build.sh --target Bug: 181943478 Change-Id: I4defd85038e28fe3506903ba3f33f723682b3298
2023-04-27Reland "Don't enable intrinsic optimizations in debuggable runtime"" Mythri Alle
This reverts commit b5fcab944b3786f27ab6b698685109bfc7f785fd. Reason for revert: test/988 is a CTS test and we shouldn't modify the Main to do any real work other than calling run. Also there's no way to call ensureJitCompiled from atests, so restoring 988 to original and adding another test for testing JIT tracing Bug: 279547861 Test: test.py -t 988, 2263 Change-Id: I0908c29996a550b93ba6c38f99460ff0d51a2964
2023-04-25Revert "Don't enable intrinsic optimizations in debuggable runtime" Mythri Alle
This reverts commit cb008914fbc5a2334e3c00366afdb5f8af5a23ba. Reason for revert: Failures on some configs https://buganizer.corp.google.com/issues/279562617 Change-Id: I4d26cd00e76d8ec4aef76ab26987418eab24d217
2023-04-25Don't enable intrinsic optimizations in debuggable runtime Mythri Alle
We have optimizations that generate code inline for intrinsics instead of leaving them as invoke for better performance. Some debug features like method entry / exit or setting a breakpoint on intrinsics wouldn't work if intrinsics are inlined. So disable those optimizations in debuggable runtimes. Also update 988-method-trace test to test intrinsics on JITed code. Test: art/test.py -t 988 Bug: 279547861 Change-Id: Ic7c61d1b1541ff534faa24ccec5c2d0b574b0537
2023-04-05Clean up `IsZeroBitPattern(HInstruction*)` usage. Vladimir Marko
Remove duplicate helper function and use the existing function from `nodes.h` more. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: Ib0d3b9b12c6950f06843cd71039562c5d6e7e4cf
2023-04-04Inline unimplemented intrinsics Santiago Aboy Solanes
There are intrinsics that are unimplemented i.e. we didn't hand-craft code for them. Allow the inliner to inline those. Since our optimizations expect InvokeVirtual, I stopped the de-virtualization of intrinsics. That could be re-added if we modify optimizations like TryReplaceStringBuilderAppend. Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Test: art/test/testrunner/testrunner.py --target --64 --optimizing Test: compiling the APK in the bug and seeing the inline Bug: 262585898 Fixes: 262585898 Change-Id: I501b69c4ffd9082ca8ffacb1cd1cd5d1ab3668a8
2023-02-22Set more RTI only if they are valid Santiago Aboy Solanes
Follow-up to aosp/2442280. We haven't seen crashes with these ones, but we can't guarantee that the RTI will be valid in these code paths. Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: I80da85a6549ba0275a80027016363e0cf9fb8045
2023-02-20Don't set an invalid RTI in the inliner Santiago Aboy Solanes
In the inliner we were setting an RTI without checking if it's valid first. Since aosp/2433377 we shifted the responsibility to the user instead of checking that we always have a valid RTI. Bug: 269721624 Fixes: 269721624 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Test: dex2oat compiling the app in the bug Change-Id: I330504ad2802e8f8daaae1fffa1907d529b6f975
2023-01-12Set devirtualized methods as always throws if appropriate Santiago Aboy Solanes
If we devirtualize a method that throws given the parameters, then we should also set the devirtualization as always throws. Found while updating graph checker flags in aosp/2362044. Bug: 264278131 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: I5e65055f63a3a98d17d5a862b864832f904dc7c8
2023-01-11Swap optimizations when inlining Santiago Aboy Solanes
When we optimize a function we run: 1. Constant folding 2. Instruction simplifier 3. Dead code elimination Make the inliner use the same order of optimizations. Improvements are small but noticeable. Locally, Pixel 5 speed compile: * System server: -7.8KB (-0.02%) * SysUIGoogle: -3.9KB (-0.01%) * AGSA: -113KB (-0.03%) Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: If2eaf9b35b43f88c29093fcf9a9ba17da22d2535
2022-12-16Add irreducible loop check in CanInlineBody Santiago Aboy Solanes
In aosp/2335809 we moved splitting the critical edge (aka adding the extra goto) from the builder to InlineInto. We need to also move the irreducible loop check from there to inliner.cc. Bug: 262725735 Fixes: 262725735 Test: dex2oat compiling the apps in the bug Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: I94eebfb21cd94b1199ba996d458b897b7917840e