History log of /art/compiler/elf_writer_quick.cc
Revision Date Author Comments
316a2186b7fa9e03187d45ac0fa320f4dff1f3df 18-Sep-2015 Douglas Leung <douglas.leung@imgtec.com> Add Mips abiflags section to the oatfile.

Once this patch is merged, then the workaround patch:
0acb15ead6a554a6879b29fd90726b9ea8fd98c4
in bionic can be removed.

Change-Id: Ie06a3c4e384a23a77db7d04a2508edbf3a6d3933
5d8112029d0e085c5a0099257daa4c7e29c12310 08-Mar-2016 David Srbecky <dsrbecky@google.com> Propagate InstructionSetFeatures to ElfBuilder.

This is subset of CL171665 and it separates it into two.
It will be needed to generate .MIPS.abiflags ELF section.

Change-Id: I5557e7cb98d0fa1dc57c85cf6161e119c6d50a1a
944da603cde59a4277f3bbc31d860a90842a1a2a 19-Feb-2016 Vladimir Marko <vmarko@google.com> ART: Allow method references across oat files for multi-image, 2nd attempt.

These were disabled because we didn't have sufficient
information about the multi-image layout when processing
link-time patches in OatWriter. This CL refactors the
ELF file creation so that the information is available.

Also clean up ImageWriter to use oat file indexes instead
of filenames and avoid reopening the oat file to retrieve
the checksum.

Change-Id: Icc7b528deca29da1e473c8f079521a36d6c4892f
45724f9a0cc38dbb3071beb3eeab96499868b49c 17-Feb-2016 Vladimir Marko <vmarko@google.com> Revert "Allow method references across oat files for multi-image."

Breaks Quick tests.

This reverts commit 6065402316da2b51eed5fc34cffbd991766bd408.

Change-Id: I8a5469ba7cea5f46b85cb489b3e0ef06ed548f03
6065402316da2b51eed5fc34cffbd991766bd408 16-Feb-2016 Vladimir Marko <vmarko@google.com> Allow method references across oat files for multi-image.

These were disabled because we didn't have sufficient
information about the multi-image layout when processing
link-time patches in OatWriter. This CL refactors the
ELF file creation so that the information is available.

Change-Id: I6f2e8dc8572d143c72cc2693bb0ba4fd76f889ab
c5bfa97c47d656b76f297af8abcd5f7502987399 05-Feb-2016 David Srbecky <dsrbecky@google.com> Split elf_writer_debug.cc to several files.

Refactoring only. The file has grown significantly over time,
and it is time to split it so it can be better managed.

Change-Id: Idce0231718add722292f4701df353d5baf31de5f
4fda4eb799c95be266f52aaf3461a440ea86b841 05-Feb-2016 David Srbecky <dsrbecky@google.com> Move code related to debug info generation to its own directory.

debug/dwarf/ contains helper classes which hide the details
of the DWARF file format. It acts as independent DWARF library.

debug/ contains ART-specific code which generates ELF debug
sections (which includes non-DWARF sections like .symtab).

Change-Id: Id351f604e4e64be2ca395a78324ea02e30481497
370339cb8edd91ec8732e0c97cea1f0556cfcc11 05-Feb-2016 David Srbecky <dsrbecky@google.com> Do not emit DWARF debug info if there are no methods.

Change-Id: I43406e54b454dbac45980d5c5edd90cd5593b9fd
0c4572e8c874de279463af22268d588471f40d3e 22-Jan-2016 David Srbecky <dsrbecky@google.com> Generate mini-debug-info on separate thread.

The generation and compression of mini-debug-info is a lot of work.
However, we can do it on background thread when the main thread is
busy with .rodata and .text related I/O.

Change-Id: I514f1db3cb50aa250639f3ef697faa9bc9976d12
ae5d2738a2b941b543c3fd478af910d4cd16f2ba 05-Feb-2016 David Srbecky <dsrbecky@google.com> Change the method which generates DWARF mini-debug-info.

This splits some code from CL198651. It moves the WriteSection
call out one level and does not otherwise change behaviour.

Change-Id: I7dc1c7c08b577b50bf6fa366a9b0ca757048b81e
579942fc26f8a0b0ff1d909d19086fca6d2396a3 28-Jan-2016 David Srbecky <dsrbecky@google.com> Reduce the size of native debug info generated by JIT.

Remove some ELF file overheads:
- Do not produce program headers.
- Do not page align strtab.
- Do not write oat_patches sections.

This more than halves the size of JIT native debug info.
Since we generate many small entries, the overheads added up.

Change-Id: I27d95548c61e2e38c3683d6f5eb870a2db6e812d
5b1c2ca30dad519be285f0a1e839c23cc4e3a51d 25-Jan-2016 David Srbecky <dsrbecky@google.com> Revert "Revert "Add option to generate compressed backtrace info.""

This reverts commit 8546cc9aeb05e866e1fb6a9e4130d53ea330baa8.

Change-Id: I676fdf9af27fa3b16fa8921778ff8832ab8c437d
8546cc9aeb05e866e1fb6a9e4130d53ea330baa8 25-Jan-2016 David Srbecky <dsrbecky@google.com> Revert "Add option to generate compressed backtrace info."

This reverts commit 5fdcc3c931b70204fd8c491afa66f57f8428490f.

Change-Id: I9c1f5aad6933a46af6717e3a90a51f76111f9c8a
5fdcc3c931b70204fd8c491afa66f57f8428490f 19-Jan-2016 David Srbecky <dsrbecky@google.com> Add option to generate compressed backtrace info.

Add flag --generate-mini-debug-info which generates
LZMA compressed .symtab and .debug_frame, which are
sufficient to print java backtraces in libunwind.

