summaryrefslogtreecommitdiff
path: root/compiler/optimizing/intrinsics.cc
AgeCommit message (Collapse)Author
2025-02-28Remove `HInstruction::GetAllocator()`. Vladimir Marko
And clean up some uses of instruction->GetBlock()->GetGraph()->GetAllocator() Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: Iae218056495a0b9cf94d2a3c1cebd6c8eb909096
2025-01-23Address comments from aosp/3457760. Nicolas Geoffray
Test: test.py Change-Id: I48a9da7111d61762ab04d53c7efd689aad08f71b
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-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-30Revert^5 "Object.clone() allocates more movable objects" Nicolas Geoffray
This reverts commit ea269f69d05fe333e4b36634b925c3c40fc8ce95. Bug: 355291033 Bug: 354087169 Bug: 360363656 Bug: 361327909 Bug: 364629185 Reason for revert: Failure on asan: +addressOf succeeded on movable object +Unexpectedly got 0 address in checkMovable Change-Id: I1f27845bf3fb7a1542f24b943d999f2d4da5e23a
2024-09-26Revert^4 "Object.clone() allocates more movable objects" Hans Boehm
This reverts commit fc0ed57a5f25d8a7b3fbf200224bd880ed05eff5. PS1 is identical to aosp/3231043 PS2 adds 2280-address-of test, re-allows non-movable objects to be allocated in LOS, and more generally tracks non-movable objects in other spaces. PS3 Style tweak PS4 Disable test on jvm Bug: 355291033 Bug: 354087169 Bug: 360363656 Bug: 361327909 Bug: 364629185 Test: Build and boot AOSP Test: testrunner.py --host -b --all-gc -t 2280-address-of Change-Id: I4b2929c353a6ede916762de509056817f001d6f8
2024-09-03Revert^3 "Object.clone() allocates more movable objects" Pechetty Sravani (xWF)
This reverts commit 1956542906d0b128a86975af009ba4601d02129a. Reason for revert: Droid Monitor created revert due to this b/363849521. Change-Id: Ic56e46bc11b1fd696b82f29782a1d1735ee805a9
2024-08-30Revert^2 "Object.clone() allocates more movable objects" Hans Boehm
This reverts commit 7c89f49c2c542df1a5780fb851e2ef0e0909f48f. PS1 is identical to aosp/3200711. PS2 revises the approach a bit by continuing to allocate non-movable objects in LargeObjectsSpace, but tracking them explicitly in a renamed, and now lock-protected, data structure stray_non_movable_objects_, which explicitly tracks nonmovable objects in both zygote and large objects spaces. This was done after discovering that there are applications that allocate more than 64MB of mostly large DirectByteBuffers. Also modifies 070-nio-buffer to check that we can allocate lots of direct ByteBuffers. PS3-PS5 have minor tweaks (comments and slight code simplification). Bug: 355291033 Bug: 354087169 Bug: 360363656 Bug: 361327909 Test: Build and boot AOSP Test: testrunner.py --host -b --all-gc -t 070-nio-buffer Change-Id: Ia6948c516b30188934a644a3f8f788914dfabb2a
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-19Revert "Object.clone() allocates more movable objects" Hans Boehm
This reverts commit a5001fed23788c966fd87048d7f17ba8c0b51914. Reason for revert: b/360363656 Change-Id: Ibfea46976bb6434d728c69160edb5904ab7708aa
2024-08-14Object.clone() allocates more movable objects Hans Boehm
Make Object.clone() allocate an unmovable object only if the original was specifically allocated as nonmovable. Or at least get much closer to that. In the process, we stop allocated nonmovable objects in LargeObjectsSpace, so that we can better identifty them. Objects in image space cannot have been allocated as nonmovable: newNonMovableArray() involves JNI call, and this will cause a transaction failure. This is good, since the act of including the object in an ImageSpace would move it. The ZygoteSpace is allocated by copying objects into nonmoving space. To avoid having clone() treat the whole ZygoteSpace as nonmovable, we explicitly remember the non-class objects that were already there. Currently we use a std::set data structure for this. This seems a bit suboptimal; a sorted array may be an improvement. But empirically the set only contains a dozen or two elements for AOSP. We do implicitly allocate classes using the nonnmoving allocator. But those cannot be cloned. Thus we do not bother tracking them. For Array::CopyOf, we DCHECK that the argument was movable, and fix one of the callers to fail in a more appropriate way if we would otherwise violate that. Prevent jvmti from resizing a nonmovable array. I don't think anything good could have come of that anyway. This should prevent us from creating unrequested nonmovable objects, except as a result of the CC collector using that as a backup when it otherwise runs out of space during copying. Rename IsMovableObject() to somewhat clarify that it queries an implementation property, where IsNonMovable() is a query about intended object semantics, NOT implementation artifacts. Various drive-by documentation fixes for issues I encountered while trying to understand the code. Bug: 355291033 Bug: 354087169 Test: Build and boot AOSP Change-Id: Ia24dd1c2623d3d588c397332f87be45cc0f4bf27
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-01-19Move files related to compiled code into oat/ directory Dmitrii Ishcheikin
Test: art/test.py -b --host Change-Id: Icedd3a82c6bca5147c3bc9dc50de5a729003d66f
2023-11-22Address review comments. Nicolas Geoffray
For https://android-review.googlesource.com/2835572 Test: test.py Change-Id: Ia1584de58fe945a46b8f49548e062ce212be0a23
2023-11-21Implement Short/Byte/Character.valueOf intrinsics. Nicolas Geoffray
Also remove now obsolete IntegerCache checks - we can rely on the checks done when generating the boot image. Test: test.py Change-Id: Ia8dfa97498e7aaefd4493e8ed67fa62874fe78c3
2023-11-20Clean up after putting boxed caches to boot image. Vladimir Marko
Clean up after https://android-review.googlesource.com/2824676 . Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: Ic5ae98148499b8195669c7c81e7bffef9c8c9aa2
2023-11-17Put all cached boxed values into boot_image_live_objects. Nicolas Geoffray
Test: test.py Change-Id: I16dc434207334aad4768e26704ce20dc98a31f6a
2023-11-16Harcode IntegerCache range. Nicolas Geoffray
Let JIT assume these ranges. They are checked at AOT time when generating the boot image and when compiling applications. Test: test.py Change-Id: Ib2240d150bab366a3c17e0015503f728a98ae2ea
2023-11-10Introduce boxed primitive caches in WellKnownClasses. Nicolas Geoffray
Test: test.py Change-Id: Ia8d2f03dea8dd01eeb337d4bc2e31c778b9543a2
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-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-07-14Clean up ART intrinsics. Vladimir Marko
Change `intrinsics_list.h` to a normal include file instead of the weird include-use-and-undef pattern. Prefix macros defined in that file with `ART_`. And also remove blank lines at end of some files and address some comments on merged changes. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 283082089 Change-Id: I9c462f973c0c4bb53eff39fbe191014f6321d7c5
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-06Clean up creating constant locations. Vladimir Marko
Change `Location::ConstantLocation()` to allow passing any instruction and `DCHECK()` that it is indeed a constant. Skip explicit calls to `HInstruction::AsConstant()` before calling `Location::ConstantLocation()`. Also cache results of `instuction->InputAt(.)` in some cases when it's used more than once. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: run-gtests.sh Test: testrunner.py --target --optimizing Change-Id: I3c07642f6b3523b576ec229e4d234561ad74a20e
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-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-02-25Initialize intrinsics in dex2oat. Nicolas Geoffray
When compiling without a boot image, we used to not initialize them. Also adjust run-test with --no-image to not pass an image to dex2oat. Test: test.py --no-image --optimizing Bug: 220702556 Change-Id: Ia0f26f35ee4ad24988e067c4c7c53a0acf98cf51
2021-02-05Implement Reference.refersTo() intrinsic. Vladimir Marko
Test: Added tests to 122-npe and 160-read-barrier-stress Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: run-gtests.sh Test: testrunner.py --target --optimizing Bug: 172573708 Change-Id: I8342510565289058df218d3249ffac1eb993ca4f
2020-11-04Implement Reference.getReferent() intrinsic. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --jit Test: aosp_blueline-userdebug boots. Test: run-gtests.sh Test: testrunner.py --target --optimizing --jit Bug: 170286013 Change-Id: I4762f7c1cf3d61de2215ec8f1d14be80289c2372
2020-10-29Refactor Integer.valueOf() intrinsic implementation. Vladimir Marko
Prepare for Reference.getReferent() intrinsic implementation by a refactoring to separate the retrieval of an intrinsic method's declaring class to its own helper function, rather than being a part of a larger one. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --jit Test: aosp_blueline-userdebug boots. Test: run-gtests.sh Test: testrunner.py --target --optimizing --jit Bug: 170286013 Change-Id: Ib6c0e55d0c6fcc932999428f21c51afe32ab7ef2
2020-05-20Add compiler type to CompilerOptions. Vladimir Marko
Let CompilerOptions hold the information whether it is AOT or JIT compilation, or Zygote JIT for shared code. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --jit Test: aosp_taimen-userdebug boots. Change-Id: Id9200572406f8e43d99b8b61ef0e3edf43b52fff
2020-05-13Move implementations from class_root.h to -inl.h . Vladimir Marko
Make it possible to include the definition of enum ClassRoot without pulling in a lot of other headers. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: aosp_taimen-userdebug boots. Change-Id: Ic90fdd70bfe0c5428a5c9a0d7901ea7e15b03488
2019-10-14Revert "Make compiler/optimizing/ symbols hidden." Vladimir Marko
This reverts commit e2727154f25e0db9a5bb92af494d8e47b181dfcf. Reason for revert: Breaks ASAN tests (ODR violation). Bug: 142365358 Change-Id: I38103d74a1297256c81d90872b6902ff1e9ef7a4
2019-10-14Make compiler/optimizing/ symbols hidden. Vladimir Marko
Make symbols in compiler/optimizing hidden by a namespace attribute. The unit intrinsic_objects.{h,cc} is excluded as it is needed by dex2oat. As the symbols are no longer exported, gtests are now linked with the static version of the libartd-compiler library. libart-compiler.so size: - before: arm: 2396152 arm64: 3345280 - after: arm: 2016176 (-371KiB, -15.9%) arm64: 2874480 (-460KiB, -14.1%) Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --jit Bug: 142365358 Change-Id: I1fb04a33351f53f00b389a1642e81a68e40912a8
2019-04-09Fix AssertNonMovableStringClass(). Vladimir Marko
Use standard thread state transition. Test: testrunner.py --host --jit --gcstress -t 157 Bug: 126246773 Change-Id: I496ede614508f9c84692c4fa549153025c6ef9b4
2019-02-05Merge "Check that the String class is not movable in String.equals intrinsics." Roland Levillain
2018-12-27ART: Refactor for bugprone-argument-comment Andreas Gampe
Handles compiler. Bug: 116054210 Test: WITH_TIDY=1 mmma art Change-Id: I5cdfe73c31ac39144838a2736146b71de037425e
2018-09-28Remove need for intrinsic recognizer to be a pass. Nicolas Geoffray
Instead just recognize the intrinsic when creating an invoke instruction. Also remove some old code related to compiler driver sharpening. Test: test.py Change-Id: Iecb668f30e95034970fcf57160ca12092c9c610d
2018-09-07Check that the String class is not movable in String.equals intrinsics. Roland Levillain
Test: art/test.py Bug: 68181300 Bug: 67628039 Change-Id: I66afa3ea010f758125f8aec79509f0255cb5ea03
2018-06-29Implement Integer.valueOf() intrinsic for boot image. Vladimir Marko
And generate only one "boot image live objects" array rather than one per boot*.art file. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: Pixel 2 XL boots. Test: testrunner.py --target --optimizing Bug: 71526895 Change-Id: I23af7f47fea5150805f801cd2512f2d152ee5b73
2018-06-21Implement Integer.valueOf() intrinsic for PIC. Vladimir Marko
And fix the intrinsic for JIT even in case when someone messes up the IntegerCache using reflection. Two cases are exposed with a regression test (one that previously failed randomly and one that failed 100%) but other crashes were possible; for example, we would need a read barrier for array reads when elements are not guaranteed to be in the boot image. The new approach loads references only from the boot image live objects array which cannot be touched by reflection. The referenced objects and IntegerCache.cache are exposed and can lead to weird behavior but not crashes. On x86, the pc_relative_fixups_86 actually checks the cache an additional time but discrepancies between this check and the location building at the beginning of codegen should be OK as the HIsX86ComputeBaseMethodAddress should be added for PIC regardless of whether pc_relative_fixups_86 thinks the method is intrinsified or not. Test: 717-integer-value-of Test: Pixel 2 XL boots. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --pictest --npictest Test: testrunner.py --host --jit Test: testrunner.py --target --optimizing --pictest --npictest Test: testrunner.py --target --jit Bug: 71526895 Change-Id: I89b3245a62aba22980c86a99e2af480bfa250af1
2018-06-11Merge "ART: Adds an entrypoint for invoke-custom" Treehugger Robot
2018-06-11ART: Adds an entrypoint for invoke-custom Orion Hodson
Add support for the compiler to call into the runtime for invoke-custom bytecodes. Bug: 35337872 Test: art/test.py --host -r -t 952 Test: art/test.py --target --64 -r -t 952 Test: art/test.py --target --32 -r -t 952 Change-Id: I821432e7e5248c91b8e1d36c3112974c34171803
2018-06-07Keep objects for Integer.valueOf() intrinsic alive. Vladimir Marko
Keep boot image objects referenced by the intrinsic alive through boot image roots, so that they can never be dead as the intrinsic would still be able to resurrect them later. Note that currently the GC considers all boot image objects live forever. That risks leaking memory and should be fixed. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 71526895 Change-Id: Iec25cc27e9c5c4bd3c5711991e3111bfb19ef182
2018-05-31ObjPtr<>-ify ClassLinker::FindClass(), fix 1 stale reference use. Vladimir Marko
Thread::CreateAnnotatedStackTrace() was using a stale reference `aste_array_class`. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 31113334 Change-Id: I191907c0053456bb57de425aa6ccd9668df818a2
2018-04-26Step 1 of 2: conditional passes. Aart Bik
Rationale: The change adds a return value to Run() in preparation of conditional pass execution. The value returned by Run() is best effort, returning false means no optimizations were applied or no useful information was obtained. I filled in a few cases with more exact information, others still just return true. In addition, it integrates inlining as a regular pass, avoiding the ugly "break" into optimizations1 and optimziations2. Bug: b/78171933, b/74026074 Test: test-art-host,target Change-Id: Ia39c5c83c01dcd79841e4b623917d61c754cf075
2018-03-05Move most of runtime/base to libartbase/base David Sehr
Enforce the layering that code in runtime/base should not depend on runtime by separating it into libartbase. Some of the code in runtime/base depends on the Runtime class, so it cannot be moved yet. Also, some of the tests depend on CommonRuntimeTest, which itself needs to be factored (in a subsequent CL). Bug: 22322814 Test: make -j 50 checkbuild make -j 50 test-art-host Change-Id: I8b096c1e2542f829eb456b4b057c71421b77d7e2
2018-01-24Move missed files to libdexfile David Sehr
Reduce the dependencies on utf and utils in preparation for separate directory. Bug: 22322814 Test: make -j 50 test-art-host make -j 50 dexdump2 dexlist Change-Id: Icdecf895dafec63ef903514eef79d459abc14925