summaryrefslogtreecommitdiff
path: root/compiler/optimizing/instruction_builder.cc
AgeCommit message (Collapse)Author
2018-11-01ART: Cache resolved types in InstructionBuilder.Vladimir Marko
And avoid using the CompilerDriver for class resolution and retrieving CompilerOptions. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: Icec3de58456cfeaf3f2be6e57e037fdf45e8b851
2018-11-01Add compiling class to the DexCompilationUnit.Vladimir Marko
Use it to simplify HInstructionBuilder and reduce the number of class resolution calls. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: Pixel 2 XL boots. Change-Id: Ib4f9b4ea61235841e653a03a40755a39c7de7504
2018-10-31Fix and improve ClinitCheck elimination.Vladimir Marko
Fix erroneous usage of the inner method's access flags while checking the class of the outer method. This allowed erroneous elimination of a needed ClinitCheck when inlining. Treat constructors the same way as static methods as the instance allocation necessarily preceding the constructor call performs the class initialization check. The size of the aosp_taimen-userdebug prebuilts: - before: arm/boot*.oat: 20252196 arm64/boot*.oat: 24030776 oat/arm64/services.odex: 22406664 - after: arm/boot*.oat: 20252092 (-0.1KiB) arm64/boot*.oat: 24027024 (-3.7KiB) oat/arm64/services.odex: 22402528 (-4.0KiB) (Insignificant changes.) Test: Add regression test to 174-escaping-instance-of-bad-class. Test: Add optimization test to 551-checker-clinit. Test: testrunner.py --jvm -t 174 Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: Pixel 2 XL boots. Test: m test-art-target-gtest Test: testrunner.py --target --optimizing Bug: 62478025 Change-Id: I591aca2c538d10cf6df1d38d59270af1de380b3e
2018-10-16Fix HNewArray with unresolved primitive array type.Vladimir Marko
And enable test 920-objects that was crashing because of this bug. Test: testrunner.py --host --jit-on-first-use -t 920 Test: testrunner.py --host --optimizing Test: m test-art-host-gtest Bug: 117638896 Change-Id: I47dc893b121c82de537b3147c86d37a6eecf2d62
2018-10-03Fix ReplaceUninitializedStringPhis.Nicolas Geoffray
Move the analysis after redundant phi and dead phi elimination, knowing that only graphs with irreducible loops may still have a phi as input of the invoke. In such a case, we bail. bug: 112537407 Test: 563-checker-fake-string Change-Id: Ib9eefa4ce905b7fb418ca9b2a3c26ea4df74ce8f
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-09-12Refactor debug info position visitingMathieu Chartier
Move logic to CodeItemDebugInfoAccessor, makes it easier to modify the debug info format. Test: test-art-host Bug: 112311591 Bug: 77709234 Change-Id: Ice56a88951efa54dc07d88f2c228c01be4670e73
2018-07-23Elide ClinitCheck for superclasses with trivial init.Vladimir Marko
We cannot generally elide ClinitCheck for superclasses because of escaping instances of erroneous classes and because a subclass can be successfully initialized while the superclass is initializing and the subclass remains initialized even when the superclass initializer throws. However, for those superclasses that have trivial init, i.e. that class and its superclasses (and superinterfaces with default methods) initialize only their own static fields using constant values, there is no chance to end up in one of these weird situations and we can safely eliminate the ClinitCheck. The size of the aosp_taimen-userdebug prebuilts: - before: arm/boot*.oat: 16856928 arm64/boot*.oat: 19846592 oat/arm64/services.odex: 24662880 - after: arm/boot*.oat: 16848696 (-8.0KiB, -0.05%) arm64/boot*.oat: 19842320 (-4.2KiB, -0.02%) oat/arm64/services.odex: 24629952 (-32.2KiB, -0.13%) with minor changes to other app prebuilts. Test: Improved 478-checker-clinit-check-pruning. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: Pixel 2 XL boots. Test: testrunner.py --target --optimizing Bug: 62478025 Change-Id: I865f567443f1b7f172e5e6559d8eb3232adb7833
2018-07-23Fix a stale reference use.Vladimir Marko
It is unsafe to use an expression like klass.Get() == ResolveType() where the `ResolveType()` call can invalidate the plain pointer already retrieved from a Handle<>. We fix this in HInstructionBuilder::BuildLoadClass() by reordering the code and we change the prefix of related functions from "Get" to "Resolve" to better express their semantics. We also pass the ScopedObjectAccess helper all the way to the `ResolveClassFrom()` to avoid constructing a new one. Test: m test-art-host-gtest Test: testrunner.py --host Bug: 31113334 Change-Id: I13c1ea356386f28fdc9548da781982f9774080f1
2018-07-12Merge "Fix HClinitCheck elimination in instruction builder."Vladimir Marko
2018-07-12Fix HClinitCheck elimination in instruction builder.Vladimir Marko
To handle escaping instances of erroneous classes correctly, we can omit the HClinitCheck only when using a class in the static method of the very same class. Even for superclasses we need to do the check. The new test exposes the cases where we were previously diverging from the RI. Also clean up the CompilerDriver by inlining one function directly to the HInstructionBuild::IsInitialized(.) and removing some related functions that are no longer used. The size of the aosp_taimen-userdebug prebuilts: - before: arm/boot*.oat: 16891788 arm64/boot*.oat: 19815520 oat/arm64/services.odex: 20071624 - after: arm/boot*.oat: 16949532 (+56.4KiB, +0.34%) arm64/boot*.oat: 19889752 (+72.5KiB, +0.37%) oat/arm64/services.odex: 20224328 (+149.1KiB, +0.76%) with minor changes to other app prebuilts. Note: Some of that could be reclaimed by reinstating the old optimization for classes where no bytecode can be executed during initialization (no <clinit> to execute in that class or superclasses). Test: 174-escaping-instance-of-bad-class Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: testrunner.py --jvm -t 174 Test: Pixel 2 XL boots. Test: testrunner.py --target --optimizing Bug: 62478025 Change-Id: I41f026ea7fecc615c06e87f3b6cb847de0ede8a6
2018-07-10Don't use StringFactory.newEmptyString in compiled codeAlex Light
When compiling debuggable code we would compile a new-instance String instruction into a StringFactory.newEmptyString invoke. This additional invoke could be observed using tracing and is inconsistent with the interpreter, where the string is simply allocated directly. In order to bring these two modes into alignment we added a new AllocStringObject quick entrypoint that will be used instead of the normal AllocObject<...> entrypoints when allocating a string. This entrypoint directly allocates a new string in the same manner the interpreter does. Needs next CL for test to work. Bug: 110884646 Test: ./test/testrunner/testrunner.py --host --runtime-option=-Xjitthreshold:0 --jit Test: Manual inspection of compiled code. Change-Id: I7b4b084bcf7dd9a23485c0e3cd2cd04a04b43d3d
2018-07-04Merge "Handle String.<init> with a phi input."Nicolas Geoffray
2018-07-03Handle String.<init> with a phi input.Nicolas Geoffray
We wrongly assumed only irreducible loops could lead to this situation, but any loop can actually be in between a String NewInstance and a String.<init>. bug: 109666561 Test: 563-checker-fakestring Change-Id: I018a22f7e22c15e140252544415f51d544f7cc13
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 image_classes_ to CompilerOptions.Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: Ifb30e071d7b39ae939fc3f83d7eba82fd077c7e8
2018-06-11Merge "ART: Adds an entrypoint for invoke-custom"Treehugger Robot
2018-06-11ART: Adds an entrypoint for invoke-customOrion 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-08Remove DCHECK while investigating.Nicolas Geoffray
bug: 109666561 Test: m Change-Id: Ia10990d7caeb37d23d3096b087541aac9eea0c3d
2018-05-21ART: Simplify operands in InstructionBuilderTreehugger Robot
Test: art/test.py --host --optimizing --jit -r Change-Id: Ia408ae00637aa6a05a3ba54e1144ea00c6b335b5
2018-05-17Merge "Don't compile methods with irreducible loops and String.<init>."Nicolas Geoffray
2018-05-16Don't compile methods with irreducible loops and String.<init>.Nicolas Geoffray
The current code doesn't work when dex register aliases. bug: 78493232 Test: m Change-Id: I1c296f6dc914388844ae5eb7d84f3bd7d81e1f87
2018-05-14ART: Add dex::ProtoIndexOrion Hodson
Test: m -j32 test-art-host Change-Id: Ic2d2a7a43be1b8590b97cdf3729200b043ffc6a3
2018-05-11ART: Compiler support for const-method-handleOrion Hodson
Implemented as a runtime call. Bug: 66890674 Test: art/test.py --target -r -t 979 Test: art/test.py --target --64 -r -t 979 Test: art/test.py --host -r -t 979 Change-Id: I67f461c819a7d528d7455afda8b4a59e9aed381c
2018-05-10ART: Compiler support for const-method-typeOrion Hodson
Implemented as a runtime call. Bug: 66890674 Test: art/test.py --target -r -t 979 Test: art/test.py --target --64 -r -t 979 Test: art/test.py --host -r -t 979 Change-Id: I4b3d3969d455d0198cfe122eea8abd54e0ea20ee
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-19Move some remaining dex utilitiesDavid Sehr
There were several utilities related to building/walking/testing dex files that were not in libdexfile. This change consolidates these. Bug: 22322814 Test: make -j 50 test-art-host Change-Id: Id76e9179d03b8ec7d67f7e0f267121f54f0ec2e0
2018-02-15Pass the right dex_file/method_index for String.<init>.Nicolas Geoffray
Passing the dex file of the caller in instruction_builder.cc was problematic as this information get lost at the point of RTP. test: test.py Change-Id: I3f620b931544a538386d23c2456b182b3ed41091
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-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
2018-01-13Revert "Revert "Move quickening info logic to its own table""Mathieu Chartier
Bug: 71605148 Bug: 63756964 Test: test-art-target on angler This reverts commit 6716941120ae9f47ba1b8ef8e79820c4b5640350. Change-Id: Ic01ea4e8bb2c1de761fab354c5bbe27290538631
2018-01-12Revert "Move quickening info logic to its own table"Nicolas Geoffray
Bug: 71605148 Bug: 63756964 Seems to fail on armv7. This reverts commit f5245188d9c61f6b90eb30cca0875fbdcc493b15. Change-Id: I37786c04a8260ae3ec4a2cd73710126783c3ae7e
2018-01-11Move quickening info logic to its own tableMathieu Chartier
Added a table that is indexed by dex method index. To prevent size overhead, there is only one slot for each 16 method indices. This means there is up to 15 loop iterations to get the quickening info for a method. The quickening infos are now prefixed by a leb encoded length. This allows methods that aren't quickened to only have 1.25 bytes of space overhead. The value was picked arbitrarily, there is little advantage to increasing the value since the table only takes 1 byte per 4 method indices currently. JIT benchmarks do not regress with the change. There is a net space saving from removing 8 bytes from each quickening info since most scenarios have more quickened methods than compiled methods. For getting quick access to the table, a 4 byte preheader was added to each dex in the vdex file Removed logic that stored the quickening info in the CodeItem debug_info_offset field. The change adds a small quicken table for each method index, this means that filters that don't quicken will have a slight increase in size. The worst case scenario is compiling all the methods, this results in 0.3% larger vdex for this case. The change also disables deduping since the quicken infos need to be in dex method index order. For filters that don't compile most methods like quicken and speed-profile, there is space savings. For quicken, the vdex is 2% smaller. Bug: 71605148 Bug: 63756964 Test: test-art-host Change-Id: I89cb679538811369c36b6ac8c40ea93135f813cd
2018-01-05Create dex subdirectoryDavid Sehr
Move all the DexFile related source to a common subdirectory dex/ of runtime. Bug: 71361973 Test: make -j 50 test-art-host Change-Id: I59e984ed660b93e0776556308be3d653722f5223
2017-12-22Make CodeItem fields privateMathieu Chartier
Make code item fields private and use accessors. Added a hand full of friend classes to reduce the size of the change. Changed default to be nullable and removed CreateNullable. CreateNullable was a bad API since it defaulted to the unsafe, may add a CreateNonNullable if it's important for performance. Motivation: Have a different layout for code items in cdex. Bug: 63756964 Test: test-art-host-gtest Test: test/testrunner/testrunner.py --host Test: art/tools/run-jdwp-tests.sh '--mode=host' '--variant=X32' --debug Change-Id: I42bc7435e20358682075cb6de52713b595f95bf9
2017-12-12Merge "Add CodeItemDebugInfoAccessor"Mathieu Chartier
2017-12-12Do not pass DexFile to ClassLinker::Lookup/ResolveType().Vladimir Marko
The DexFile can be easily retrieved from the DexCache, so reduce the number of arguments that need to be passed. Also refactor the code to avoid doing the DexCache lookup twice and avoid unnecessary read barriers in the initial DexCache lookup (also for Lookup/ResolveField()). Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: Idea9aa42b6a5bade947e93e330b1abdb9d11b2da
2017-12-11Add CodeItemDebugInfoAccessorMathieu Chartier
Use it in places where DecodeDebugPositionInfo is called. Motivation: Abstract away calls to GetDebugInfoOffset. Bug: 63756964 Test: test-art-host Test: art/tools/run-jdwp-tests.sh '--mode=host' --debug Change-Id: I3ab2eff56c472cc717f49d17fd17eb0b8fde4062
2017-12-11Do not pass DexFile to ClassLinker::Lookup/ResolveMethod().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: I2e47280e7cb8b84595130c4abfb5ece18d7f5c75
2017-12-08Do not pass DexFile to ClassLinker::ResolveField*().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: I0579db64c63afea789c7c9ad8db81e37c9248e97
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-12-04Merge "Log at places we fail to compile."Nicolas Geoffray
2017-12-01Log at places we fail to compile.Nicolas Geoffray
Useful when diagnosing some compiler issues / limitations. Test: test.py Change-Id: I8759d0e78b0682b300ddcadfe02793432cab2036
2017-11-23Pass the debug_info_offset explicitly.Nicolas Geoffray
In order to use debug_info_offset for encoding implementation details, rewrite all indirect users of it to fetch it before calling DexFile methods. This allows keeping the DexFile interface clean of runtime considerations. Test: test.py Change-Id: I4591e0039b5f822f4409aae411071ecbe97082b1
2017-11-15Use intrinsic codegen for compiling intrinsic methods.Vladimir Marko
When compiling an intrinsic method, generate a graph that invokes the same method and try to compile it. If the call is actually intrinsified (or simplified to other HIR) and yields a leaf method, use the result of this compilation attempt, otherwise compile the actual code or JNI stub. Note that CodeGenerator::CreateThrowingSlowPathLocations() actually marks the locations as kNoCall if the throw is not in a catch block, thus considering some throwing methods (for example, String.charAt()) as leaf methods. We would ideally want to use the intrinsic codegen for all intrinsics that do not generate a slow-path call to the default implementation. Relying on the leaf method is suboptimal as we're missing out on methods that do other types of calls, for example runtime calls. This shall be fixed in a subsequent CL. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 67717501 Change-Id: I640fda7c22d4ff494b5ff77ebec3b7f5f75af652
2017-11-07Delete CodeItemIteratorMathieu Chartier
Replace uses with DexInstructionIterator. Bug: 63756964 Test: test-art-host-gtest Change-Id: I28c839c372edcb60583867355d46b14f8752d41b
2017-11-01Refactor DexInstructionIteratorMathieu Chartier
Add a way to get the dex PC for the "for each" use case. Bug: 67104794 Test: test-art-host Change-Id: I144c459c9a2a03ec8d56842280338d1f7ce1caf0
2017-10-11Use ScopedArenaAllocator for building HGraph.Vladimir Marko
Memory needed to compile the two most expensive methods for aosp_angler-userdebug boot image: BatteryStats.dumpCheckinLocked() : 21.1MiB -> 20.2MiB BatteryStats.dumpLocked(): 42.0MiB -> 40.3MiB This is because all the memory previously used by the graph builder is reused by later passes. And finish the "arena"->"allocator" renaming; make renamed allocator pointers that are members of classes const when appropriate (and make a few more members around them const). Test: m test-art-host-gtest Test: testrunner.py --host Bug: 64312607 Change-Id: Ia50aafc80c05941ae5b96984ba4f31ed4c78255e