If enabled, it increases the size of boot.oat by about 3.5%.

Change-Id: Ic3c2ef7704c05fa328720c6781ca2a9b8e3935a3
fffbee4d158259633ec7b7f712eaf75be86bd4e5 15-Jan-2016 Tamas Berghammer <tberghammer@google.com> Report types loaded during init to the native debugger

The runtime loads a lot of type before it creates the jit from the
boot image and from hard coded source code (e.g. primitive arrays).
This change emits type information for these types after the jit has
been created. At the same time we remove the type info generation
that happens during AOT compilation because that type information can
be modified by a class loader at runtime.

Change-Id: Ie5b3b3df9d01c7200a1f670a98d9cbee796234e9
86e4278d5edc3685465b8846dcb17efa83c86d75 05-Jan-2016 Tamas Berghammer <tberghammer@google.com> Add DWARF type information generation.

Emit native debugging information for types which are used during
compilation.

Change-Id: If28d19f60294494b7c6db8400d179494bebe9e61
e0febdfc2d9585d0d1b4a562b8e44d9058c71c37 17-Dec-2015 David Srbecky <dsrbecky@google.com> Move debug symbol writing code to elf_writer_debug.cc

I want to be able to use this code without needing to
reference elf_writer_quick.

Change-Id: I87ccedc540b8f04b53be0fc6344a5947308ffcb6
131980fc9aeb2b4d03480443e0fb494c76ce03a2 03-Dec-2015 Vladimir Marko <vmarko@google.com> Add ElfWriter::GetStream().

This will be used for writing the OatHeader which is
currently oddly written through the .text stream.

Also move the error delaying output stream out of the
ElfBuilder<> to its own file and move all output stream
files to compiler/linker/.

Change-Id: I00db4e33ed80ac4757ec459946c7b5ae014a3a2e
10c13565474de2786aad7c2e79757ea250747a15 25-Nov-2015 Vladimir Marko <vmarko@google.com> Refactor oat file writing to give Dex2Oat more control.

This is the first step towards writing dex files to oat file
and mapping them from there for the actual AOT compilation.

Change-Id: Icb0d27487eaf6ba3a66c157e695f9bdc5bb9cf9a
6d8c8f0344a706df651567387ede683ab3ec1b5f 26-Oct-2015 David Srbecky <dsrbecky@google.com> Rewrite ElfBuilder to make streaming directly to file easier.

The previous design required knowing all the sections and their
sizes before even the first byte of the file was written.

The new design allows sections to be written one by one without
any knowledge of later sections. Furthermore, as soon as
section is started, its virtual memory address is known,
which removes the need for the various patching passes.

The new ElfBuilder essentially tries to be a thin wrapper
around OutputStream which keeps track where the various
sections start/end and then writes their ELF headers.

Change-Id: I817e7f3b41882e4e4b9b442cfe56e4ef2e26babd
a26cb57f46fd3f27a930d9d688fe8670c1f24754 23-Apr-2015 David Srbecky <dsrbecky@google.com> ART stack unwinding fixes for libunwind/gdb/lldb.

dex2oat can already generate unwinding and symbol information which
allows tools to create backtrace of mixed native and Java code.

This is a cherry pick from aosp/master which fixes several issues.
Most notably:
* It enables generation of ELF-64 on 64-bit systems (in dex2oat, C
compilers already produce ELF-64). Libunwind requires ELF-64 on
64-bit systems for backtraces to work.
* It enables loading of ELF files with dlopen. This is required for
libunwind to be able to generate backtrace of current process (i.e.
the process requesting backtrace of itself).
* It adds unit test to test the above (32 vs 64 bit, in-proces vs
out-of-process, application code vs framework code).
* Some other fixes or clean-ups which should not be of much
significance but which are easier to include to make the
important CLs cherry-pick cleanly.

This is squash of the following commits from aosp/master:
7381010 ART: CFI Test
e1bbed2 ART: Blacklist CFI test for non-compiled run-tests
aab9f73 ART: Blacklist CFI test for JIT
4437219 ART: Blacklist CFI test for Heap Poisoning
a3a49fe Switch to using ELF-64 for 64-bit architectures.
297ed22 Write 64-bit address in DWARF if we are on 64-bit architecture.
24981a1 Set correct size of PT_PHDR ELF segment.
1a146bf Link .dynamic to .dynstr
67a0653 Make some parts of ELF more (pointer) aligned.
f50fa82 Enable 64-bit CFI tests.
49e1fab Use dlopen to load oat files.
5dedb80 Add more logging output for dlopen.
aa03870 Find the dlopened file using address rather than file path.
82e73dc Release dummy MemMaps corresponding to dlopen.
5c40961 Test that we can unwind framework code.
020c543 Add more log output to the CFI test.
88da3b0 ART: Fix CFI test wrt/ PIC
a70e5b9 CFI test: kill the other process in native code.
ad5fa8c Support generation of CFI in .debug_frame format.
90688ae Fix build - large frame size of ElfWriterQuick<ElfTypes>::Write.
97dabb7 Fix build breakage in dwarf_test.
388d286 Generate just single ARM mapping symbol.
f898087 Split .oat_patches to multiple sections.
491a7fe Fix build - large frame size of ElfWriterQuick<ElfTypes>::Write (again).
8363c77 Add --generate-debug-info flag and remove the other two flags.
461d72a Generate debug info for core.oat files.

Bug: 21924613
Change-Id: I3f944a08dd2ed1df4d8a807da4fee423fdd35eb7
8363c772581bf00ebcdc2e38391b4bfae51beb75 28-May-2015 David Srbecky <dsrbecky@google.com> Add --generate-debug-info flag and remove the other two flags.

Replace the flags --include-debug-symbols and --include-cfi
with single flag called --generate-debug-info (with alias -g).

