summaryrefslogtreecommitdiff
path: root/compiler/optimizing/sharpening.cc
AgeCommit message (Collapse)Author
2018-01-23ART: Use the bitstring type check for AOT app compilation. Vladimir Marko
For boot image target classes that have their bitstring already assigned in the boot image. The size of the services.odex for aosp_taimen-userdebug: - before: - arm64: 20988640 - after: - arm64: 20968016 (-20KiB, -0.1%) (There is no arm version, only arm64.) Test: New test case in 552-checker-sharpening. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: Pixel 2 XL boots. Test: testrunner.py --target --optimizing Bug: 64692057 Change-Id: I9585efca8ba0df15400e7536e5e2cc76aca13e8d
2018-01-23Compiler changes for bitstring based type checks. Vladimir Marko
We guard the use of this feature with a compile-time flag, set to true in this CL. Boot image size for aosp_taimen-userdebug in AOSP master: - before: arm boot*.oat: 63604740 arm64 boot*.oat: 74237864 - after: arm boot*.oat: 63531172 (-72KiB, -0.1%) arm64 boot*.oat: 74135008 (-100KiB, -0.1%) The new TypeCheckBenchmark yields the following changes using the little cores of taimen fixed at 1.4016GHz: 32-bit 64-bit timeCheckCastLevel1ToLevel1 11.48->15.80 11.47->15.78 timeCheckCastLevel2ToLevel1 15.08->15.79 15.08->15.79 timeCheckCastLevel3ToLevel1 19.01->15.82 17.94->15.81 timeCheckCastLevel9ToLevel1 42.55->15.79 42.63->15.81 timeCheckCastLevel9ToLevel2 39.70->14.36 39.70->14.35 timeInstanceOfLevel1ToLevel1 13.74->17.93 13.76->17.95 timeInstanceOfLevel2ToLevel1 17.02->17.95 16.99->17.93 timeInstanceOfLevel3ToLevel1 24.03->17.95 24.45->17.95 timeInstanceOfLevel9ToLevel1 47.13->17.95 47.14->18.00 timeInstanceOfLevel9ToLevel2 44.19->16.52 44.27->16.51 This suggests that the bitstring typecheck should not be used for exact type checks which would be equivalent to the "Level1ToLevel1" benchmark. Whether the implementation is a beneficial replacement for the kClassHierarchyCheck and kAbstractClassCheck on average depends on how many levels from the target class (or Object for a negative result) is a typical object's class. 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: 71853552 Bug: 26687569 Change-Id: I538d7e036b5a8ae2cc3fe77662a5903d74854562
2017-12-11Do not pass DexFile to ClassLinker::Lookup/ResolveString(). Vladimir Marko
The DexFile can be easily retrieved from the DexCache, so reduce the number of arguments that need to be passed. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I8c4cec43b31b27de7e4e94374fdd69c6d6ca6c13
2017-12-08Determine HLoadClass/String load kind early. Vladimir Marko
This helps save memory by avoiding the allocation of HEnvironment and related objects for AOT references to boot image strings and classes (kBootImage* load kinds) and also for JIT references (kJitTableAddress). Compiling aosp_taimen-userdebug boot image, the most memory hungry method BatteryStats.dumpLocked() needs - before: Used 55105384 bytes of arena memory... ... UseListNode 10009704 Environment 423248 EnvVRegs 20676560 ... - after: Used 50559176 bytes of arena memory... ... UseListNode 8568936 Environment 365680 EnvVRegs 17628704 ... Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --jit Bug: 34053922 Change-Id: I68e73a438e6ac8e8908e6fccf53bbeea8a64a077
2017-09-11Use mmapped boot image class table for PIC app HLoadClass. Vladimir Marko
Implement new HLoadClass load kind for boot image classes referenced by PIC-compiled apps (i.e. prebuilts) that uses PC-relative load from a boot image ClassTable mmapped into the apps .bss. This reduces the size of the PIC prebuilts that reference boot image classes compared to the kBssEntry as we can completely avoid the slow path and stack map unless we need to do the class initialization check. Prebuilt services.odex for aosp_angler-userdebug (arm64): - before: 20312800 - after: 19775352 (-525KiB) Test: m test-art-host-gtest Test: testrunner.py --host Test: testrunner.py --host --pictest Test: testrunner.py --target on Nexus 6P. Test: testrunner.py --target --pictest on Nexus 6P. Test: Nexus 6P boots. Bug: 31951624 Change-Id: I13adb19a1fa7d095a72a41f09daa6101876e77a8
2017-09-07Use mmapped boot image intern table for PIC app HLoadString. Vladimir Marko
Implement new HLoadString load kind for boot image strings referenced by PIC-compiled apps (i.e. prebuilts) that uses PC-relative load from a boot image InternTable mmapped into the apps .bss. This reduces the size of the PIC prebuilts that reference boot image strings compared to the kBssEntry as we can completely avoid the slow path and stack map. We separate the InternedStrings and ClassTable sections of the boot image (.art) file from the rest, aligning the start of the InternedStrings section to a page boundary. This may actually increase the size of the boot image file by a page but it also allows mprotecting() these tables as read-only. The ClassTable section is included in anticipation of a similar load kind for HLoadClass. Prebuilt services.odex for aosp_angler-userdebug (arm64): - before: 20862776 - after: 20308512 (-541KiB) Note that 92KiB savings could have been achieved by simply avoiding the read barrier, similar to the HLoadClass flag IsInBootImage(). Such flag is now unnecessary. Test: m test-art-host-gtest Test: testrunner.py --host Test: testrunner.py --host --pictest Test: testrunner.py --target on Nexus 6P. Test: testrunner.py --target --pictest on Nexus 6P. Test: Nexus 6P boots. Bug: 31951624 Change-Id: I5f2bf1fc0bb36a8483244317cfdfa69e192ef6c5
2017-07-24ART: Include cleanup Andreas Gampe
Let clang-format reorder the header includes. Derived with: * .clang-format: BasedOnStyle: Google IncludeIsMainRegex: '(_test|-inl)?$' * Steps: find . -name '*.cc' -o -name '*.h' | xargs sed -i.bak -e 's/^#include/ #include/' ; git commit -a -m 'ART: Include cleanup' git-clang-format -style=file HEAD^ manual inspection git commit -a --amend Test: mmma art Change-Id: Ia963a8ce3ce5f96b5e78acd587e26908c7a70d02
2017-06-07Use ArtMethod* .bss entries for HInvokeStaticOrDirect. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host Test: testrunner.py --target Test: Nexus 6P boots. Test: Build aosp_mips64-userdebug. Bug: 30627598 Change-Id: I0e54fdd2e91e983d475b7a04d40815ba89ae3d4f
2017-06-02Rename kDexCacheViaMethod to kRuntimeCall for HLoadClass/String. Vladimir Marko
The old name does not reflect the actual code anymore. Test: testrunner.py --host Change-Id: I2e13cf727bba9d901c4d3fc821bb526d38a775b8
2017-05-22Use PC-relative pointer to boot image methods. Vladimir Marko
In preparation for adding ArtMethod entries to the .bss section, add direct PC-relative pointers to methods so that the number of needed .bss entries for boot image is small. Test: m test-art-host-gtest Test: testrunner.py --host Test: testrunner.py --target on Nexus 6P Test: Nexus 6P boots. Test: Build aosp_mips64-userdebug Bug: 30627598 Change-Id: Ia89f5f9975b741ddac2816e1570077ba4b4c020f
2017-05-16Remove LoadString/Class kind kBootImageLinkTimeAddress. Vladimir Marko
We no longer support non-PIC boot image compilation. Also clean up some obsolete code for method patches and make JIT correctly report itself as non-PIC. Test: testrunner.py --host Test: testrunner.py --target Bug: 33192586 Change-Id: I593289c5c1b0e88b82b86a933038be97bbb15ad2
2017-05-11Clean up some uses of "auto". Vladimir Marko
Make actual types more explicit, either by replacing "auto" with actual type or by assigning std::pair<> elements of an "auto" variable to typed variables. Avoid binding const references to temporaries. Avoid copying a container. Test: m test-art-host-gtest Change-Id: I1a59f9ba1ee15950cacfc5853bd010c1726de603
2017-03-23Deterministic DexCache in heap images. Vladimir Marko
Preload each slot in dex cache arrays with the candidate entry with the lowest index. Also fix a discrepancy where we used to keep an ArtField* in the DexCache if we kept the declaring class rather than based on the class referenced in the corresponding FieldId. This can result in accessing a field through a FieldId with an unresolved class as demonstrated by the regression test. Test: 159-app-image-fields Test: testrunner.py --host Bug: 30627598 Change-Id: I34735047cb064ff462cd9859e86a61ddf8615ecd
2017-03-09Merge "Remove --include-patch-information option from dex2oat." Richard Uhler
2017-03-08Remove --include-patch-information option from dex2oat. Richard Uhler
Because we no longer support running patchoat on npic oat files, which means the included patch information is unused . Bug: 33192586 Test: m test-art-host Change-Id: I9e100c4e47dc24d91cd74226c84025e961d30f67
2017-03-07Invoke typed arraycopy for primitive arrays. Nicolas Geoffray
Apps will always call the Object version of arraycopy. When we can infer the types of the passed arrays, replace the method being called to be the typed System.arraycopy one. 10% improvement on ExoPlayerBench. Test: 641-checker-arraycopy bug: 7103825 Change-Id: I872d7a6e163a4614510ef04ae582eb90ec48b5fa
2017-02-14ART: Add operator == and != with nullptr to Handle Andreas Gampe
Get it in line with ObjPtr and prettify our code. Test: m Change-Id: I1322e2a9bc7a85d7f2441034a19bf4d807b81a0e
2017-02-06Merge "Code refactoring around sharpening HLoadClass." Nicolas Geoffray
2017-02-03Code refactoring around sharpening HLoadClass. Nicolas Geoffray
Even if the class is not accessible through the dex cache, we can access it by other means (eg boot class, jit table). So rewrite static field access instruction builder to not bail out if a class cannot be accessed through the dex cache. bug:34966607 test: test-art-host test-art-target Change-Id: I88e4e09951a002b480eb8f271726b56f981291bd
2017-02-01Fix creating self-recursive obsolete methods. Alex Light
We were using recursive loading of the current art method which was making us miss obsolete methods in some cases. We could also end up checking the wrong method when walking the stack. We also add tests for recursive obsolete methods in general. Bug: 34815470 Test: mma -j40 test-art-host Test: ART_TEST_JIT=true mma -j40 test-art-host Change-Id: I522fd4cac4e3f9d35d03b128bad6d6971cfe6c4a
2017-01-16Put the resolved class in HLoadClass. Nicolas Geoffray
To avoid repeated lookups in sharpening/rtp/inlining. Test: test-art-host test-art-target Change-Id: I08d0da36a4bb061cdaa490ea2af3a3217a875bbe
2017-01-16Implement HLoadClass/kBssEntry for boot image. Vladimir Marko
Test: m test-art-host Test: m test-art-host with CC Test: m test-art-target on Nexus 9 Test: Nexus 9 boots. Test: Build aosp_mips64-eng Bug: 30627598 Change-Id: I168f24dedd5fb54a1e4215ecafb947ffb0dc3280
2017-01-16Store resolved types for AOT code in .bss. Vladimir Marko
Test: m test-art-host Test: m test-art-target on Nexus 9. Test: Nexus 9 boots. Test: Build aosp_mips64-eng. Bug: 30627598 Bug: 34193123 Change-Id: I8ec60a98eb488cb46ae3ea56341f5709dad4f623
2017-01-16Make runtime call on main for HLoadClass/kDexCacheViaMethod. Vladimir Marko
Remove dependency of the compiled code on types dex cache array in preparation for changing to a hash-based array. Test: m test-art-host Test: m test-art-target on Nexus 9 Bug: 30627598 Change-Id: I3c426ed762c12eb9eb4bb61ea9a23a0659abf0a2
2017-01-16Remove HLoadClass::LoadKind::kDexCachePcRelative. Vladimir Marko
Test: m test-art-host Test: m test-art-target-run-test-552-checker-sharpening Bug: 30627598 Change-Id: Ic809b0f3a8ed0bd4dc7ab67aa64866f9cdff9bdb
2017-01-10Keep resolved String in HLoadString. Nicolas Geoffray
For the following reasons: - Avoids needing to do a lookup again in CodeGenerator::EmitJitRoots. - Fixes races where we the string was GC'ed before CodeGenerator::EmitJitRoots. - Makes it possible to do GVN on the same string but defined in different dex files. Test: test-art-host, test-art-target Change-Id: If2b5d3079f7555427b1b96ab04546b3373fcf921
2017-01-06Remove the IsInDexCache flag from HLoadString. Vladimir Marko
This flag was obsolete and always false. Test: m test-art-host Change-Id: Iabefc068908ff4f994b63e7e18a2a27c25a0919e
2016-12-20Remove soon to be obsolete call kinds for direct calls. Nicolas Geoffray
And remove CompilerDriver::GetCodeAndMethodForDirectCall in preparation of removing non-PIC prebuild and non-PIC on-device boot image compilation. Test: test-art-host test-art-target bug:33192586 Change-Id: Ic48e3e8b9d7605dd0e66f31d458a182198ba9578
2016-12-19Sharpen HLoadClass from inliner. Nicolas Geoffray
Also cleanup HLoadClass constructor. Test: ART_TEST_JIT=true m test-art-host-run-test Change-Id: I8f803b05fb8a7267d1421ca9c032e624f27efed3
2016-12-13Support GVN for HLoadClass::LoadKind::kJitTableAddress. Nicolas Geoffray
Fixes performance regressions seen in eg Dhrystone. Also add comment on why a class may not be found when sharpening. Test: manual Dhrystone run, performance recovers Test: ART_TEST_JIT=true test-art-host-run-test-jit Change-Id: I8e879f1c390f83e8bc930f343beb7b4a41c2f190
2016-12-12Revert "Revert "Add kJitTableAddress for HLoadClass."" Nicolas Geoffray
This reverts commit d2d5262c8370309e1f2a009f00aafc24f1cf00a0. Change-Id: I6149d5c7d5df0b0fc5cb646a802a2eea8d01ac08
2016-12-12Revert "Add kJitTableAddress for HLoadClass." Nicolas Geoffray
One test failure after merge. This reverts commit 5b12f7973636bfea29da3956a9baa7a6bbe2b666. Change-Id: I120c49e53274471fc1c82a10d52e99c83f5f85cc
2016-12-12Add kJitTableAddress for HLoadClass. Nicolas Geoffray
This new kind loads classes from the root table associated with JIT compiled code. Also remove kDexCacheAddress, which is replaced by kJitTableAddress. test: ART_TEST_JIT=true test-art-host-jit test-art-target-jit Change-Id: Ia23029688d1a60c178bf2ffa7463927c5d5de4d0
2016-11-29ART: Add dex::StringIndex Andreas Gampe
Add abstraction for uint32_t string index. Test: m test-art-host Change-Id: I917c2881702fe3df112c713f06980f2278ced7ed
2016-11-21ART: Add dex::TypeIndex Andreas Gampe
Add abstraction for uint16_t type index. Test: m test-art-host Change-Id: I47708741c7c579cbbe59ab723c1e31c5fe71f83a
2016-11-18Revert "Revert "Revert "Revert "JIT root tables."""" Nicolas Geoffray
Test: 626-set-resolved-string, test-art-host, test-art-target Test: run-libcore-tests.sh Test: phone boots and runs This reverts commit 3395fbc20bcd20948bec8958db91b304c17cacd8. Change-Id: I104b73d093e3eb6a271d564cfdb9ab09c1c8cf24
2016-11-14Revert "Revert "Revert "JIT root tables.""" Nicolas Geoffray
libcore failures: dalvikvm32 F 11-14 03:04:06 14870 14870 jit_code_cache.cc:310] Check failed: new_string != nullptr This reverts commit 75afcdd3503a8a8518e5b23d21b6e73306ce39ce. Change-Id: I5a6b6b48aa79a763d1ff1ba4d85d63811254787d
2016-11-11Revert "Revert "JIT root tables."" Nicolas Geoffray
Also contains Revert "Support kJitTableAddress in x86/arm/arm64." This reverts commit 4acd03638fcdb4e5d1666f8eec7eb3bf6d6be035. This reverts commit 997d1217830c0a18b70faeabd53c04700a87d7d9. Test: ART_USE_READ_BARRIER=true/false test-art-host test-art-target Change-Id: I77cb1e9bf8f1b4c58b72d3cf5ca31ced2aaa1ea3
2016-11-09Merge "Revert "JIT root tables."" Nicolas Geoffray
2016-11-09Revert "JIT root tables." Nicolas Geoffray
May be the offender for jit-gcstress failure of 902. This reverts commit ac3ebc3150760425ed00abd56da48f9a6e0666bc. Change-Id: I9ea6c9236fd1729fed7d1868dd8a111172932308
2016-11-09Fix 552-checker-sharpening for PIC test. Vladimir Marko
And remove obsolete HLoadString::LoadKind::kDexCacheAddress. Test: m ART_TEST_PIC_TEST=true test-art-host Change-Id: I3e7a1a98c2c7eba5ea10954d7efcf743a807c300
2016-11-08JIT root tables. Nicolas Geoffray
Implement root tables for the JIT. Each JIT compiled method gets a table allocated before the stack maps. The table gets visited through Runtime::SweepSystemWeaks. Implement String roots for x86_64 as an example. Test: test-art-host test-art-target Change-Id: Id3d5bc67479e08b52dd4b253e970201203a0f0d2
2016-10-25Merge "Revert "Disable kBssEntry LoadString sharpening."" Vladimir Marko
2016-10-25Revert "Disable kBssEntry LoadString sharpening." Vladimir Marko
Fix .bss GC root walking by registering the oat file with the class loader's class table. Also fix potentially outdated ObjPtr<> use in debug build. This reverts commit b55fdbb30b3bc4e334c241153b98c0a6ea4a4a2b. Test: m test-art-host Bug: 32124939 Change-Id: I0b7e3b93cb53c7b22408aa10a04eaf5582c69ee8
2016-10-24Remove unnecessary load class for new instance Mathieu Chartier
Remove the load class for new instance if the load class has only one use and can not throw. Previously many were not removed due to MarkInDexCache nulling out the environment of the HLoadClass and causing CanMoveClinitCheck to fail. Also keep track of initialized HLoadClass and always remove clinit checks for these. Added checker regression test. Code size savings: ARM64 CC boot.oat: 47896936 -> 47642488 (-0.53%) Savings from IsInitialized optimization: 65984 bytes Performance unmeasured, probably faster due to removing unnecessary work. Test: test-art-host with CC baker Bug: 29516974 Change-Id: I43358762ffb380ebe7e6518d0d440a5e1cc03b61
2016-10-21Disable kBssEntry LoadString sharpening. Vladimir Marko
We seem to fail to visit the BSS GC roots sometimes. Bug: 32124939 Test: m test-art-host Change-Id: I4724ced649042cbeb170cac9e8da8c5db168c8fc
2016-10-04Revert "Revert "Store resolved Strings for AOT code in .bss."" Vladimir Marko
Fixed oat_test to keep dex files alive. Fixed mips build. Rewritten the .bss GC root visiting and added write barrier to the artResolveStringFromCode(). Test: build aosp_mips-eng Test: m ART_DEFAULT_GC_TYPE=SS test-art-target-host-gtest-oat_test Test: Run ART test suite on host and Nexus 9. Bug: 20323084 Bug: 30627598 This reverts commit 5f926055cb88089d8ca27243f35a9dfd89d981f0. Change-Id: I07fa2278d82b8eb64964c9a4b66cb93726ccda6b
2016-09-30Revert "Store resolved Strings for AOT code in .bss." Vladimir Marko
There are some issues with oat_test64 on host and aosp_mips-eng. Also reverts "compiler_driver: Fix build." Bug: 20323084 Bug: 30627598 This reverts commit 63dccbbefef3014c99c22748d18befcc7bcb3b41. This reverts commit 04a44135ace10123f059373691594ae0f270a8a4. Change-Id: I568ba3e58cf103987fdd63c8a21521010a9f27c4
2016-09-30Merge "Store resolved Strings for AOT code in .bss." Vladimir Marko
2016-09-29Clean up ScopedThreadStateChange to use ObjPtr Mathieu Chartier
Also fixed inclusion of -inl.h files in .h files by adding scoped_object_access-inl.h and scoped_fast_natvie_object_access-inl.h Changed AddLocalReference / Decode to use ObjPtr. Changed libartbenchmark to be debug to avoid linkage errors. Bug: 31113334 Test: test-art-host Change-Id: I4d2e160483a29d21e1e0e440585ed328b9811483