summaryrefslogtreecommitdiff
path: root/compiler/optimizing/instruction_builder.cc
AgeCommit message (Collapse)Author
2025-02-18Only locking error and runtime throws should retrigger verification. Nicolas Geoffray
This ensures the stability of the vdex file. Test: 412-new-array Change-Id: I73a6be0a46b6eb184ea127de720bfaf7104f3777
2025-02-17Optimizing: Speed up `HInstruction::Add{,Env}UseAt()`. Vladimir Marko
Avoid three dependent loads to fetch the allocator on the hot paths. Inline the `FixupUserRecordsAfter*UseInsertion()` loop and use the fact that it's known to execute exactly one or two iterations. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 181943478 Change-Id: I7fd4d48caebc6aeb13fb9a9f8146a06129c72b2e
2025-02-17Optimizing: Do not crash on bad `filled-new-array` opcode. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: testrunner.py --host --jit --jit-on-first-use -t 412 Change-Id: I8b86c806492b9b3ff44a2e670650e5ed18749190
2025-02-14verifier: Reject `filled-new-array/-range` with `[J`/`[D`. Vladimir Marko
We were not enforcing the specified requirement from https://source.android.com/docs/core/runtime/dalvik-bytecode for `filled-new-array/-range`. We now reject the descriptors `[J` and `[D` in the verifier and defer arrays of primitive types other than `[I` to the interpreter. All these cases would have previously hit a `DCHECK()` in the compiler. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: Iaf91465faa8ed9599abe2504796a2d9bc5bd4678
2025-01-16Merge sFields and iFields. Nicolas Geoffray
Test: test.py Change-Id: Ib97fca637a8866a41a4389b150c6000d9fb6d99b
2025-01-06Handle invoke-virtual targeting invokeExact gracefully. Almaz Mingaleev
The interpreter handles such invoke-virtual as if they are native method and executes MethodHandle_invokeExact, which throws UOE. Bug: 383057088 Test: ./art/test/testrunner/testrunner.py --host --64 -b --optimizing Test: ./art/test/testrunner/testrunner.py --host --64 -b --interpreter Change-Id: I4dd4dea46eddd2b26e5866c80548b530a603d9c9
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-28Refactor ResolveMethod. Nicolas Geoffray
Introduce ResolveMethodId and ResolveMethodWithChecks to make it more explicit at the call site. This also simplifies the implementation of ResolveMethodWithChecks. Also avoid creating handles in ResolveField when the dex cache already contains the field. Test: test.py Change-Id: Ie722c6d7ecadf7c6dbd780f0fc58dfae89140a01
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-10-04Reduce memory used by `HEnvironment`. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 181943478 Change-Id: Ie05d4001e411a669e11b8edda375414e5da52ae2
2024-09-25Revert^2 "Add VarHandle implementations for void getAndUpdate methods" Santiago Aboy Solanes
This reverts commit 8567fcdf972ade85785b689a15e3593a7d3bff9d. Reason for revert: RISC-V fix Test: LUCI run for RISC-V Change-Id: I6392bfa045e7737b5c45d78da4f7ecb8fbd3b89a
2024-09-25Revert "Add VarHandle implementations for void getAndUpdate methods" Ulya Trofimovich
This reverts commit 9ff2b617341bfe574e2d8706553f0cd65a1a2fc8. Reason for revert: failed ART test 712-varhandle-invocations on riscv64 `F dex2oat64: intrinsics_riscv64.cc:4821 Check failed: locations->GetTempCount() == 2u (locations->GetTempCount()=3, 2u=2)` Change-Id: I68a3830ccd730afa66e9cff277fe2a06829ddabe
2024-09-24Add VarHandle implementations for void getAndUpdate methods Santiago Aboy Solanes
We were missing to intrinsify getAndUpdate methods whose value was unused. By adding this support, they get a considerable runtime improvement. Bug: 362916226 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Test: art/test/testrunner/testrunner.py --host --32 --optimizing -b Test: art/test/testrunner/testrunner.py --target --64 --optimizing Test: art/test/testrunner/testrunner.py --target --32 --optimizing Change-Id: I63d5a897ac9ea3c133167ac186afd8595f75bb13
2024-09-24x86_64: Handle invoke-static in invokeExact fast path. Almaz Mingaleev
Bug: 297147201 Test: ./art/test/testrunner/testrunner.py --host --64 --optimizing -b Test: ./art/test.py --host -g Change-Id: Ia49285c116e4abfc3da2d78495f85d9131f111b5
2024-09-13riscv64: Add node Rol, fix InstructionBuilder Anton Romanov
This reverts commit 744830cb242c82c4637e6fb303b36d0371c84979. Reason for revert: updated CHECKer test to use rolw instead of rol. Change-Id: I50e34c6ac69488a9c083f04c6382df4302e8e7d3
2024-09-11Revert "riscv64: Add node Rol, fix InstructionBuilder" Nicolas Geoffray
This reverts commit 39927bc359ccbe65371213c4559126b05dcfb117. Reason for revert: Failure on bot with: error: Statement could not be matched starting from line 1089612 TestRotate.java:95: rol {{a\d+}}, {{a\d+}}, {{a\d+}} ISA_FEATURES = {'rv64gcv_zba_zbb_zbs': True} READ_BARRIER_TYPE = baker 567-checker-builder-intrinsics FAILED: [run-test:1074] CFG checker failed $ ssh -q -F /b/s/w/ir/cache/builder/art/test/testrunner/ssh_config -p 10001 ubuntu@localhost "rm -rf /home/ubuntu/art-test-chroot/data/run-test/test-343039" 567-checker-builder-intrinsics files deleted from host and from target ---------- test-art-target-run-test-ndebug-prebuild-optimizing-no-relocate-ntrace-cms-checkjni-picimage-ndebuggable-no-jvmti-567-checker-builder-intrinsics64 Change-Id: Ic1fd87c331c9eba315af6c98c3ad393766327417
2024-09-10riscv64: Add node Rol, fix InstructionBuilder Anton Romanov
Add new IR node Rol (rotate left). This allows to generate 1 (one) risc-v instruction from Integer(Long).rotateLeft intrinsic instead of 2 instructions (Ror+Neg). Fix InstructionBuilder: build Rol from rotateLeft instead of Ror+Neg. Add unfolding of Rol node in InstructionSimplifier(Arm, Arm64 and X86 Int64 type) to Neg+Ror. By compiling with dex2oat all the methods of applications below I got: in Facebook 1 Ror+Neg pattern, in Minecraft 5 Ror+Neg patterns. Test: art/test/testrunner/testrunner.py --target --64 --ndebug --optimizing Change-Id: Ic28610c6fab4f66386f2fbc0f7223ef2c0e644b6
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-02Address follow-up comments from aosp/2721077. Almaz Mingaleev
Bug: 297147201 Test: ./art/test/testrunner/testrunner.py --host --64 -b --optimizing Change-Id: Ie89d310633339b785de5d9f3daf653abfbff875c
2024-08-28x86_64: Add instrinsic for MethodHandle::invokeExact... Almaz Mingaleev
... which targets invoke-virtual methods. New entrypoint changes deliverException's offset, hence arm test change. Bug: 297147201 Test: ./art/test/testrunner/testrunner.py --host --64 -b --optimizing Test: ./art/test.py --host -g Change-Id: I636fc60c088bfdf9b695c92de47f1c539e3956f1
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-07-02Revert^4 "x86_64: Add JIT support for LoadMethodType." Almaz Mingaleev
This reverts commit b63adc919ba9a53f4fbad476356c702845821149. Bringing back map from ArtMethod to code pointers. Bug: 297147201 Test: CtsPerfettoTestCases Test: ./art/test/testrunner/testrunner.py --host --64 --jit -b Test: ./art/test/testrunner/testrunner.py --host --64 --jit --cms -b Test: ./art/test/testrunner/testrunner.py --host --64 -b Test: ./art/test.py --host -b Change-Id: I6a1c50598ec878393edf8ef895274da79d4ab42d
2024-06-24Revert^3 "x86_64: Add JIT support for LoadMethodType." Santiago Aboy Solanes
This reverts commit d92a43f4310e2d634d6e8f24103fc1e27557d784. Reason for revert: Failing 979-const-method-handle https://ci.chromium.org/ui/p/art/builders/ci/host-x86_64-cms/10095/overview Change-Id: I9b44d8cc66e98db074edfa90ce2ebab087e4b115
2024-06-21Revert^2 "x86_64: Add JIT support for LoadMethodType." Almaz Mingaleev
This reverts commit 69c9ea4f93a688ff50e08060be37bcfd3f3e9910. Instead of storing reversed method_code_map_, now just keep MethodType-s associated with a compiled code. Increasing constant in 979/Main.java to trigger jit more reliably. Bug: 297147201 Test: CtsPerfettoTestCases Test: ./art/test/testrunner/testrunner.py --host --64 --jit -b Test: ./art/test/testrunner/testrunner.py --host --64 -b Test: ./art/test.py --host -b Change-Id: I5ece80b63cd0d6dac2805c94649726dc62fe85db
2024-06-21Specify instruction format in `HInstructionBuilder`. Vladimir Marko
Even in cases where constant propagation to switch statement should reduce the inlined `Instruction::VReg{A,B,C}()` to the version with a specific format, clang++ is failing to optimize this properly. And there are builder functions that handle a known instruction format which are not inlined, so they are ineligible even if clang++ did optimize this. This simple change reduces the read/execute section in arm64 `libart.so` by almost 35KiB as seen with readelf -l [...]/libart.so | grep -E 'R E' (0x71a350 -> 0x711820). Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: Ia2d89fecef7fd8b8784fa7d6b0d2b8877501c629
2024-04-22Optimizing: Treat app image objects as non-movable. Vladimir Marko
Treat app image objects similar to boot image objects and avoid unnecessary read barriers for app image `HLoadClass` and `HInstanceOf` checks with app image `HLoadClass` input. Extend other optimizations to treat app image classes the same way as boot image classes even though this remains mostly dormant because we currently do not initialize app image classes with class initializers; the experimental flag `--initialize-app-image-classes` is false by default. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --speed-profile Bug: 38313278 Change-Id: I359dd8897f6d128213602f5731d40edace298ab8
2024-04-11Revert "x86_64: Add JIT support for LoadMethodType." Nicolas Geoffray
This reverts commit 53ca944020bb86199f6f80d8594d5deb1b1d46dd. Bug: 297147201 Reason for revert: Crash on bot Change-Id: Ibf3b53a8fe67aa633686990881a96acb783af9a3
2024-04-11Clean up string data access in `DexFile`. Vladimir Marko
The `*ByIdx()` and `*ByTypeIdx()` functions were doing validity checks that were needed only for processing the debug data, so move the checks to these callers. Replace these functions with new overloads of other functions to provide consistent naming. In a few cases, rewrite calls to these functions to fetch and work with a `string_view` instead. Rename `GetStringLength()` to `GetStringUtf16Length()` and change its return type to `uint32_t`. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I561899606f6e5ec5f23aa4be617349dacdb376e3
2024-04-11x86_64: Add JIT support for LoadMethodType. Almaz Mingaleev
In aosp/2876518 JIT code made runtime calls. Bug: 297147201 Test: ./art/test/testrunner/testrunner.py --host --64 --jit -b Test: ./art/test/testrunner/testrunner.py --host --64 -b Test: ./art/test.py --host -b Change-Id: Ifdfd3ace9419b34f8079c9ec4b1b2de31cb50ef7
2024-03-25Remove extra uses of ClearAllBits Santiago Aboy Solanes
ArenaBitVector creation guarantees it starts empty. Add a debug check to make sure this assumption doesn't change. Note that ArenaAllocator guarantees zero-initialized memory but ScopedArenaAllocators do not. This is fine either way since the BitVector constructor calls ClearAllBits. Bug: 329037671 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: Icbf5e5dd1869e80b5d5828ecca9f13de30c0242b
2024-02-14Move `JitOptions` to its own file. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --jit Change-Id: Id86a37ba6569b68487eb977df6656d4868255acc
2024-01-22Create list of intrinsics with specialized HIR. Vladimir Marko
Split the intrinsics list to differentiate intrinsics with and without HIR. Eliminate unreachable intrinsic functions for intrinsics with HIR. Test: m test-art-host-gtest Test: restrunner.py --host --optimizing Bug: 319045458 Change-Id: I6144ef6b6ec547c30f2911c41125a1f07f6f6d50
2024-01-19Move files related to compiled code into oat/ directory Dmitrii Ishcheikin
Test: art/test.py -b --host Change-Id: Icedd3a82c6bca5147c3bc9dc50de5a729003d66f
2024-01-03Revert^2 "x86_64: Store resolved MethodType-s in .bss." Almaz Mingaleev
This reverts commit d014fd019e84471665ac02f2de285541009892cd. Reason for revert: fix codegen to do runtime call in JIT for now. 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 Test: ./art/test/testrunner/testrunner.py --host --64 --jit -b Change-Id: I0f01c8391b09659bb6195955ecd8f88159141872
2023-12-21Revert "Use GetCurrentMethod to get the current method when tracing" Nicolas Geoffray
This reverts commit a4fd8bb141fdb877bfd0d69700dad4e2859634a7. Bug: 259258187 Reason for revert: Failures on bots: https://ci.chromium.org/ui/p/art/builders/ci/angler-armv8-non-gen-cc/3617/overview Change-Id: Ia4aa3532b137d9022853a9f82ef6bacc9246d0ce
2023-12-21Use GetCurrentMethod to get the current method when tracing Mythri Alle
The current method is passed in a register and we can use the GetCurrentMethod as an input to the method entry / exit hooks. In most cases we may just have the current method in the register on method entry. Bug: 259258187 Test: art/test.py Change-Id: Iea75f41b0ec5ebbc2aef857c84f39846b594e8e7
2023-10-17Add branch profiling in baseline compiler. Nicolas Geoffray
Currently unused. Follow-up CLs will make use of the data. Test: test.py Bug: 304969871 Change-Id: I486faba3de030061715d06ab9fdb33970d319d9b
2023-08-25Enable intrinsic optimization for polymorphic intrinsics Mythri Alle
Polymorphic invokes are expensive and some of the methods in Atomic* classes uses polymorphic methods. We use intrinsics to generate efficient code for them. Intrinsic optimization was disabled in debuggable runtimes to be able to support breakpoint in intrinsic functions. It might be less useful to break in such methods so we want to enable intrinsic optimization for polymorphic invokes which are performance sensitive. Bug: 296298460 Test: art/test.py Change-Id: I575695d82e8bc7d703cfbf5ff22ea7d5a35f6937
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-26Remove unnecessary `HInstruction::As##type()` calls. Vladimir Marko
Also so some style cleanup. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I34304acb39bc5197dde03543a6c157b3c319f94f
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
2022-11-08Minor nterp improvements. Vladimir Marko
Do not resolve primitive field types for iput*, sput* before updating the interpreter cache. Introduce and use `ArtMethod::IsStringConstructor(), a convenience helper function where we avoid a read barrier for checking if the declaring class is the `String` class. Change one `CHECK_LE()` to `DCHECK_LE()`. Test: testrunner.py --host --interpreter Change-Id: I17b0409cee5321e0ca389f053da1f767d2913d08
2022-11-07Reland "Make compiler/optimizing/ symbols hidden." Vladimír Marko
This reverts commit 0a51605ddd81635135463dab08b6f7c21b58ffb0. Reason for revert: Reland after some of the required work was merged in other CLs. Also address a TODO from the original CL to mark required symbols with EXPORT in `intrinsic_objects.h`. Also mark symbols in new files as HIDDEN. Bug: 186902856 Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I936d448983928af23614ca82c2d0bf9a645e2c52
2022-10-04Use ArtMethod::GetImtIndex to avoid recomputing the imt index. Nicolas Geoffray
Small inefficiency spotted when investigating b/249522283. Test: test.py Bug: 249522283 Change-Id: I96f7a141b2e3ad6669760e2f784a093ce58c277f