The name "symbol" was not ideal, since depending on context it
may be interpreted as "ELF symbols", or "debugging information".

This CL also means that we have only the options to include
either all debugging information or none. This should be fine,
since we can use standard tools to strip anything we do not want.

Change-Id: I721fded56d755d7eed0ef36aa84e841a1f5747f8
491a7fed21eb153965cee73ac77268ec340aaca2 28-May-2015 David Srbecky <dsrbecky@google.com> Fix build - large frame size of ElfWriterQuick<ElfTypes>::Write (again).

Change-Id: I8a3277835f22a23c31063eda9b7f1fdc9423a5b0
f8980875ef8fb0ce86be4ed2c0af7070f5ae9cfd 22-May-2015 David Srbecky <dsrbecky@google.com> Split .oat_patches to multiple sections.

.oat_patches section currently contains encoded patch locations for
several other sections. Split it to several sections - one for each
of the destination sections. For example, .text.oat_patches section
contains patch locations for the .text section.

This ensures that if we strip some the sections using standard
tools, we strip the corresponding .oat_patches section as well.

It also makes the overall design simpler.
I should have done it this way in the first place.

Since ApplyOatPatches has been simplified and uses unaligned memory
access, this also fixes bug 21403573.

Bug:20556771
Bug:21403573
Change-Id: Iae7c423911507b524eec500e8d61744046fcd3ba
388d2861ce185fe9bbf1989f1467031467bd1de7 21-May-2015 David Srbecky <dsrbecky@google.com> Generate just single ARM mapping symbol.

It is unnecessary to keep repeating the $t symbol if there
are no $d symbols. The last $t should still be in effect.

This shrinks the .symtab section by half.

Change-Id: Ic57c8c2d412c10f0d040e966379ec524ece87d4a
aaf143d80bc6f226290eadb10361a752ed5d204e 21-May-2015 David Srbecky <dsrbecky@google.com> Switch to using .debug_frame for CFI.

This will make it easier to strip or compress CFI using standard tools.

It also saves some space since we do not need .eh_frame_hdr anymore.

Bug:20556771
Change-Id: I8656b1ff248e4b12cb94924800c3a91fac8bdda4
ad5fa8c5b26a325dc2a9521b87188755046c17f3 06-May-2015 David Srbecky <dsrbecky@google.com> Support generation of CFI in .debug_frame format.

.debug_frame section is almost identical to .eh_frame section.
There are only minor differences in the CIE and FDE headers.
The main difference is that .eh_frame is intended to be used
at runtime for exception handling and is therefore allocated
within the running program whereas .debug_frame is not.

This makes .debug_frame easier to remove using standard tools.
"objcopy --strip-debug" removes .debug_frame, but not .eh_frame.
(although objcopy can be still be forced to remove .eh_frame)

Similarly, we might want to separate the CFI to separate debug
file or include it as compressed .gnu_debugdata section.
It is more appropriate to use .debug_frame for this purpose.

Bug:20556771
Change-Id: I9d91a333b9fb37523fd6fafccfad89b21d2477af
033d745bb9412c9b546d29395cc9efbbb4fa306e 30-Apr-2015 David Srbecky <dsrbecky@google.com> Add binary search table to .eh_frame_hdr

The addresses in the search table must be relative to the start
of .eh_frame_hdr which results in yet another pointer type to patch.
I have moved the Patch method back to elf_writer_quick where
it can be specialized to one of the three pointer types.

The .eh_frame_hdr takes around 17% of .eh_frame now.

Change-Id: I4770d1355ded6cdff9489c33380f6b06c4e3f9fe
6d73c9d06bc0fc6b32825ca0a8224010933a026e 01-May-2015 David Srbecky <dsrbecky@google.com> Do not write CFI and symbols for deduplicate methods.

There is no need to have multiple symbols for a given address
since libunwind still has to pick only one to print.
Likewise, there is no need to duplicate the CFI.

There is fair number of duplicate methods in the boot image,
so this saves over 20% from those debug sections.

Change-Id: Ib4390150257d009a6303b084076750ce56afed60
b0a962c59699fb4d115fb159eeabbd2200c6f872 28-Apr-2015 David Srbecky <dsrbecky@google.com> Move .eh_frame to the end of ELF file.

Move .eh_frame to the end together with other debug sections.
This should make it easier to remove it using standard strip tools.

Bug:20556771
Change-Id: I8303ccb053aee50d53fb193819d345c91f1e5b75
bc90fd09e09a845ae6ea0d84ad67560575a94142 22-Apr-2015 David Srbecky <dsrbecky@google.com> Major refactoring of ElfBuilder.

Simplify ElfBuilder by removing duplicated or redundant code.
Many of the repeated code patterns were replaced by just
looping over the list of all sections.

Methods Init() and Write() have been merged into one.
The split between those was rather arbitrary, but it was there
for a reason. It allowed creation of raw sections between
the calls which may have depended on layout decisions done in
Init(), but not in Write() (e.g. knowing of offset of .text).

This has been replaced by more generic solution.
All sections are asked about their size first and complete
file layout is calculated. Then the sections are asked to
write their content (potentially using the layout information).

This should be pure refactoring CL - the compiler should
produce bit for bit identical output as before.

Change-Id: I281d13d469801bd8288b36b360d200d98a3e92d7
0c5bbc11a6af7b4f83b3929bc99de690635095c0 28-Apr-2015 David Srbecky <dsrbecky@google.com> Minor refactoring of ElfBuilder.

* Nest section builder classes within the main builder
class to reduce verbosity caused by templates.
* Move .eh_frame and .eh_frame_hdr section headers earlier
so that the section headers are sorted by file offset.
* Do not emit PT_NULL header if .eh_frame_hdr is missing.

