summaryrefslogtreecommitdiff
path: root/compiler/optimizing/instruction_builder.cc
AgeCommit message (Collapse)Author
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-09-27Add DexInstructionIterator and use it a few placesMathieu Chartier
Motivation: Want to start abstracting away dex specific functionality to enable CompactDex. Adding an iterator will enable CompactDex iteration to work differently than normal dex iteration. Will eventually replace CodeItemIterator. Bug: 63756964 Test: test-art-host Change-Id: I90e67c1a994b7698aaac0523a82816b0a003fbdc
2017-09-25ART: Introduce compiler data type.Vladimir Marko
Replace most uses of the runtime's Primitive in compiler with a new class DataType. This prepares for introducing new types, such as Uint8, that the runtime does not need to know about. Test: m test-art-host-gtest Test: testrunner.py --host Bug: 23964345 Change-Id: Iec2ad82454eec678fffcd8279a9746b90feb9b0c
2017-09-11ART: Clean up WellKnownClasses include.Andreas Gampe
Delete an unnecessary include propagating the WellKnownClasses far to widely, and instead fix some transitive users. Test: m Change-Id: I88fd49057afe4ddcc548b979baafb8b8682d78ae
2017-08-11optimizing: Add statistics for # of constructor fences added/removedIgor Murashkin
Statistics are attributed as follows: Added because: * HNewInstances requires a HConstructorFence following it. * HReturn requires a HConstructorFence (for final fields) preceding it. Removed because: * Optimized in Load-Store-Elimination. * Optimized in Prepare-For-Register-Allocation. Test: art/test.py Bug: 36656456 Change-Id: Ic119441c5151a5a840fc6532b411340e2d68e5eb
2017-08-11optimizing: Refactor statistics to use OptimizingCompilerStats helperIgor Murashkin
Remove all copies of 'MaybeRecordStat', replacing them with a single OptimizingCompilerStats::MaybeRecordStat helper. Change-Id: I83b96b41439dccece3eee2e159b18c95336ea933
2017-07-24ART: Include cleanupAndreas 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-07-20ART: Change method lookup to be more consistent to JLS and the RI.Vladimir Marko
The method lookup for different invoke types was previously widely different and didn't work well with the dex cache method array where we have only a single slot for each MethodId. The new behavior is to perform the same lookup for all cases, distinguishing only between interface and non-interface referencing class, and to further align the behavior with the JLS and the RI. Where the JLS conflicts with the RI, we follow the JLS semantics. The new lookup for class methods first searches the methods declared in the superclass chain (ignoring "copied" methods) and only then looks in the "copied" methods. If the search in the superclass chain finds a method that has not been inherited (i.e. either a private method or a package-access method where one of the classes in the chain does not belong to the same package, see JLS 8.4.8), we still search the "copied" methods as there may actually be a method inherited from an interface. This follows the JLS semantics where inherited methods are included in the search (JLS 15.12.2.1) but conflicts with the RI where the private or package-access method takes precedence over methods inherited from interfaces. Note that this search can find an accessible method that is not inherited by the qualifying type, either for a package access method when the referrer is in the same package but the qualifying type is in another package, or for a private method where the referrer is in the same class but the qualifying type is actually a subclass. For the moment we allow such calls and we shall consider whether to throw an IncompatibleClassChangeError in this situation in future to comply with JLS 15.12.4.3. The new lookup for interface methods searches the interface class, then all the superinterfaces and then the java.lang.Object class, see implicitly declared methods in interfaces, JLS 9.2. The search for the maximally-specific non-abstract superinterface method is not yet implemented, but the difference should be difficult to observe as the usual subsequent call to FindVirtualMethodForInterface() should yield the same result for any matching method. The new test 162-method-idx-clash exposes several cases where we previously completely messed up due to the effects of the DexCache, or where we were out of line with the RI. It also tests a case where the JLS and the RI disagree and we follow the JLS. Test: art/test/run-test --host --jvm 162-method-resolution Test: m test-art-host-gtest Test: testrunner.py --host Test: testrunner.py --host --interp-ac Test: Nexus 6P boots. Test: testrunner.py --target Bug: 62855082 Bug: 30627598 Change-Id: If450c8cff2751369011d649c25d28a482a2c61a3
2017-07-12Reduce quicken info sizeMathieu Chartier
Move the quicken info from using a map of <dex pc, index> to an array of indices. Removed leb encoding since it is harmful for 16 bit indices. The map is indexed by the dequickenable instruction index from the start of the code item. Numbers for a certain large app compiled with quicken filter: dex2oat native alloc: 85345936B -> 81527072B oat file size: 9068968B -> 8659368B vdex file size: 90479120B -> 86321184B Bug: 63467744 Bug: 36457259 Test: test-art-host (cherry picked from commit 959f348acabc48efbb18c547dad6300c0f610c1c) Change-Id: I85546d8cd409cbf96140cbdddabd7e228797b9e3
2017-06-06Replace invoke kind kDexCacheViaMethod with kRuntimeCall.Vladimir Marko
In preparation for replacing the dex cache method array with a hash-based array, get rid of one unnecessary use. This method load kind is currently used only on mips for irreducible loops and OSR, so this should have no impact on x86/x86-64/arm/arm64. Test: m test-art-host-gtest Test: testrunner.py --host Test: Repeat the above tests with manually changing kDexCachePcRelative to kRuntimeCall in sharpening.cc. (Ignore failures in 552-checker-sharpening.) Bug: 30627598 Change-Id: Ifce42645f2dcc350bbb88c2f4642e88fc5f98152
2017-05-23optimizing: Fix a potential nullptr dereferenceGeorge Burgess IV
Operator precedence in C++ means the DCHECK was parsed as DCHECK((allocation != nullptr && allocation->IsNewInstance()) || allocation->IsNewArray()) Caught by the static analyzer: art/compiler/optimizing/instruction_builder.cc:1004:14: warning: Called C++ object pointer is null [clang-analyzer-core.CallAndMessage] Bug: None Test: Reran the static analyzer. No more nullptr complaints. m builds the file fine, as well. Change-Id: Iad94719fc013f1883746128e066452994740f171
2017-05-18optimizing: Build HConstructorFence for HNewArray/HNewInstance nodesIgor Murashkin
Also fixes: * LSE, code_sinking to keep optimizing new-instance if it did so before * Various tests to expect constructor fences after new-instance Sidenote: new-instance String does not get a ConstructorFence; the special StringFactory calls are assumed to be self-fencing. Metric changes on go/lem: * CodeSize -0.262% in ART-Compile (ARMv8) * RunTime -0.747% for all (linux-armv8) (No changes expected to x86, constructor fences are no-op). The RunTime regression is temporary until art_quick_alloc_* entrypoints have their DMBs removed in a follow up CL. Test: art/test.py Bug: 36656456 Change-Id: I6a936a6e51c623e1c6b5b22eee5c3c72bebbed35
2017-05-02optimizing: constructor fence redundancy elimination - remove dmb after LSEIgor Murashkin
Part one of a few upcoming CLs to optimize constructor fences. This improves load-store-elimination; all singleton objects that are not returned will have their associated constructor fence removed. If the allocation is removed, so is the fence. Even if allocation is not removed, fences can sometimes be removed. This change is enabled by tracking the "this" object associated with the constructor fence as an input. Fence inputs are considered weak; they do not keep the "this" object alive; if the instructions for "this" are all deleted, the fence can also be deleted. Bug: 36656456 Test: art/test.py --host && art/test.py --target Change-Id: I05659ab07e20d6e2ecd4be051b722726776f4ab1
2017-04-10optimizing: do not illegally remove constructor barriers after inliningIgor Murashkin
Remove the illegal optimization that destroyed constructor barriers after inlining invoke-super constructor calls. --- According to JLS 7.5.1, "Note that if one constructor invokes another constructor, and the invoked constructor sets a final field, the freeze for the final field takes place at the end of the invoked constructor." This means if an object is published (stored to a location potentially visible to another thread) inside of an outer constructor, all final field stores from any inner constructors must be visible to other threads. Test: art/test.py Bug: 37001605 Change-Id: I3b55f6c628ff1773dab88022a6475d50a1a6f906
2017-03-14Revert^6 "Hash-based dex cache type array."Vladimir Marko
Fixed ImageWriter to write class table also if it contains only boot class loader classes. Added a regression test and added extra checks for debug-build to verify that dex cache types from app image are also in the class table. Removed some unnecessary debug output. Test: 158-app-image-class-table Bug: 34839984 Bug: 30627598 Bug: 34659969 This reverts commit 0b66d6174bf1f6023f9d36dda8538490b79c2e9f. Change-Id: I6a747904940c6ebc297f4946feef99dc0adf930c
2017-03-13Revert^5 "Hash-based dex cache type array."Vladimir Marko
For app images, ImageWriter does not add boot image classes to the app image class table even though it keeps them in the dex caches. The reason for that is unknown, the code looks OK. Bug: 34839984 Bug: 30627598 Bug: 34659969 Also reverts "Improve debugging output for a crash." This reverts commits bfb80d25eaeb7a604d5dd25a370e3869e96a33ab, 8dd56fcb3196f466ecaffd445397cb11ef85f89f. Test: testrunner.py --host Change-Id: Ic8db128207c07588c7f11563208ae1e85c8b0e84
2017-03-08Merge "Inlining a few small methods based on profiling dex2oat with perf."Mingyao Yang
2017-03-08Inlining a few small methods based on profiling dex2oat with perf.Mingyao Yang
Test: m test-art-host Change-Id: I6313158e59592d8d132154523be9c82dda3c7eb8
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-20Revert^4 "Hash-based dex cache type array."Vladimir Marko
Added extra output to the abort message to collect more data when we hit the crash. Added extra check when loading an app image to verify that the class table isn't already broken. Test: testrunner.py --host Bug: 34839984 Bug: 30627598 Bug: 34659969 This reverts commit 5812e20ff7cbc8efa0b8d7486ada2f58840a6ad5. Change-Id: I9bb442a184c236dcb75b3e42a095f39cd6bee59d
2017-02-14ART: Add operator == and != with nullptr to HandleAndreas Gampe
Get it in line with ObjPtr and prettify our code. Test: m Change-Id: I1322e2a9bc7a85d7f2441034a19bf4d807b81a0e
2017-02-13Revert^3 "Hash-based dex cache type array."Mathieu Chartier
Assert failing for "earchbox:search": F zygote64: class_linker.cc:4612] Check failed: handle_scope_iface.Get() != nullptr Test: m test-art-host Bug: 34839984 Bug: 30627598 Bug: 34659969 This reverts commit 85c0f2ac03417f5125bc2ff1dab8109859c67d5c. Change-Id: I39846c20295af5875b0f945be7035c73ded23135
2017-02-10Revert^2 "Hash-based dex cache type array."Vladimir Marko
The reason for the revert was fixed by https://android-review.googlesource.com/332666 . We now enable clearing dex cache types in test 155 from that CL. Also avoid an unnecessary store in LookupResolvedTypes() and prevent verifier from messing up the dex cache types. Test: m test-art-host Bug: 34839984 Bug: 30627598 Bug: 34659969 This reverts commit d16363a93053de0f32252c7897d839a46aff14ae. Change-Id: Ie8603cfa772e78e648d005b0b6eae59062ae729d
2017-02-06Remove obsolete restriction with allocations and dex cache.Nicolas Geoffray
We used to rely on being in the same dex file for doing allocations, but not anymore. Test: ART_TEST_JIT=true test-art-host Change-Id: Iabc27469dadea6bfe39054e4be305e620818ac99
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-01Revert "Hash-based dex cache type array."Vladimir Marko
Reverting to work around some programs crashing with Check failed: handle_scope_iface.Get() != nullptr. though the reason for the failure not yet understood. Test: m test-art-host Bug: 34839984 Bug: 30627598 Bug: 34659969 Bug: 30419309 This reverts commit ec7862283dd49f5a58d0ac45960ce27c2f7671b8. Change-Id: Ifded663633082f1e59e5b6ff2e026dc559bd6b82
2017-01-30Hash-based dex cache type array.Vladimir Marko
Test: m test-art-host (Interpreter, Optimizing, JIT) Test: m test-art-target on Nexus 6P (Interpreter, Optimizing, JIT) Test: Nexus 6P boots Test: m valgrind-test-art-host Bug: 30627598 Bug: 34659969 Bug: 30419309 Change-Id: Ic00eda89e58088a3573fc9ec0ad04c0e69e161d1
2017-01-23Fix some typos in ART.Roland Levillain
Test: m build-art-host Test: m cpplint-art Change-Id: Ifc6ce3d0d645c4a8dca72dd483fc03fc05077130
2017-01-19Revert "Revert "Load the array class in the compiler for allocations.""Nicolas Geoffray
This reverts commit fee255039e30c1c3dfc70c426c3d176221c3cdf9. Change-Id: I02b45f9a659d872feeb35df40b42c1be9878413a
2017-01-19Revert "Load the array class in the compiler for allocations."Hiroshi Yamauchi
libcore test fails. This reverts commit cc99df230feb46ba717252f002d0cc2da6828421. Change-Id: I5bac595acd2b240886062e8c1f11f9095ff6a9ed
2017-01-18Load the array class in the compiler for allocations.Nicolas Geoffray
Removing one other dependency for needing to pass the current method, and having dex_cache_resolved_types_ in ArtMethod. oat file increase: - x64: 0.25% - arm32: 0.30% - x86: 0.28% test: test-art-host, test-art-target Change-Id: Ibca4fa00d3e31954db2ccb1f65a584b8c67cb230
2017-01-17Merge "Put the resolved class in HLoadClass."Nicolas Geoffray
2017-01-17Merge "Put inlined ArtMethod pointer in stack maps."Nicolas Geoffray
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-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
2017-01-15Revert "Revert "ART: Compiler support for invoke-polymorphic.""Orion Hodson
This reverts commit 0fb5af1c8287b1ec85c55c306a1c43820c38a337. This takes us back to the original change and attempts to fix the issues encountered: - Adds transition record push/pop around artInvokePolymorphic. - Changes X86/X64 relocations for MacSDK. - Implements MIPS entrypoint for art_quick_invoke_polymorphic. - Corrects size of returned reference in art_quick_invoke_polymorphic on ARM. Bug: 30550796,33191393 Test: art/test/run-test 953 Test: m test-art-run-test Change-Id: Ib6b93e00b37b9d4ab743a3470ab3d77fe857cda8
2017-01-12Revert "Revert "Make object allocation entrypoints only take a class.""Nicolas Geoffray
This reverts commit f7aaacd97881c6924b8212c7f8fe4a4c8721ef53. Change-Id: I6756cd1e6110bb45231f62f5e388f16c044cb145
2017-01-12Revert "Make object allocation entrypoints only take a class."Hiroshi Yamauchi
960-default-smali64 is failing. This reverts commit 2b615ba29c4dfcf54aaf44955f2eac60f5080b2e. Change-Id: Iebb8ee5a917fa84c5f01660ce432798524d078ef
2017-01-11Make object allocation entrypoints only take a class.Nicolas Geoffray
Change motivated by: - Dex cache compression: having the allocation fast path do a dex cache lookup will be too expensive. So instead, rely on the compiler having direct access to the class (either through BSS for AOT, or JIT tables for JIT). - Inlining: the entrypoints relied on the caller of the allocation to have the same dex cache as the outer method (stored at the bottom of the stack). This meant we could not inline methods from a different dex file that do allocations. By avoiding the dex cache lookup in the entrypoint, we can now remove this restriction. Code expansion on average for Docs/Gms/FB/Framework (go/lem numbers): - Around 0.8% on arm64 - Around 1% for x64, arm - Around 1.5% on x86 Test: test-art-host, test-art-target, ART_USE_READ_BARRIER=true/false Test: test-art-host, test-art-target, ART_DEFAULT_GC_TYPE=SS ART_USE_TLAB=true Change-Id: I41f3748bb4d251996aaf6a90fae4c50176f9295f
2017-01-10Recognize getClass() in RTP.Nicolas Geoffray
Also always keep around the resolved field in related HInstructions to avoid resolving it again and again. Test: test-art-host, 631-checker-get-class Change-Id: I3bc6be11f3eb175c635e746006f39865947e0669
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-11-29ART: Add dex::StringIndexAndreas Gampe
Add abstraction for uint32_t string index. Test: m test-art-host Change-Id: I917c2881702fe3df112c713f06980f2278ced7ed
2016-11-21ART: Add dex::TypeIndexAndreas Gampe
Add abstraction for uint16_t type index. Test: m test-art-host Change-Id: I47708741c7c579cbbe59ab723c1e31c5fe71f83a
2016-11-18Add dequickening support.Nicolas Geoffray
Both vdex and BCI require full dequickening support. This change implements dequickening by using the existing encoded quickening, and adds the checkcast quickening to that encoding. bug: 30937355 bug: 32369913 Test: dex_to_dex_decompiler_test.cc test-art-host Change-Id: Ie95f46946d59b28157d6e47dcf4a859be032d1c3
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-29Clean up ScopedThreadStateChange to use ObjPtrMathieu 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-28ART: Factor out IMT from ArtMethodAndreas Gampe
Move IMT Conflict Table to its own file. Move IMT index computation to ImTable. In preparation for code using this independent of specific ArtMethods. Bug: 31594153 Test: m test-art-host Change-Id: Ifd6e304bb86724c5284984c4655c43d3af357f84
2016-09-27Merge "Cleanup String.<init> handling."Nicolas Geoffray