summaryrefslogtreecommitdiff
path: root/compiler/optimizing/sharpening.cc
AgeCommit message (Collapse)Author
2024-11-05Use .data.img.rel.ro for app image methods. Vladimir Marko
This should improve app startup as we can skip the target method resolution on the first call. For `invoke-direct` we should never go to the resolution trampoline for app image methods and for `invoke-static` we go to the trampoline only if the class is not yet visibly initialized and in that case we still save time as the target method is already known. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --speed-profile Test: run-gtests.sh Test: testrunner.py --target --optimizing --speed-profile Bug: 38313278 Change-Id: I1fea5485264b433fe642c9d0092a5411813eb996
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-05-07Faster `HLoadClass` for app image classes. Vladimir Marko
Add app image relocations for classes in the app image, similar to the existing relocations for boot image. This new load kind lets the compiled code avoid the null check and slow path. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --speed-profile Test: run-test.sh Test: testrunner.py --target --optimizing --speed-profile Bug: 38313278 Change-Id: Iffd76fe9ac6b95c37c2781fd6257e1d5cd0790d0
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-16Rename `.data.bimg.rel.ro` to `.data.img.rel.ro`. Vladimir Marko
Prepare for adding app image patches to the same section. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 38313278 Change-Id: Ib552f005b3a2859152d0de9fa6b2fcd48a0f3feb
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-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
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-04-21Avoid VarHandle checks for boot image field VarHandles. Vladimir Marko
And use the field offset as seen at compile time. Implemented for x86-64, arm and arm64 but not for x86 with incomplete set of `VarHandle` intrinsics. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: run-gtests.sh Test: testrunner.py --target --optimizing Bug: 191765508 Change-Id: If68b0287c8823e69c493dcefb7e61dc34d69fb4f
2022-02-09Add test to check against sharpening optimization Santiago Aboy Solanes
After b/214850438 we took a second look at the sharpening optimization. While it seems doable, it is not straightforward. We are adding a comment and a test to make sure we are not mistakenly enabling it. Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Bug: 214850438 Bug: 154012332 Change-Id: Ic619934cdd4cd322a31afce60b9becbfa4338e81
2022-02-02Revert "Add bss support for inlining BCP DexFiles for single image" Santiago Aboy Solanes
This reverts commit 2d62882195eb97358fb8a1fd147d52a36cd3c581. Reason for revert: Native crashes due to out of date OatFile b/217369528 Change-Id: I7bf7d6decb24934b47d5a4b2cc2ce25906032f10
2022-01-28Add bss support for inlining BCP DexFiles for single image Santiago Aboy Solanes
This CL extends the .bss metadata section to allow for BCP methods to be inlined into other DexFiles, even when requiring a bss entry. Test: ART tests, compiling and launching top 100 apps Bug: 154012332 Change-Id: Ib541e69a9c52b3fad003d286a5b57060770e1395
2022-01-17Revert "Expand sharpening's ComputeLoadClassKind to cover cross-dex cases" Nicolas Geoffray
This reverts commit 32b8c8f33ad68982357c1fa3d0f132d06b070ab5. Bug: 154012332 Bug: 214850438 Reason for revert: b/214850438 Change-Id: I479c0910ce5da593e170bc5e4f6fa10dfe5d67b2
2022-01-13Expand sharpening's ComputeLoadClassKind to cover cross-dex cases Santiago Aboy Solanes
We can handle some extra cross-dex cases in order to expand the support. Bug: 154012332 Test: ART tests Change-Id: Ic3220d809086b4b3007bf5b6d63789ffb1b91fb9
2021-01-21Reland "Improve invokeinterface for nterp." Nicolas Geoffray
This reverts commit f1d06474baa2f7c00761db39099b89ddab71bbe4. Bug: 177554973 Bug: 112676029 Test: test.py Test: 815-invokeinterface-default Test: enable text-to-speech on device, no crash Reason for revert: Fixed issue with recursive default methods Change-Id: I2fb9336adb6c4fc920f39aa19bfe7f0a92ce059a
2020-10-07Change interface conflict stub to take the interface method. Nicolas Geoffray
To avoid doing dex cache lookup, pass the interface method instead. This costs a few hundred KBs on speed compiled APKs (< 0.5% code size), but improves performance when hitting a conflict (as seen on dogfood data). For nterp, we currently pass the conflict method instead of the interface method. We need to handle default methods before optimizing it. This removes our last use of dex cache in compiled code. A follow-up CL will remove the NeedsDexCacheOfDeclaringClass from HInvokeInterface. Test: test.py Change-Id: I3cdd4543ad7d904b3e81950af46a48a48af6991a
2020-09-30Faster access to unresolved classes from compiled code. Vladimir Marko
Add two new load kinds to LoadClass, similar to kBssEntry but using the access-checking entrypoint on the slow-path. One is used for classes that are in the literal package and the other for classes outside the literal package of the compiling class. Associate new .bss entries with these load kinds and update them from entrypoints based on the resolved class properties. If the resolved class is public, both types of entries can be updated, otherwise only the package local entry can be updated and only if the defining class loader of the class is the same as the caller's defining class loader (which is identical for all code in an oat file) because the run time access check for same package requires both class loader and literal package name match. Test: Additional tests in 727-checker-unresolved-class. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: aosp_blueline-userdebug boots. Test: run-gtests.sh Test: testrunner.py --target --optimizing Bug: 161898207 Change-Id: I281e06ac2825caf81c6d7ee3128af833abd39992
2020-09-24Don't store copied methods in BSS. Nicolas Geoffray
Otherwise, we can end up in a state where the method on the stack is unrelated to the receiver. Also fix a comment related to GetCanonicalMethod and StackVisitor::ValidateFrame. Test: 810-checker-invoke-super-default Change-Id: I3030e4af6059f7a4a7a1f046f2aabae8ce9057da
2020-09-23Move MethodLoadKind out of HInvokeStaticOrDirect. Nicolas Geoffray
To prepare for using it in HInvokeInterface. For consistency, also move CodePtrLocation. Test: test.py Change-Id: I84f973764275002e2adb71080ebc833b2bafb975
2020-09-11Handle more cases of super calls in the compiler. Nicolas Geoffray
Add support for calling super methods that are not referenced within the compiling dex file. Test: 808-checker-invoke-super Test: 809-checker-invoke-super-bss Change-Id: Ib103f818ac8b612a79b6b18cc8eda81131bb3149
2020-06-19Direct calls to @CriticalNative methods. Vladimir Marko
Emit direct calls from compiled managed code to the native code registered with the method, avoiding the JNI stub. Golem results: art-opt-cc x86 x86-64 arm arm64 NativeDowncallStaticCritical +12.5% +62.5% +75.9% +41.7% NativeDowncallStaticCritical6 +55.6% +87.5% +72.1% +35.3% art-opt x86 x86-64 arm arm64 NativeDowncallStaticCritical +28.6% +85.6% +76.4% +38.4% NativeDowncallStaticCritical6 +44.6% +44.6% +74.6% +32.2% Test: Covered by 178-app-image-native-method. Test: m test-art-host-gtest Test: testrunner.py --host --debuggable --ndebuggable \ --optimizing --jit --jit-on-first-use Test: run-gtests.sh Test: testrunner.py --target --optimizing Test: testrunner.py --target --debuggable --ndebuggable \ --optimizing --jit --jit-on-first-use -t 178 Test: aosp_cf_x86_phone-userdebug boots. Test: aosp_cf_x86_phone-userdebug/jitzygote boots. Bug: 112189621 Change-Id: I8b37da51e8fe0b7bc513bb81b127fe0416068866
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
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-07-30Compiler changes for boot image extension. Vladimir Marko
Test: m test-art-host-gtest Test: testrunnner.py --host --optimizing Test: aosp_taimen-userdebug boots. Test: run-gtest.sh Test: testrunner.py --target --optimizing Change-Id: I8e999c96ec908f26d8c529edc9d2a3be49a9379a
2019-07-16Further clean up boot image address checks. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: aosp_taimen-userdebug boots. Change-Id: Ib7abd10e94e995e61549b3a3111a640802b5e700
2019-07-01Prepare for sharing JIT code after fork. Nicolas Geoffray
Only encode classes/strings/methods that are in a boot image. Bug: 119800099 Test: boot Change-Id: I7ed8ce2ce876ad1c6c1678939cafe4808a67bef4
2019-06-28Revert "Revert "Make the JIT zygote memory shared."" Nicolas Geoffray
This reverts commit 2fef66b294417d447630f9d98de68227eef476d3. Bug: 119800099 Bug: 136110523 Reason for revert: Fixed webview_zygote case. Change-Id: Iaae8c999463d77b7b1e62b55458493bdbc97a104
2019-06-26Revert "Make the JIT zygote memory shared." Nicolas Geoffray
This reverts commit 05f87217ddc9b4b9186710c0135b918f456c5aef. Bug: 119800099 Bug: 136110523 Reason for revert: testWebview flaking Change-Id: I96afa6bc9c56c4aaf5ed72ae370f6f69c096c559
2019-06-26Make the JIT zygote memory shared. Nicolas Geoffray
Test: boots Bug: 119800099 Change-Id: I75ff8a58eea4de5cb833139641b4e15b8394d9b1
2019-03-12Fix non-deterministic compilation for const-string... Vladimir Marko
... in inlined methods that are not in the boot profile. If such string is not in the boot image for other reasons, do not resolve the string and use the kBssEntry load kind. Boot image sizes for aosp_taimen-userdebug: - before: arm/boot*.art: 12349440 arm/boot*.oat: 19862024 arm64/boot*.art: 16609280 arm64/boot*.oat: 23568592 - after: arm/boot*.art: 12324864 (-24KiB) arm/boot*.oat: 19936612 (+73KiB) arm64/boot*.art: 16580608 (-28KiB) arm64/boot*.oat: 23642120 (+72KiB) Test: aosp_taimen-userdebug boots. Test: m test-art-host-gtest Bug: 26687569 Change-Id: I3e0b72cd5e8c67904517856208f25a6c379ab601
2018-11-08Delete IsClassToCompile Mathieu Chartier
Compiled classes filtering is no longer a thing. Bug: 26687569 Bug: 76145463 Test: test-art-host Change-Id: Iaf4b9dcea5d9fe1eae564fbd6d373af2fdc87b14
2018-09-19Remove sharpening as an optimization pass. Nicolas Geoffray
Make the last sharpening helper (methods) like the other helpers: being invoked by the instruction builder. Test: test.py Change-Id: Ic80a454f9b59b0b4ef7825590b24402500ba851c
2018-07-16Always produce PIC code for AOT compilation. Vladimir Marko
Change sharpening to use PIC load kinds for AOT compilation and add "Jit" to the direct addressing load kind names. Use PIC code also for the Integer.valueOf() intrinsic codegen. Remove all support for non-PIC linker patches. The dex2oat --compile-pic option is retained for now but ignored by the compiler. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: Pixel 2 XL boots. Test: testrunner.py --target --optimizing Bug: 77856493 Change-Id: I54d666f6522f160a1b6ece4045a15d19363acbb6
2018-06-28Remove CompilerDriver::support_boot_image_fixup_. Vladimir Marko
Check for non-PIC boot image as a testing config instead. Honor the config for HInvokeStaticOrDirect sharpening. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I3645f4fefe322f1fd64ea88a2b41a35ceccea688
2018-06-25Move dex_files_for_oat_file_ to CompilerOptions. Vladimir Marko
A step toward removing the CompilerDriver dependency from several classes, including HSharpening and ImageWriter. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I364ef66511fdf855cb11b12c818a40572b037727
2018-06-25Move image_classes_ to CompilerOptions. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: Ifb30e071d7b39ae939fc3f83d7eba82fd077c7e8
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-27Revert^4 "Compiler changes for bitstring based type checks." Vladimir Marko
Disabled the build time flag. (No image version bump needed.) Bug: 26687569 Bug: 64692057 Bug: 76420366 This reverts commit 3fbd3ad99fad077e5c760e7238bcd55b07d4c06e. Change-Id: I5d83c4ce8a7331c435d5155ac6e0ce1c77d60004
2018-03-26Revert^3 "Compiler changes for bitstring based type checks." Andreas Gampe
This reverts commit 3f41323cc9da335e9aa4f3fbad90a86caa82ee4d. Reason for revert: Fails sporadically. Bug: 26687569 Bug: 64692057 Bug: 76420366 Change-Id: I84d1e9e46c58aeecf17591ff71fbac6a1e583909
2018-03-22Revert^2 "Compiler changes for bitstring based type checks." Vladimir Marko
Add extra output for debugging failures and re-enable the bitstring type checks. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --jit Test: testrunner.py --host -t 670-bitstring-type-check Test: Pixel 2 XL boots. Test: testrunner.py --target --optimizing --jit Test: testrunner.py --target -t 670-bitstring-type-check Bug: 64692057 Bug: 26687569 This reverts commit bff7a52e2c6c9e988c3ed1f12a2da0fa5fd37cfb. Change-Id: I090e241983f3ac6ed8394d842e17716087d169ac
2018-03-08Retrieve String/Class references from .data.bimg.rel.ro. Vladimir Marko
For PIC AOT-compiled app, use the .data.bimg.rel.ro to load the boot image String/Class references instead of using the mmapped boot image ClassTable and InternTable. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --pictest --npictest Test: Pixel 2 XL boots. Test: testrunner.py --target --optimizing --pictest --npictest Bug: 71526895 Change-Id: Id5703229777aecb589a933a41f92e44d3ec02a3d
2018-03-08Load ArtMethod* from .data.bimg.rel.ro entries. Vladimir Marko
Introduce a new .data.bimg.rel.ro section in oat files where we store offsets of boot image objects from the beginning of the boot image. At runtime we relocate these entries using the actual boot image address to turn offsets to pointers. Use the .data.bimg.rel.ro to prepare the boot image methods used by HInvokeStaticOrDirect for PIC AOT app compilation. Loading the ArtMethod* from .data.bimg.rel.ro instead of the .bss avoids the initial call to the resolution trampoline. Test: Additional test in 522-checker-sharpening Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --pictest --npictest Test: Pixel 2 XL boots. Test: testrunner.py --target --optimizing --pictest --npictest Bug: 71526895 Change-Id: Ie5f5b1f622704877b36730377146e59092e46c0c
2018-01-25Revert "Compiler changes for bitstring based type checks." Nicolas Geoffray
Bug: 64692057 Bug: 71853552 Bug: 26687569 This reverts commit eb0ebed72432b3c6b8c7b38f8937d7ba736f4567. Change-Id: I7daeaa077960ba41b2ed42bc47f17501621be4be
2018-01-25Revert "ART: Use the bitstring type check for AOT app compilation." Nicolas Geoffray
Test failures: http://build.chromium.org/p/client.art/builders/fugu-debug/builds/4875 01-25 02:05:28.357 23732 23732 F /data/local/tmp/system/bin/../bin/dalvikvm: quick_throw_entrypoints.cc:132] Check failed: !dest_type->IsAssignableFrom(src_type) This reverts commit 718e8319c728e9ee2ec15b1d56ca96baa4393028. Change-Id: I022f88cd81ae99143e5670ae29eae326ecc83cc2