None of these changes should have any material impact.
This CL just prepares ground for the following CL.

Change-Id: I56f9825892adb01d413a18ca10cb5c805cb8cd78
2cebb24bfc3247d3e9be138a3350106737455918 22-Apr-2015 Mathieu Chartier <mathieuc@google.com> Replace NULL with nullptr

Also fixed some lines that were too long, and a few other minor
details.

Change-Id: I6efba5fb6e03eb5d0a300fddb2a75bf8e2f175cb
533c207f9d2da6d913c4b10f6f757fe9d6367b10 22-Apr-2015 David Srbecky <dsrbecky@google.com> Simplify template parameters of Elf classes.

The ELF specification defines several types which differ between
32-bit ELF and 64-bit ELF. We used to template all ELF-related
methods on all of those types which was very verbose.

This CL wraps all the types as typedefs in ElfTypes32 and ElfTypes64.
One of those wrappers is then used as the template parameter.

Change-Id: I65247c2c79d92a7c4799e988cf3e4a1b10eb4788
527c9c71f0c6e2f9943ac028e7c050500699a44b 17-Apr-2015 David Srbecky <dsrbecky@google.com> Generate .eh_frame_hdr section and PT_GNU_EH_FRAME segment.

Fixes issue 20125400 - ART: Need .eh_frame_hdr and PT_GNU_EH_FRAME
for libunwind.

.eh_frame_hdr serves two purposes. Firstly, it can optionally contain
binary search table for fast eh_frame lookup. This is important for
C++ exception handling, but we do not need it so we omit it.
Secondly, it contains a relative .eh_frame pointer which makes it
easier for run-time code to locate the .eh_frame section.
libunwind seems to rely on this relative pointer.

Bug: 20125400
Change-Id: I7c1e3f68d914f70781404c508395831a3296a7da
626a1666015b0fa201e979870baf06afa93b65e7 12-Apr-2015 David Srbecky <dsrbecky@google.com> Append [DEDUPED] suffix to all deduped methods in the symbol table.

This resolves old TODO in the code. The first method was never
marked as deduped and only the subsequent copies were recognised.
Therefore the suffix might have been missing in backtraces.

Change-Id: I4882d90f3049f7e196cd38c8987ba02960dab338
8dc7324da5bd0f2afd2ab558ab04882329a61fe8 12-Apr-2015 David Srbecky <dsrbecky@google.com> Add --include-cfi compiler option.

Decouple generation of CFI from the rest of debug symbols.
This makes it possible to generate oat with CFI but without
the rest of debug symbols.

This is in line with intention of the .eh_frame section.
The section does not have the .debug_ prefix because it
is considered somewhat different to the rest of debug symbols.

Change-Id: I32816ecd4f30ac4e0dc69d69a4993e349c737f96
2f6cdb01f74772c1c521a125776ef57ea3c73d43 11-Apr-2015 David Srbecky <dsrbecky@google.com> Relocate DWARF using .oat_patches.

The current solution is to hard-code knowledge of DWARF in the linker.
This works for simple use of DWARF, but breaks as soon as I try to do
anything more complex. Making the linker fully support DWARF would be
non-trivial task and would be essentially rewrite. Using .oat_patches
is much easier solution.

Relocating .debug_* sections required extending .oat_patches to support
more sections than just .text. I have encoded each section as
null-terminated section name followed by ULEB128 deltas.

The ULEB128 encoding shrinks .oat_patches for .text by factor of
about 6 with 64-bit compiler, and factor of 3 with 32-bit compiler.

On the other hand, it grows by the extra .oat_patches for DWARF which
were not present before (if debug symbols are included).

Overall, it is still a clear improvement even with the DWARF patches.

Change-Id: I78ffeda0f8a3da03341995a3b5ef15c954e16e9f
3b9d57ab580a0593635a7dbe3dd2e2c76274f9fa 10-Apr-2015 David Srbecky <dsrbecky@google.com> Move DWARF related code in ElfWriter to its own file.

This is purely for organisation. The DWARF related code
is becoming more complex and I do not want to keep mixing
it with the ElfWriter. The ElfWriter probably should not
be dealing with the fine details of DWARF generation.

I intend to do much more work on DWARF in the future so
this situatuion would only get worse as the code grows.

The code could also use some refactoring and splitting.
However, I have mostly just moved it in this CL.

Change-Id: I6e3401a2b745ddf991b440ad7899ad7d4b921be6
b536247b1ce5de640eec81dddac47802cd074363 08-Apr-2015 David Srbecky <dsrbecky@google.com> Extend the DWARF library to support .debug_info section.

Change-Id: I9916abd8db227e7a73a3311294e675be5222a709
0df9e1faed9b095b084c4eca6ee59d24fba21c9f 07-Apr-2015 David Srbecky <dsrbecky@google.com> Remove duplicate of DexFile::DecodeDebugInfo.

Call DexFile::DecodeDebugInfo instead of having a local copy.

Change-Id: I4f94fd56a81fea1a2d10d5a26b9650d6d7ff9448
c6b4dd8980350aaf250f0185f73e9c42ec17cd57 07-Apr-2015 David Srbecky <dsrbecky@google.com> Implement CFI for Optimizing.

CFI is necessary for stack unwinding in gdb, lldb, and libunwind.

Change-Id: I1a3480e3a4a99f48bf7e6e63c4e83a80cfee40a2
1109fb3cacc8bb667979780c2b4b12ce5bb64549 07-Apr-2015 David Srbecky <dsrbecky@google.com> Implement CFI for Quick.

CFI is necessary for stack unwinding in gdb, lldb, and libunwind.

