summaryrefslogtreecommitdiff
path: root/compiler/optimizing/intrinsics.cc
AgeCommit message (Collapse)Author
2017-12-01Allow devirtualized method to be intrinsified. Mingyao Yang
For a invocation that's devirtualized to a different method, try to give intrinsics matching an opportunity before trying to inline it. Test: run-test on host. 638-checker-inline-cache-intrinsic. Change-Id: I51f70835db4c07575c58872a64a603a38dbcb89c
2017-11-29ART: Remove nested SOA in intrinsics code Orion Hodson
Removes a couple of unnecessary SOA instances. Bug: 69622155 Test: m -j32 Change-Id: I92e194096faeb4a83e4972d745bd8182ce8f820c
2017-11-28ART: Fix invoke-polymorphic compiler warnings Orion Hodson
Stops recognizing polymorphic signature methods as potential compiler intrinsics until implemented. Test: m -j32 Bug: 69622155 Bug: 65872996 Change-Id: I1392e7a91dfbb29d526dbe561f3a8c89e3218da8
2017-11-24Apply individual intrinsic recognition during inliner. Aart Bik
Rationale: Inliner could introduce new method calls, in particular it could change invoke-interface to invoke-virtual, which could expose new intrinsics. This situation happens, for example, in Kotlin generated code where String operations first go through the CharSequence interface. Rather than running a full new phase, we just recognize intrinsics when interface calls are replaced by virtual calls. This optimization boosts KotlinMicroItems by 100% Test: test-art-host test-art-target Change-Id: Ibd0519283d67ed6997b056e34b4eafdd49fcbc2d
2017-10-06ART: Use ScopedArenaAllocator for pass-local data. Vladimir Marko
Passes using local ArenaAllocator were hiding their memory usage from the allocation counting, making it difficult to track down where memory was used. Using ScopedArenaAllocator reveals the memory usage. This changes the HGraph constructor which requires a lot of changes in tests. Refactor these tests to limit the amount of work needed the next time we change that constructor. Test: m test-art-host-gtest Test: testrunner.py --host Test: Build with kArenaAllocatorCountAllocations = true. Bug: 64312607 Change-Id: I34939e4086b500d6e827ff3ef2211d1a421ac91a
2017-10-02ART: Add VarHandle fence intrinsics Orion Hodson
Bug: 65872996 Test: art/test/run-test --host --64 709 Test: art/test.py --host -j32 Change-Id: I6fa399bb00f0c83048ac2b4372b08e4b4b29ce7f
2017-10-01ART: Increase the number of potential instrinsics Orion Hodson
The new limit is 256 intrinsics. Adds additional sanity checks. Avoids setting the kAccPreviouslyWarm bit for intrinics (defaults to true). Bug: 65872996 Test: art/test.py --host -j32 Change-Id: I33ea67c9b6b8500b3ceb8a085358f075f6fcbb82
2017-08-11optimizing: Refactor statistics to use OptimizingCompilerStats helper Igor Murashkin
Remove all copies of 'MaybeRecordStat', replacing them with a single OptimizingCompilerStats::MaybeRecordStat helper. Change-Id: I83b96b41439dccece3eee2e159b18c95336ea933
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-02ART: Introduce thread-current-inl.h Andreas Gampe
Factor out Thread::Current() code into its own -inl file to remove transitive includes. This requires at the same time correcting mutex.h, i.e., moving some functions into mutex-inl.h. Test: m test-art-host Change-Id: I88f888b604e0897368d9b483edce6ce4332dd9c9
2017-05-31Add access flag for previously warm methods Mathieu Chartier
We want to know if the method was warm instead of just having a non zero counter. This is required if we want to not compile all of the startup methods, but still compile warm methods. Test: test-art-host ART_TEST_JIT=true Bug: 62200509 Change-Id: I6e04866f39f970b04b47342b7af5ed474e1f4172
2017-04-21ART: Clean up art_field.h Andreas Gampe
Clean up the header. Fix up other headers including the -inl file, in an effort to prune the include graph. Fix broken transitive includes by making includes explicit. Test: m Change-Id: I6ff2d6f89b741d8188e19426eccf4743fec688fc
2017-04-21ART: Clean up art_method.h Andreas Gampe
Clean up the header. Fix up other headers including the -inl file, in an effort to prune the include graph. Fix broken transitive includes by making includes explicit. Introduce new -inl files for method handles and reference visiting. Test: source build/envsetup.sh && lunch aosp_angler-userdebug && mmma art Test: source build/envsetup.sh && lunch aosp_mips64-userdebug && mmma art Change-Id: I8f60f1160c2a702fdf3598149dae38f6fa6bc851
2017-03-01Revert "Revert "Intrinsify Integer.valueOf."" Nicolas Geoffray
Fix heap poisoning. LOG INFO instead of ERROR to avoid run-test failures with --no-image. bug:30933338 Test: ART_HEAP_POISONING=true test-art-host test-art-target This reverts commit db7b44ac3ea80a722aaed12e913ebc1661a57998. Change-Id: I0b7d4f1eb11c62c9a3df8e0de0b1a5d8af760181
2017-02-28Revert "Intrinsify Integer.valueOf." Nicolas Geoffray
Heap poisoning missing jit-gcstress not optimizing it. bug:30933338 This reverts commit cd0b27287843cfd904dd163056322579ab4bbf27. Change-Id: I5ece1818afbca5214babb6803f62614a649aedeb
2017-02-27Intrinsify Integer.valueOf. Nicolas Geoffray
Improves performance of ArrayListStress and Ritz by ~10% and ~3%. Test: test-art-host test-art-target bug: 30933338 Change-Id: I639046e3a18dae50069d3a7ecb538a900bb590a1
2017-01-16Put inlined ArtMethod pointer in stack maps. Nicolas Geoffray
Currently done for JIT. Can be extended for AOT and inlined boot image methods. Also refactor the lookup of a inlined method at runtime to not rely on the dex cache, but look at the class loader tables. bug: 30933338 test: test-art-host, test-art-target Change-Id: I58bd4d763b82ab8ca3023742835ac388671d1794
2016-10-27Remove H[Reverse]PostOrderIterator and HInsertionOrderIterator. Vladimir Marko
Use range-based loops instead, introducing helper functions ReverseRange() for iteration in reverse order in containers. When the contents of the underlying container change inside the loop, use an index-based loop that better exposes the container data modifications, compared to the old iterator interface that's hiding it which may lead to subtle bugs. Test: m test-art-host Change-Id: I2a4e6c508b854c37a697fc4b1e8423a8c92c5ea0
2016-10-18Remove mirror:: and ArtMethod deps in utils.{h,cc} David Sehr
The latest chapter in the ongoing saga of attempting to dump a DEX file without having to start a whole runtime instance. This episode finds us removing references to ArtMethod/ArtField/mirror. One aspect of this change that I would like to call out specfically is that the utils versions of the "Pretty*" functions all were written to accept nullptr as an argument. I have split these functions up as follows: 1) an instance method, such as PrettyClass that obviously requires this != nullptr. 2) a static method, that behaves the same way as the util method, but calls the instance method if p != nullptr. This requires using a full class qualifier for the static methods, which isn't exactly beautiful. I have tried to remove as many cases as possible where it was clear p != nullptr. Bug: 22322814 Test: test-art-host Change-Id: I21adee3614aa697aa580cd1b86b72d9206e1cb24
2016-09-30Simplify our intrinsic recognizer. Nicolas Geoffray
- Use the modifiers for storing the intrinsic kind. - Delete dex_file_method_inliner and its associated map. This work was also motivated by the fact that the inline method analyzer leaks intrinsic tables, and even worse, might re-use a table from one dex file to another unrelated dex file in the presence of class unloading and the unlikely event of the dex files getting the same address. test: m test-art-host m test-art-target Change-Id: Ia653d2c72df13889dc85dd8c84997582c034ea4b
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
2016-09-23Clean-up sharpening and compiler driver. Nicolas Geoffray
Remove dependency on compiler driver for sharpening and dex2dex (the methods called on the compiler driver were doing unnecessary work), and remove the now unused methods in compiler driver. Also remove test that is now invalid, as sharpening always succeeds. test: m test-art-host m test-art-target Change-Id: I54e91c6839bd5b0b86182f2f43ba5d2c112ef908
2016-05-09Intrinsify String.length() and String.isEmpty() as HIR. Vladimir Marko
Use HArrayLength for String.length() in anticipation of changing the String.charAt() to HBoundsCheck+HArrayGet to allow the existing BCE to seamlessly work for strings. Use HArrayLength+HEqual for String.isEmpty(). We previously relied on inlining but we now want to apply the new intrinsics even when we do not inline, i.e. when compiling debuggable (as is currently the case for boot image) or when we hit inlining limits, i.e. depth, size, or the number of accumulated dex registers. Bug: 28330359 Change-Id: Iab9d2f6d2967bdd930a72eb461f27efe8f37c103
2016-03-07Unsafe: Recognize intrinsics for 1.8 java.util.concurrent Aart Bik
With unit test. Rationale: Recognizing the 1.8 methods as intrinsics is the first step towards providing efficient implementation on all architectures. Where not implemented (everywhere for now), the methods fall back to the JNI native or reference implementation. NOTE: needs iam's CL first! bug=26264765 Change-Id: Ife65e81689821a16cbcdd2bb2d35641c6de6aeb6
2016-02-26Implement fp to bits methods as intrinsics. Aart Bik
Rationale: Better optimization, better performance. Results on libcore benchmark: Most gain is from moving the invariant call out of the loop after we detect everything is a side-effect free intrinsic. But generated code in general case is much cleaner too. Before: timeFloatToIntBits() in 181 ms. timeFloatToRawIntBits() in 35 ms. timeDoubleToLongBits() in 208 ms. timeDoubleToRawLongBits() in 35 ms. After: timeFloatToIntBits() in 36 ms. timeFloatToRawIntBits() in 35 ms. timeDoubleToLongBits() in 35 ms. timeDoubleToRawLongBits() in 34 ms. bug=11548336 Change-Id: I6e001bd3708e800bd75a82b8950fb3a0fc01766e
2016-02-18Add statistics support for some optimizations Jean-Philippe Halimi
This patch adds support for the --dump-stats facility with some optimizations and fixes all build issues introduced by the patch: I68751b119a030952a11057cb651a3c63e87e73ea (which got reverted) Change-Id: I5af1f2a8cced0a1a55c2bb4d8c88e6f0a24ec879 Signed-off-by: Jean-Philippe Halimi <jean-philippe.halimi@intel.com>
2016-02-09Try to substitute constructor chains for IPUTs. Vladimir Marko
Match a constructor chain where each constructor either forwards some or all of its arguments to the next (i.e. superclass constructor or a constructor in the same class) and may pass extra zeros (of any type, including null), followed by any number of IPUTs on "this", storing either arguments or zeros, until we reach the contructor of java.lang.Object. When collecting IPUTs from the constructor chain, remove any IPUTs that store the same field as an IPUT that comes later. This is safe in this case even if those IPUTs store volatile fields because the uninitialized object reference wasn't allowed to escape yet. Also remove any IPUTs that store zero values as the allocated object is already zero initialized. Change-Id: If93022310bf04fe38ee741665ac4a65d4c2bb25f
2016-01-26Recognize common utilities as intrinsics. Aart Bik
Rationale: Recognizing these method calls as intrinsics already has major advantages (compiler knows about no-side-effects/no-throw properties). Next step is, of course, to implement these with native instructions on each architecture. Change-Id: I06fd12973238caec00d67b31b195d7f8807a538e
2016-01-20Implemented BitCount as an intrinsic. With unit test. Aart Bik
Rationale: Recognizing this important operation as an intrinsic has various advantages: (1) having the no-side-effects/no-throw allows for much more GVN/LICM/BCE. (2) Some architectures, like x86_64, provide direct support for this operation. Performance improvements on X86_64: CheckersEvalBench (32-bit bitboard): 27,210KNS -> 36,798KNS = + 35% ReversiEvalBench (64-bit bitboard): 52,562KNS -> 89,086KNS = + 69% Change-Id: I65d549b0469b7909b12c6611cdc34a8640a5751f
2015-12-30Improved side-effects/can-throw information on intrinsics. Aart Bik
Rationale: improved side effect and exception analysis gives many more opportunities for GVN/LICM/BCE. Change-Id: I8aa9b757d77c7bd9d58271204a657c2c525195b5
2015-12-10Optimizing: Add direct calls to math intrinsics Mark Mendell
Support the double forms of: cos, sin, acos, asin, atan, atan2, cbrt, cosh, exp, expm1, hypot, log, log10, nextAfter, sinh, tan, tanh Add these entries to the vector addressed off the thread pointer. Call the libc routines directly, which means that we have to implement the native ABI, not the ART one. For x86_64, that includes saving XMM12-15 as the native ABI considers them caller-save, while the ART ABI considers them callee-save. We save them by marking them as used by the call to the math function. For x86, this is not an issue, as all the XMM registers are caller-save. Other architectures will call Java as before until they are ready to implement the new intrinsics. Bump the OAT version since we are incompatible with old boot.oat files. Change-Id: Ic6332c3555c09393a17d1ad4daf62932488722fb Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
2015-12-02Revert "Revert "Don't use the compiler driver for method resolution."" Nicolas Geoffray
This reverts commit c88ef3a10c474045a3476a02ae75d07ddd3230b7. Change-Id: I0ed88a48b313a8d28bc39fae40631123aadb13ef
2015-12-01Revert "Don't use the compiler driver for method resolution." Nicolas Geoffray
Fails 425 in debuggable mode. This reverts commit 4db0bf9c4db6a09716c3388b7d2f88d534470339. Change-Id: I346df8f75674564fc4fb241c60f23e250fc7f0a7
2015-12-01Don't use the compiler driver for method resolution. Nicolas Geoffray
The compiler driver makes assumptions that don't hold for the optimizing compiler, and will for example always go to slow path for an invoke-super when there's no verified method. Also fix GenerateInvokeVirtual in the presence of intrinsics. Next change will address some of the TODOs in sharpening.cc. Change-Id: I2b0e543ee9b9bebcadb2d26de29e850c59ad58b9
2015-11-23Revert "Add stats support for existing optimizations" Nicolas Geoffray
Breaks the build. Please ensure your changes build. This reverts commit 06241b1b07fb031b7d2cf55f4b78d3444d07cc2d. Change-Id: I68b18f99a9882719bf6654d3313531a7965b8483
2015-11-22Add stats support for existing optimizations Jean-Philippe Halimi
This patch adds support for the --dump-stats facility with existing optimizations. Change-Id: I68751b119a030952a11057cb651a3c63e87e73ea Signed-off-by: Jean-Philippe Halimi <jean-philippe.halimi@intel.com>
2015-11-06MIPS32: java.lang.String.equals Chris Larsen
Add intrinsic support for String.equals on MIPS32. Change-Id: I2d184aa4d5dae7cdd4a89c2c902535692c9e7393
2015-10-12Intrinsify System.arraycopy. Nicolas Geoffray
Currently on x64, will do the other architectures in different changes. Change-Id: I15fbbadb450dd21787809759a8b14b21b1e42624
2015-09-22MIPS64: Implement miscellaneous bit manipulation intrinsics Chris Larsen
// java.lang.Double - doubleToRawLongBits(double) - longBitsToDouble(long) // java.lang.Float - floatToRawIntBits(float) - intBitsToFloat(int) // java.lang.Integer - numberOfLeadingZeros(int) - reverseBytes(int) - reverse(int) // java.lang.Long - numberOfLeadingZeros(long) - reverseBytes(long) - reverse(long) // java.lang.Short - reverseBytes(short) Change-Id: Ic8f8c4e7b584132e2282b4fd267453870fefbaaa
2015-09-11Merge "ARM/ARM64: Intrinsics - numberOfTrailingZeros, rotateLeft, rotateRight" Vladimir Marko
2015-09-11ARM/ARM64: Intrinsics - numberOfTrailingZeros, rotateLeft, rotateRight Scott Wakeling
Change-Id: I2a07c279756ee804fb7c129416bdc4a3962e93ed
2015-09-08Revert "Revert "Do a second check for testing intrinsic types."" Andreas Gampe
This reverts commit a14b9fef395b94fa9a32147862c198fe7c22e3d7. When an intrinsic with invoke-type virtual is recognized, replace the instruction with a new HInvokeStaticOrDirect. Minimal update for dex-cache rework. Fix includes. Change-Id: I1c8e735a2fa7cda4419f76ca0717125ef236d332
2015-08-24Revert "Do a second check for testing intrinsic types." Andreas Gampe
This reverts commit 4daa0b4c21eee46362b5114fb2c3800c0c7e7a36. If the intrinsic has a slow-path, like charAt, the slow-path logic will complain as it only understands direct slow-paths, not virtual calls. We should either override that decision in the slow-path, or replace the HInvokeVirtual when we're overriding the intrinsic choice. Bug: 23475673 Change-Id: If55fbc8c82d52e0e7a7aec2674ae2bd2b74b5c77
2015-08-21Do a second check for testing intrinsic types. Nicolas Geoffray
This allows to intrinsify calls made in a different dex file. Can't easily write a test because it depends on having inlined a method from boot classpath that calls an intrinsic. Once String.equals is implemented with the hybrid approach we can write one. Change-Id: I591d9496e236429943d6bfa7f8b20f576b1cfb9a
2015-08-19Add support to indicate whether intrinsics require a dex cache Agi Csaki
A structural change to indicate whether a given intrinsic requires access to a dex cache. I updated the needs_environment_ field to indicate whether an HInvoke needs an environment or a dex cache, and if an HInvoke represents an intrisified method, we utilize this field to determine if the HInvoke needs a dex cache. Bug: 21481923 Change-Id: I9dd25a385e1a1397603da6c4c43f6c1aea511b32
2015-08-13Merge "Intrinsics recognizer returns kNone for MIPS, MIPS64 instruction sets" Andreas Gampe
2015-08-12Structure for String.Equals intrinsic agicsaki
Added structure for implementing String.Equals intrinsics. There is no functional change at this point- the intrinsic is marked as unimplemented for all instruction sets and compilers. Bug: 21481923 Change-Id: Ic2a1e22a113ff6091581126f12e926478c011340
2015-08-12Intrinsics recognizer returns kNone for MIPS, MIPS64 instruction sets agicsaki
Since no intrinsics are implemented in MIPS or MIPS64, the intrinsics recognizer now does not mark methods as being intrinsified if the current instruction set is either MIPS or MIPS64. Change-Id: I9819ccd11d280e548623ad18add057eefefbf6d5
2015-08-12Add support to indicate whether intrinsics require an environment agicsaki
A structural change to indicate whether a given intrinsic requires access to an environment. I added a field to HInvoke objects to indicate if they need an environment whose default value is true and is only updated if an intrinsic is marked as not requiring an environment. At this point there is no functional change, as all intrinsics are marked as requiring an environment. This change adds the structure for future inliner work which will allow us to inline more intrinsified calls. Change-Id: I2930e3cef7b785384bf95b95a542d34af442f3b9
2015-08-04ARM/ARM64: Implement numberOfLeadingZeros intrinsic. Scott Wakeling
Change-Id: I4042fb7a0b75140475dcfca23e8f79d310f5333b