summaryrefslogtreecommitdiff
path: root/compiler/optimizing/code_generator.cc
AgeCommit message (Collapse)Author
2018-06-14Merge "Move some helper methods to DexRegisterLocation."David Srbecky
2018-06-14Move some helper methods to DexRegisterLocation.David Srbecky
Test: test-art-host-gtest-stack_map_test Change-Id: I0abab008159db023d531df69214cd3bb8c0639bd
2018-06-13Add Kind column to stack maps.David Srbecky
Add 'Kind' column to stack maps which marks special stack map types, and use it at run-time to add extra sanity checks. It will also allow us to binary search the stack maps. The column increases .oat file by 0.2%. Test: test-art-host-gtest-stack_map_test Change-Id: I2a9143afa0e32bb06174604ca81a64c41fed232f
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-08ART: Simplify invoke-polymorphic entrypointsOrion Hodson
Moves to pattern used by the interpreter bridge and writes the result in both the regular return register and the floating point result register. Add return value tests to 956-method-handles. Test: art/test.py --host -r -t 956 Test: art/test.py --target --32 -r -t 956 Test: art/test.py --target --64 -r -t 956 Change-Id: I7389d04b70b88e149682f6d656ab185e48bcbf66
2018-06-01Rewrite dex register map encoding in stackmaps.David Srbecky
Simplify code by encoding dex register maps using BitTables. The overall design is unchanged (bitmask+indices+catalogue). This CL saves ~0.4% of .oat file size. The dex register map decoding is factor of 3 faster now (based on the time to verify the register maps on Arm). This is not too surprising as the old version was O(n^2). It also reduces compiler arena memory usage by 11% since the BitTableBuilder is more memory efficient, we store less intermediate data, and we deduplicate most data on the fly. Test: test-art-host-gtest-stack_map_test Change-Id: Ib703a5ddf7f581280522d589e4a2bfebe53c26a9
2018-05-30Remove the CodeOffset helper class.David Srbecky
I need to reduce the StackMapEntry to a POD type so that it can be used in BitTableBuilder. Test: test-art-host-gtest-stack_map_test Change-Id: I5f9ad7fdc9c9405f22669a11aea14f925ef06ef7
2018-05-21Rewrite stackmap encoding code.David Srbecky
Remove most of the code related to handling of bit encodings. The design is still same; the encodings are just more implicit. Most of the complexity is replaced with a single BitTable class, which is a generic purpose table of tightly bit-packed integers. It has its own header which stores the bit-encoding of columns, and that removes the need to handle the encodings explicitly. Other classes, like StackMap, are accessors into the BitTable, with named getter methods for the individual columns. This CL saves ~1% of .oat file size (~4% of stackmap size). Test: test-art-host-gtest Change-Id: I7e92683753b0cc376300e3b23d892feac3670890
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-04-11Revert^2 "Compile link-time thunks in codegen."Vladimir Marko
The linker crash (the reason for revert) is flaky and maybe we shall not see it with this CL now that unrelated source code has changed. Test: Rely on TreeHugger Bug: 36141117 Bug: 77581732 This reverts commit 5806a9ec99b5494b511e84c74f494f0b3a8ebec5. Change-Id: I3a4a058847dff601681ba391abf45833424fa06d
2018-04-04Revert "Compile link-time thunks in codegen."Vladimir Marko
Reason for revert: This caused clang linker crash in several branches. Bug: 77581732 This reverts commit c9dd2207dfdab42586b1d6a5e7f11cf2fcea3a7a. Change-Id: I1923809083cf41c4f19e3e60df03ae80517aaedb
2018-04-04Compile link-time thunks in codegen.Vladimir Marko
Prepare for experimenting with Baker read barrier marking introspection entrypoints for JIT. Test: m test-art-host-gtest Test: Compare compiled boot*.oat before and after (no diff). Test: Pixel 2 XL boots. Bug: 36141117 Change-Id: Idb413a31b158db4bf89a8707ea46dd167a06f110
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-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-02-28Header library to remove dependence on runtime/David Sehr
Add a new header library to remove libdexfile and others' dependence on runtime (typically runtime/base) includes in libdexfile. Also a small step to tease dexlayout and profman away from relying on these as well. Bug: 22322814 Test: make -j 50 checkbuild make -j 50 test-art-host-gtest Change-Id: I38e2fe399a75f4bc6318c77a71954c00ea73ec2b
2018-01-08Clean up CodeItemAccessors and Compact/StandardDexFileMathieu Chartier
Change constructor to use a reference to a dex file. Remove duplicated logic for GetCodeItemSize. Bug: 63756964 Test: test-art-host Change-Id: I69af8b93abdf6bdfa4454e16db8f4e75883bca46
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
2018-01-02Remove CodeItem accessor functionsMathieu Chartier
These are replaced by the accessor helpers. Bug: 63756964 Test: test-art-host Test: test/testrunner/testrunner.py --host -j30 Change-Id: Ic93d60b68b684eeb5f69be286b4e15b8f8f97542
2017-12-14Clean up InstanceOf/CheckCast.Vladimir Marko
Avoid read barriers for boot image class InstanceOf. Boot image classes are non-moveable, so comparing them against from-space and to-space reference yields the same result. Change the notion of a "fatal" type check slow path to mean that the runtime call shall not return by normal path, i.e. "fatal" now includes certainly throwing in a try-block. This avoids unnecessary code to restore registers and jump back. For boot image classes the CheckCast comparisons do not need read barriers (for the same reason as for InstanceOf), so we shall not have any false negatives and can treat the check's slow paths as final in the same cases as in non-CC configs. Boot image size for aosp_taimen-userdebug in AOSP master: - before: arm boot*.oat: 37075460 arm64 boot*.oat: 43431768 - after: arm boot*.oat: 36894292 (-177KiB, -0.5%) arm64 boot*.oat: 43201256 (-225KiB, -0.5%) Also remove some obsolete helpers from CodeGenerator. Test: Additional test in 603-checker-instanceof. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: Pixel 2 XL boots. Test: testrunner.py --target --optimizing Bug: 12687968 Change-Id: Ib1381084e46a10e70320dcc618f0502ad725f0b8
2017-12-04Minor cleanup in CodeGenerator::RecordPcInfo().Vladimir Marko
And remove HInvokeInterface::GetDexMethodIndex() as the base class version is identical. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I489bff5b3f624eec19269487529e29d58f068960
2017-11-27Fix stats reporting over 100% methods compiled.Vladimir Marko
Add statistics for intrinsic and native stub compilation and JIT failing to allocate memory for committing the code. Clean up recording of compilation statistics. New statistics when building aosp_taimen-userdebug boot image with --dump-stats: Attempted compilation of 94304 methods: 99.99% (94295) compiled. OptStat#AttemptBytecodeCompilation: 89487 OptStat#AttemptIntrinsicCompilation: 160 OptStat#CompiledNativeStub: 4733 OptStat#CompiledIntrinsic: 84 OptStat#CompiledBytecode: 89478 ... where 94304=89487+4733+84 and 94295=89478+4733+84. Test: testrunner.py -b --host --optimizing Test: Manually inspect output of building boot image with --dump-stats. Bug: 69627511 Change-Id: I15eb2b062a96f09a7721948bcc77b83ee4f18efd
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-03Merge "Refactor DexInstructionIterator"Mathieu Chartier
2017-11-02ART: Make InstructionSet an enum class and add kLast.Vladimir Marko
Adding InstructionSet::kLast shall make it easier to encode the InstructionSet in fewer bits using BitField<>. However, introducing `kLast` into the `art` namespace is not a good idea, so we change the InstructionSet to an enum class. This also uncovered a case of InstructionSet::kNone being erroneously used instead of vixl32::Condition::None(), so it's good to remove `kNone` from the `art` namespace. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I6fa6168dfba4ed6da86d021a69c80224f09997a6
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-11-01ART: Intrinsify polymorphic signature methodsOrion Hodson
Adds VarHandle accessor method to list of intrinsics. Adds code to interpreter to ensure intrinsics with polymorphic signatures are initialized. Rename most uses of InvokePolymorphic to InvokeMethodHandle (and similar changes) to be clear that the particular code path applies to MethodHandle instances rather than VarHandle. Change-Id: Ib74865124a1e986badc0a7c4bb3d782af07225d4 Bug: 65872996 Test: art/test.py --host
2017-10-17Use ScopedArenaAllocator for code generation.Vladimir Marko
Reuse the memory previously allocated on the ArenaStack by optimization passes. This CL handles only the architecture-independent codegen and slow paths, architecture-dependent codegen allocations shall be moved to the ScopedArenaAllocator in a follow-up. Memory needed to compile the two most expensive methods for aosp_angler-userdebug boot image: BatteryStats.dumpCheckinLocked() : 19.6MiB -> 18.5MiB (-1189KiB) BatteryStats.dumpLocked(): 39.3MiB -> 37.0MiB (-2379KiB) Also move definitions of functions that use bit_vector-inl.h from bit_vector.h also to bit_vector-inl.h . Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 64312607 Change-Id: I84688c3a5a95bf90f56bd3a150bc31fedc95f29c
2017-10-12Fix using LiveIntervals beyond their lifetime.Vladimir Marko
Fixes a bug introduced by https://android-review.googlesource.com/504041 Test: test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 64312607 Change-Id: I7fd2d55c2a657f736eaed7c94c41d1237ae2ec0b
2017-10-09Use ScopedArenaAllocator for register allocation.Vladimir Marko
Memory needed to compile the two most expensive methods for aosp_angler-userdebug boot image: BatteryStats.dumpCheckinLocked() : 25.1MiB -> 21.1MiB BatteryStats.dumpLocked(): 49.6MiB -> 42.0MiB This is because all the memory previously used by Scheduler is reused by the register allocator; the register allocator has a higher peak usage of the ArenaStack. And continue the "arena"->"allocator" renaming. Test: m test-art-host-gtest Test: testrunner.py --host Bug: 64312607 Change-Id: Idfd79a9901552b5147ec0bf591cb38120de86b01
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-20Refactor compiled_method.h .Vladimir Marko
Move LinkerPatch to compiler/linker/linker_patch.h . Move SrcMapElem to compiler/debug/src_map_elem.h . Introduce compiled_method-inl.h to reduce the number of `#include`s in compiled_method.h . Test: m test-art-host-gtest Test: testrunner.py --host Change-Id: Id211cdf94a63ad265bf4709f1a5e06dffbe30f64
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-14Remove the old ARM code generator from ART's Optimizing compiler.Roland Levillain
The AArch32 VIXL-based code generator has been the default ARM code generator in ART for some time now. The old ARM code generator does not compile anymore; retiring it. Test: test.py Bug: 63316036 Change-Id: Iab8fbc4ac73eac2c1a809cd7b22fec6b619755db
2017-06-08ART: Refactor bit_utils and stl_utilAndreas Gampe
Move iterator code from bit_utils.h into bit_utils_iterator.h. Move Identity into stl_util_identity.h. Remove now unnecessary includes, and fix up transitive users. Test: m Change-Id: Id1ce9cda66827c5d00584f39ed310b6b37629906
2017-06-07Merge "Replace invoke kind kDexCacheViaMethod with kRuntimeCall."Vladimir Marko
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-06-05Merge "Revert^3 "ART: Reference.getReferent intrinsic for x86 and x86_64""Vladimir Marko
2017-06-05Merge "Rename kDexCacheViaMethod to kRuntimeCall for HLoadClass/String."Vladimir Marko
2017-06-02Revert^3 "ART: Reference.getReferent intrinsic for x86 and x86_64"Vladimir Marko
Reverting because GenerateCalleeMethodStaticOrDirectCall() prevents replacing kDexCacheViaMethod with kRuntimeCall where we would not retrieve the target method at all and leave the runtime to retrieve and call it just like for unresolved methods. The intrinsic should be re-implemented by loading the flags through HLoadClass. Note that the intrinsic was unimplemented for CC. Test: Rely on TreeHugger. Bug: 32535355 Bug: 30627598 This reverts commit 288c7a8664e516d7486ab85267050e676e84cc39. Change-Id: Ia22864553ff55562897571e180b11926ccd51588
2017-06-02ART: Introduce thread-current-inl.hAndreas 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-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-06-02Delay allocating environment locations.Vladimir Marko
Many environments are killed before we get to the register allocation, so the early allocation of their locations was simply wasting memory. For the most expensive method of a certain app, this reduces EnvLocations with 64-bit dex2oat from 8657200 to 5339712 (-3.16MiB). Test: m test-art-host Test: testrunner.py --host Bug: 33650849 Change-Id: I70a02fc3c7ec87b54a87e989e1239dc4acfcf18b
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-04-21ART: Add object-readbarrier-inl.hAndreas Gampe
Move some read-barrier code into a new header. This prunes the include tree for the concurrent-copying collector. Clean up other related includes. Test: mmma art Change-Id: I40ce4e74f2e5d4c692529ffb4df933230b6fd73e
2017-04-21ART: Clean up art_method.hAndreas 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