Change-Id: Ic3b84c9dc91c4bae80e27cda02190f3274e95ae8
8c57831b2b07185ee1986b9af68a351e1ca584c3 07-Apr-2015 David Srbecky <dsrbecky@google.com> Remove the old CFI infrastructure.

Change-Id: I12a17a8a1c39ffccaa499c328ebac36e4d74dc4e
189ae8251dfb0cace95a6c21d7f8132ecb486778 04-Apr-2015 David Srbecky <dsrbecky@google.com> Proper fix for issue 20051601 - arm actually means thumb2.

Change-Id: I38e81868cbebdccec6ecbba40494612f7c1d8092
934d754a53acff144273bd7fc42f4272628bb944 02-Apr-2015 David Srbecky <dsrbecky@google.com> Fix for issue 20051601 - ARM instruction alignment.

The instructions do not have to be 4 byte aligned.

Change-Id: I58078a15190b835601094611ed01a599e2d99563
6f7158927fee233255f8e96719c374694b10cad3 30-Mar-2015 David Srbecky <dsrbecky@google.com> Write .debug_line section using the new DWARF library.

Also simplify dex to java mapping and handle mapping
in prologues and epilogues.

Change-Id: I410f06024580f2a8788f2c93fe9bca132805029a
20f85597828194c12be10d3a927999def066555e 19-Mar-2015 Vladimir Marko <vmarko@google.com> Fixed layout for dex caches in boot image.

Define a fixed layout for dex cache arrays (type, method,
string and field arrays) for dex caches in the boot image.
This gives those arrays fixed offsets from the boot image
code and allows PC-relative addressing of their elements.

Use the PC-relative load on arm64 for relevant instructions,
i.e. invoke-static, invoke-direct, const-string,
const-class, check-cast and instance-of. This reduces the
arm64 boot.oat on Nexus 9 by 1.1MiB.

This CL provides the infrastructure and shows on the arm64
the gains that we can achieve by having fixed dex cache
arrays' layout. To fully use this for the boot images, we
need to implement the PC-relative addressing for other
architectures. To achieve similar gains for apps, we need
to move the dex cache arrays to a .bss section of the oat
file. These changes will be implemented in subsequent CLs.

(Also remove some compiler_driver.h dependencies to reduce
incremental build times.)

Change-Id: Ib1859fa4452d01d983fd92ae22b611f45a85d69b
5c42c29b89286e5efa4a4613132b09051ce5945b 25-Feb-2015 Vladimir Marko <vmarko@google.com> Add support for .bss section in oat files.

Change-Id: I779b80b8139d9afdc28373f8c68edff5df7726ce
80b96d1a76790527f72a660ac03d9c215eed17ce 19-Feb-2015 Vladimir Marko <vmarko@google.com> Replace a few std::vector with ArenaVector in Mir2Lir.

Change-Id: I7867d60afc60f57cdbbfd312f02883854d65c805
e21dc3db191df04c100620965bee4617b3b24397 09-Dec-2014 Andreas Gampe <agampe@google.com> ART: Swap-space in the compiler

Introduce a swap-space and corresponding allocator to transparently
switch native allocations to memory backed by a file.

Bug: 18596910

(cherry picked from commit 62746d8d9c4400e4764f162b22bfb1a32be287a9)

Change-Id: I131448f3907115054a592af73db86d2b9257ea33
8683038c1f59bea790d8c7691e40eed7f6250e4a 13-Dec-2014 Andreas Gampe <agampe@google.com> ART: Do not inline elf writer debug symbols

Using Clang, this pushes the frame size of the caller across our
limit. Thus forbid inlining. The function is only called once per
compile, impact is insignificant.

Bug: 18738594
Change-Id: I19c3f1168a5104ab508a8dbf9f2a8c035cb97e3c
807140048f82a2b87ee5bcf337f23b6a3d1d5269 21-Nov-2014 Mathieu Chartier <mathieuc@google.com> Add fast string sharpening

String sharpening changes const strings to PC relative loads instead
of always going through the dex cache. This saves code size and
probably improves performance slightly.

Before: 49602992 system@framework@boot.oat
After: 49385904 system@framework@boot.oat

Pre-cursor to removing dex_cache_strings_ field from ArtMethod.

Bug: 17643507

Change-Id: I1787f48774631eee0accafeea257aa8d0e91e8d6
6a3c1fcb4ba42ad4d5d142c17a3712a6ddd3866f 31-Oct-2014 Ian Rogers <irogers@google.com> Remove -Wno-unused-parameter and -Wno-sign-promo from base cflags.

Fix associated errors about unused paramenters and implict sign conversions.
For sign conversion this was largely in the area of enums, so add ostream
operators for the effected enums and fix tools/generate-operator-out.py.
Tidy arena allocation code and arena allocated data types, rather than fixing
new and delete operators.
Remove dead code.

Change-Id: I5b433e722d2f75baacfacae4d32aef4a828bfe1b
f9734550c1453f173150b12efc72b10ebf67878d 27-Oct-2014 Ningsheng Jian <ningsheng.jian@arm.com> ARM: Generate $t mapping symbol to indicate thumb2 code

According to ARM ELF specification, add $t mapping symbol to oat file
to indicate that the compiled method is thumb2 code.

Change-Id: I31e4eeab0b2be7754127cc90ac40b00216b48009
0279ebb3efd653e6bb255470c99d26949c7bcd95 09-Oct-2014 Ian Rogers <irogers@google.com> Tidy ELF builder.

Don't do "if (ptr)". Use const. Use DISALLOW_COPY_AND_ASSIGN. Avoid public
member variables.
Move ValueObject to base and use in ELF builder.
Tidy VectorOutputStream to not use non-const reference arguments.

Change-Id: I2c727c3fc61769c3726de7cfb68b2d6eb4477e53
f4da675bbc4615c5f854c81964cac9dd1153baea 01-Aug-2014 Vladimir Marko <vmarko@google.com> Implement method calls using relative BL on ARM.

Store the linker patches with each CompiledMethod instead of
keeping them in CompilerDriver. Reorganize oat file creation
to apply the patches as we're writing the method code. Add
framework for platform-specific relative call patches in the
OatWriter. Implement relative call patches for ARM.

Change-Id: Ie2effb3d92b61ac8f356140eba09dc37d62290f8
3c5ec99e156632a734c2359642ae928102850597 24-Sep-2014 Andreas Gampe <agampe@google.com> ART: Refactor elf_writer_quick for elf section order

This writes ELF sections in approximate order (debug sections are
currently out-of-order) to avoid incompletely written files
appearing OK to ART loading code.

Bug: 17622827
Change-Id: I812fd42fcf2823dbfaf5891bf101d3b59406f263
54fc26c7350beb782d042ba61cb06284b3a367e4 05-Sep-2014 Andreas Gampe <agampe@google.com> ART: Refactor elf_writer_quick, add symbolizer

Refactors some classes in elf_writer_quick.h to elf_builder.h to
be more friendly for re-use. Use this in oatdump to add a symtab
to an oat file.

Bug: 17187621, 17322125
Change-Id: I2333291334fd98bd09cc5717fb83cb18efe3a029
f9b87b1eece0e03578c4d1b627f1d5e8691a539a 02-Sep-2014 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "ART: Prepare for ELF64.""

Fix was commited in "Fix frame size issue with 64-bit"

This reverts commit 7eebd95bddc7c6866ba29010d28b4f8251b43242.

Change-Id: I799b7fcab14ae24471d2f9d6d3a5e5cedd4aa7b8
7eebd95bddc7c6866ba29010d28b4f8251b43242 01-Sep-2014 Nicolas Geoffray <ngeoffray@google.com> Revert "ART: Prepare for ELF64."

Build fails on arm64 with error message:
art/compiler/elf_writer_quick.cc:1083:1: error: the frame size of 2016 bytes is larger than 1728 bytes [-Werror=frame-larger-than=]

This reverts commit 45b8f1ab2782d02830c77751f883456de799dfb6.

Change-Id: I61b2e5f27ba4b2b32eacaec51fb5e5ed12fd8066
18a49cc2f956dec648e0a13186d42374023d47a7 30-Aug-2014 Brian Carlstrom <bdc@google.com> Fix frame size issue with 64-bit

Change-Id: Ib2f33dfb79952ba39f2d7e5303a2a2e6c4b0a0f6
45b8f1ab2782d02830c77751f883456de799dfb6 27-Aug-2014 Tong Shen <endlessroad@google.com> ART: Prepare for ELF64.

Make ElfWriterQuick a template class. No functionality change.

Change-Id: I62b60dc9795c4795027e80f0bee6b54622ea49e9
33ac819bd13c6e9d42b36ae8393c37cfb1bb4cde 19-Aug-2014 Yevgeny Rouban <yevgeny.y.rouban@intel.com> ART fix oat debug source map operations

Several places need to be fixed in OAT debug source map generation
(see comments in https://android-review.googlesource.com/#/c/102610/19/compiler/compiled_method.h):
1. Source Maps are deduplicated in Compiler Driver by implicit conversion
SrcMapElems to bytes. This implies incorrect operator==.
2. SrcMapElem operator < is peculiar, and cannot be applied to
SrcMapElems with negative to_ fields
3. SrcMap.Arrange method is not elegant

The fix is to introduce explicit conversion from SrcMapElem to one
signed 64-bit value, which is used as a base of two new operators < and ==.
They are correct and intuitive. DedupeHashFunc is changed to
explicitly convert array elements to byte, so the explicit type conversion
from SrcMapElem to byte is used.

Minor fix: In Line Table Programs the file index set command is generated
only if the index gets new value.

Change-Id: I5e2c03404a437254fc2db3485b22bfc1799b39b7
Signed-off-by: Yevgeny Rouban <yevgeny.y.rouban@intel.com>
e3ea83811d47152c00abea24a9b420651a33b496 08-Aug-2014 Yevgeny Rouban <yevgeny.y.rouban@intel.com> ART source line debug info in OAT files

OAT files have source line information enough for ART runtime needs like
jump to/from interpreter and thread suspension. But this information
is not enough for finer grained source level debugging and low-level
profiling (VTune or perf).

This patch adds to OAT files two additional sections:
.debug_line - DWARF formatted Elf32 section with detailed source line
information (mapping from native PC to Java source lines).

In addition to the debugging symbols added using the dex2oat option
--include-debug-symbols, the source line information is added to
the section .debug_line.

The source line info can be read by many Elf reading tools like objdump,
readelf, dwarfdump, gdb, perf, VTune, ...

gdb can use this debug line information in x86. In 64-bit mode
the information can be used if the oat file is mapped in the lower
address space (address has higher 32 bits zeroed). Relocation works.

Testing:
1. art/test/run-test --host --gdb [--64] 001-HelloWorld
2. in gdb: break Main.java:19
3. in gdb: break Runtime.java:111
4. in gdb: run - stops at void java.lang.Runtime.<init>()
5. in gdb: backtrace - shows call stack down to main()
6. in gdb: continue - stops at void Main.main() (only in 32-bit mode)
7. in gdb: backtrace - shows call stack down to main()
8. objdump -W <oat-file> - addresses are from VMA range of .text
section reported by objdump -h <file>
9. dwarfdump -ka <oat-file> - no errors expected

Size of aosp-x86-eng boot.oat increased by 11% from 80.5Mb to 89.2Mb
with two sections added .debug_line (7.2Mb) and .rel.debug (1.5Mb).

Change-Id: Ib8828832686e49782a63d5529008ff4814ed9cda
Signed-off-by: Yevgeny Rouban <yevgeny.y.rouban@intel.com>
4b0d2d99b596eebd6da45679896d3af54bc5a935 06-Aug-2014 Alex Light <allight@google.com> Make patchoat use the sht_entsize when patching.

This fixes an occasional problem with multiarch use of patchoat.

Change-Id: I80799de36774720bd985704f9b709a8378bb5af5
79273802f2b788bcd3eb76edf4df1bcaa57f886f 06-Aug-2014 Andreas Gampe <agampe@google.com> ART: Rework CFA frame initialization and writing code

Move eh_frame initialization code and CFI writing code to
elf_writer_quick to remove hard-wired dependencies on specific
Quick-compiler backends.

Change-Id: I27ee8ce7245da33a20c90e0086b8d4fd0a2baf4d
547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52 05-Aug-2014 Tong Shen <endlessroad@google.com> Emit CFI for x86 & x86_64 JNI compiler.

Now for host-side x86 & x86_64 ART, we are able to get complete stacktrace with even mixed C/C++ & Java stack frames.

Testing:
1. art/test/run-test --host --gdb [--64] --no-relocate 005
2. In gdb, run 'b art::Class_classForName' which is implementation of a Java native method, then 'r'
3. In gdb, run 'bt'. You should see stack frames down to main()

Change-Id: I2d17e9aa0f6d42d374b5362a15ea35a2fce96302
35e1e6ad4b50f1adbe9f93fe467766f042491896 30-Jul-2014 Tong Shen <endlessroad@google.com> 1. Fix CFI for quick compiled code in x86 & x86_64;
2. Emit CFI in .eh_frame instead of .debug_frame.

With CFI, we can correctly unwind past quick generated code.
Now gdb should unwind to main() for both x86 & x86_64 host-side ART.

Note that it does not work with relocation yet.

Testing:
1. art/test/run-test --host --gdb [--64] --no-relocate 005
2. In gdb, run 'b art_quick_invoke_stub', then 'r', then 'c' a few times
3. In gdb, run 'bt'. You should see stack frames down to main()

Change-Id: I5350d4097dc3d360a60cb17c94f1d02b99bc58bb
53cb16b98acf3cf6f3a1e2204ad4958ecf1b5a3c 12-Jun-2014 Alex Light <allight@google.com> Add patchoat tool to Art.

Add a new executable called patchoat to art. This tool takes already
compiled images and oat files and changes their base address, acting as
a cheap form of relocation.

Add a --include-patch-information flag to dex2oat and code to add
required patch information to oat files created with the quick compiler.

Bug: 15358152

Change-Id: Ie0c580db45bb14ec180deb84930def6c3628d97d
eefbe39799126afdf7d315a79359b9da23d1cef5 08-Jul-2014 Alex Light <allight@google.com> Fix some style nitpicks

Change-Id: Icfdd327f4ddf129f0a8607162c09ba271c1d49d9
3470ab4011b5e18d590d5375e2f13a1e3bd69222 18-Jun-2014 Alex Light <allight@google.com> Fixed gdb support and added some ElfFile functions

Fixed gdb support so that it would continue working even when debug
symbols or other sections are included in the elf file. Also made it
actually read parts of the DWARF information so it should work even if
there are minor changes to how and where DWARF information is written
out.

Added a dwarf.h file with the dwarf constants.

Added a FindSectionByName function, a FindDynamicSymbol function, and
the ability to specify the mmap protection and flags directly if we are
mapping in the whole file.

Modified elf_writer_quick.cc to use the dwarf constants from dwarf.h.

Change-Id: I09e15c425fab252b331a2e4719863552e8b6b137
78382fa44ee505cf16835e4d22515e7252a90864 07-Jun-2014 Alex Light <allight@google.com> Optionally add debug symbols to ELF files made by quick compiler.

Added debug symbols to ELF files created by dex2oat using
the quick compiler. Adds two flags --include-debug-symbols and
--no-include-debug-symbols for dex2oat that control the inclusion of these
debug symbols. Debug info is added by default if kIsDebugBuild is true.

Fixed bug where Intel DWARF information would not correctly deal with
deduplicated code the binary.

Changed the portable compiler code path in dex2oat.cc so that symbols
will not be stripped when run with --include-debug-symbols.

Change-Id: Ia2eb2f654dedf0e5e8606f7744e05b8d14155fb1
8758c64a40e74ebb492a348556ec7b25a89c1491 11-Jun-2014 Brian Carlstrom <bdc@google.com> Fix build by converting from bionic to elfutils version of elf.h

Change-Id: I70a3b6fedae6d290a4f01d4ae8fdd726b8aaa90f
b12f34742be4adaa804cc0d388ba51603bb95955 11-Jun-2014 Brian Carlstrom <bdc@google.com> Revert "Revert "Rewrite ElfWriterQuick to make it more modular.""

This reverts commit 35f72251e722cad03a08e8ceacbd5c244eab5c29.
35f72251e722cad03a08e8ceacbd5c244eab5c29 11-Jun-2014 Brian Carlstrom <bdc@google.com> Revert "Rewrite ElfWriterQuick to make it more modular."

This reverts commit ad13cb2db8c4a64298ed85c82ae7366ee73f7640.

Change-Id: Iee1d1fd08a008d7d382c181cb352ef46a6eaf5d3
ad13cb2db8c4a64298ed85c82ae7366ee73f7640 05-Jun-2014 Alex Light <allight@google.com> Rewrite ElfWriterQuick to make it more modular.

Remade ElfWriterQuick so that it would use a more modular design and allow
the addition of additional features onto it in a more straightforward way.

Change-Id: I07971eb2080890645fab1b02c7305697e85d3a64
ffddfdf6fec0b9d98a692e27242eecb15af5ead2 03-Jun-2014 Tim Murray <timmurray@google.com> DO NOT MERGE

Merge ART from AOSP to lmp-preview-dev.

Change-Id: I0f578733a4b8756fd780d4a052ad69b746f687a9
57ef2d33b369ced7eaf95b996bba473702f636cf 30-May-2014 Alex Light <allight@google.com> Moved a BufferedOutputStream onto the heap to reduce stack usage.

Bug: 15278350
Change-Id: I6aa7cf3979453e555686610e90520b762b812f8c
53bee42d0f8b454ff4fe5b7e42bdb070c786e3eb 05-Apr-2014 Mathieu Chartier <mathieuc@google.com> Fix using kArm instead of kThumb2.

Change-Id: I0f3bf93b38d910bc57d017693675829b6a39bc18
b95a5345ae4217b70ca36f0cced92f68dda7caf5 12-Mar-2014 Stuart Monteith <stuart.monteith@arm.com> AArch64: Add arm64 runtime support.

Adds support for arm64 to ART. Assembler stubs are sufficient for
down calls into interpreter. JNI compiler and generics are not finished.

Basic Generic JNI functionality.

Change-Id: I4a07c79d1e037b9f5746673480e32cf456867b82
befbd5731ecca08f08780ee28a913d08ffb14656 06-Mar-2014 Ian Rogers <irogers@google.com> Fix host architecture for 64bit.

Also, hack x86 assembler for use as a x86-64 trampoline compiler's assembler.
Implement missing x86-64 quick resolution trampoline.
Add x86-64 to the quick elf writer.

Change-Id: I08216c67014a83492ada12898ab8000218ba7bb4
ae9fd93c39a341e2dffe15c61cc7d9e841fa92c4 11-Feb-2014 Mark Mendell <mark.p.mendell@intel.com> Tell GDB about Quick ART generated code

This is actually a lot of work. To do this, we need:
.debug_info
.debug_abbrev
.debug_frame
.debug_str

These are generated into the OAT file by OatWriter and ElfWriterQuick.

Since the Quick ART runtime doesn't use dlopen to load the OAT files,
GDB can't find this information. Use the alternate GDB JIT interface,
which can be invoked at runtime. To use this interface, an ELF image
needs to be built in memory. Read the information from the OAT file,
fixup the addresses to point to the real locations, add a symbol table
to hold the .text symbol, and then let GDB know about the information,
which will be read from the runtime address space.

This is quite primitive now, and could be cleaned up considerably. It
probably needs symbol table entries for the methods, and descriptions of
parameters and return types.

Currently only supported for X86.

This defaults to enabled for debug builds. Added dexoat --gen-gdb-info
and --no-gen-gdb-info flags to override.

Change-Id: I4d18b2370f6dfaa00c8cc1925f10717be3bd1a62
Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
3d504075f7c1204d581923460754bf6d3714b13f 01-Mar-2014 Ian Rogers <irogers@google.com> Make out arguments non-reference types.

Also, tidy some portable related code.

Change-Id: I67c8aa52eef8b556ca117ecda1b1e75465ba06a5
50cfe74daaece80853cb3b45d4338329b7d0345b 19-Feb-2014 Nicolas Geoffray <ngeoffray@google.com> Remove dependency on llvm/Support/ELF.h by using linux's elf.h.

Change-Id: Iefe66af9958641ac7f08fdc22f438d976e5b4d54
c6dfdacea2fd9e268f70328805b0366cdd6b7b9e 27-Aug-2013 Brian Carlstrom <bdc@google.com> Add buffering to ELF file generation

Bug: 10496017
Change-Id: I3cbad249e0fb33f726bd0a504b3b6bd9b4f759c8
e2be9da597c69b92ffb707f2101b96076578b5e6 26-Aug-2013 Mathieu Chartier <mathieuc@google.com> Fix typo in elf writer.

We were writing the wrong number of characters to the elf file.
Caught by valgrind.

Change-Id: Iaf5a51bc7f6dd23cc5e68992dc033610fd0c5c79
8718359763aa3dcd0033a2d2e67e0cb145fb9c53 14-Aug-2013 Anwar Ghuloum <anwarg@google.com> Add -XX:+DisableExplicitGC option for Art

Phone boots. Also removed elfwriter spam from logcat.

Change-Id: I09b9d2fc40ebfeb6f1c2f12153b0ad4134bb5159
7934ac288acfb2552bb0b06ec1f61e5820d924a4 26-Jul-2013 Brian Carlstrom <bdc@google.com> Fix cpplint whitespace/comments issues

Change-Id: Iae286862c85fb8fd8901eae1204cd6d271d69496
c50d8e11a098cc5c6239aa86b47d4fcf8cbb4899 24-Jul-2013 Brian Carlstrom <bdc@google.com> Remove OatWriter buffering to memory for ElfWriterQuick

This allows the oat contents to be directly written to the file.

Change-Id: Ibc7ddf57477b152f07784b52f7334be73fd22833
7940e44f4517de5e2634a7e07d58d0fb26160513 12-Jul-2013 Brian Carlstrom <bdc@google.com> Create separate Android.mk for main build targets

The runtime, compiler, dex2oat, and oatdump now are in seperate trees
to prevent dependency creep. They can now be individually built
without rebuilding the rest of the art projects. dalvikvm and jdwpspy
were already this way. Builds in the art directory should behave as
before, building everything including tests.

Change-Id: Ic6b1151e5ed0f823c3dd301afd2b13eb2d8feb81