summaryrefslogtreecommitdiffstats
path: root/runtime/mem_map.cc
Commit message (Collapse)AuthorAgeFilesLines
* ART stack unwinding fixes for libunwind/gdb/lldb.David Srbecky2015-06-191-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* More LOW_4G optimizationsMathieu Chartier2015-06-051-9/+26
| | | | | | | | | | Eagerly try to map at an address when it doesn't overlap with the ART known maps. Reduces time spent creating the heap on N9 from ~100ms to ~10ms. Bug: 20727525 Change-Id: Ie8982ca9d1f3158104b2b53b992c3a28841fc443
* Add optimization for LOW_4G allocatorMathieu Chartier2015-06-041-0/+24
| | | | | | | | | | | The optimization uses the maps_ field to skip over regions which we know wont be large enough for the request. Reduces time to create heap from 500-700ms to 100ms on N9. Bug: 20727525 Change-Id: I4fa92d58c2e135ba31a03ababff46669089bb542
* ART: Merge entries with same name and protect in MemMap dump.Vladimir Marko2015-05-081-4/+59
| | | | | | | | | | | This should make the MemMap dump less chatty and allow the logger to keep more relevant output. Bug: 20873174 (cherry picked from commit 17a924abde2b0f1f37f6008b451a0a75190c71ff) Change-Id: I1748f57a1f149a5498b42ee246f13d2bf1e8c2f7
* ART: Fix debug output for bad reused MemMap.Vladimir Marko2015-05-081-3/+3
| | | | | | | | | Log the error_msg instead of a pointer to it. Raise the log level to ERROR for the process maps. (cherry picked from commit b5505823ad3d0bab8fc9c15c266a3d8cd96ee59e) Change-Id: Ib0c258961e2384125907aca4bae2108f36067d5f
* Replace NULL with nullptrMathieu Chartier2015-04-221-4/+5
| | | | | | | Also fixed some lines that were too long, and a few other minor details. Change-Id: I6efba5fb6e03eb5d0a300fddb2a75bf8e2f175cb
* Move ArtField to nativeMathieu Chartier2015-04-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add linear alloc. Moved ArtField to be native object. Changed image writer to put ArtFields after the mirror section. Savings: 2MB on low ram devices 4MB on normal devices Total PSS measurements before (normal N5, 95s after shell start): Image size: 7729152 bytes 23112 kB: .NonMoving 23212 kB: .NonMoving 22868 kB: .NonMoving 23072 kB: .NonMoving 22836 kB: .NonMoving 19618 kB: .Zygote 19850 kB: .Zygote 19623 kB: .Zygote 19924 kB: .Zygote 19612 kB: .Zygote Avg: 42745.4 kB After: Image size: 7462912 bytes 17440 kB: .NonMoving 16776 kB: .NonMoving 16804 kB: .NonMoving 17812 kB: .NonMoving 16820 kB: .NonMoving 18788 kB: .Zygote 18856 kB: .Zygote 19064 kB: .Zygote 18841 kB: .Zygote 18629 kB: .Zygote 3499 kB: .LinearAlloc 3408 kB: .LinearAlloc 3424 kB: .LinearAlloc 3600 kB: .LinearAlloc 3436 kB: .LinearAlloc Avg: 39439.4 kB No reflection performance changes. Bug: 19264997 Bug: 17643507 Change-Id: I10c73a37913332080aeb978c7c94713bdfe4fe1c
* Add support for .bss section in oat files.Vladimir Marko2015-03-021-7/+15
| | | | Change-Id: I779b80b8139d9afdc28373f8c68edff5df7726ce
* ART: Print maps directly to logAndreas Gampe2015-02-241-23/+16
| | | | | | | | | | Do not read proc maps into a string before printing them later back to the log. In low-memory situations this can cause a bad_alloc. External bug: http://b.android.com/153990 Bug: 19494774 Change-Id: Ie63d8788afe8c9da65b30b2f89c50d3dbb820755
* Add clamp growth limitMathieu Chartier2015-01-081-0/+13
| | | | | | | | | | Clamp growth limit shrinks the space memmaps to the current growth limit. This reduces virtual memory usage for apps with small heaps. Bug: 18387825 Bug: 17131630 Change-Id: I4a8fdc335d2c40492e991708adabcc46299efb7d
* ART: More warningsAndreas Gampe2014-11-041-0/+5
| | | | | | | Enable -Wno-conversion-null, -Wredundant-decls and -Wshadow in general, and -Wunused-but-set-parameter for GCC builds. Change-Id: I81bbdd762213444673c65d85edae594a523836e5
* Remove -Wno-unused-parameter and -Wno-sign-promo from base cflags.Ian Rogers2014-11-031-0/+3
| | | | | | | | | | | 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
* Tidy up logging.Ian Rogers2014-10-221-2/+4
| | | | | | | | | | | | | | | | | Move gVerboseMethods to CompilerOptions. Now "--verbose-methods=" option to dex2oat rather than runtime argument "-verbose-methods:". Move ToStr and Dumpable out of logging.h, move LogMessageData into logging.cc except for a forward declaration. Remove ConstDumpable as Dump methods are all const (and make this so if not currently true). Make LogSeverity an enum and improve compile time assertions and type checking. Remove log_severity.h that's only used in logging.h. With system headers gone from logging.h, go add to .cc files missing system header includes. Also, make operator new in ValueObject private for compile time instantiation checking. Change-Id: I3228f614500ccc9b14b49c72b9821c8b0db3d641
* Change MemMap::maps_ to not be global variableMathieu Chartier2014-10-141-6/+23
| | | | | | | | Runtime.exit() was causing globals to get destructed at the same time that another thread was using it for allocating a new mem map. Bug: 17962201 Change-Id: I400cb7b8141d858f3c08a6fe59a02838c04c6962
* stdint types all the way!Ian Rogers2014-10-091-18/+18
| | | | Change-Id: I4e4ef3a2002fc59ebd9097087f150eaf3f2a7e08
* ART: Fix some -Wpedantic errorsAndreas Gampe2014-09-291-1/+1
| | | | | | | | | | | | | | | | Remove extra semicolons. Dollar signs in C++ identifiers are an extension. Named variadic macros are an extension. Binary literals are a C++14 feature. Enum re-declarations are not allowed. Overflow. Change-Id: I7d16b2217b2ef2959ca69de84eaecc754517714a
* Add native memory accounting through custom allocator.Mathieu Chartier2014-08-291-9/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added a custom allocator that lets you pass in a special tag which specifices where the allocation came from. This is used when dumping. The performance overhead is low since each allocation only does a atomic add/sub for each allocation/free. The measurements are dumped to traces.txt during SIGQUIT. Example output: I/art (27274): AllocatorTagHeap active=120 max=120 total=168 I/art (27274): AllocatorTagMonitorList active=1572 max=6240 total=11724 I/art (27274): AllocatorTagClassTable active=185208 max=185208 total=268608 I/art (27274): AllocatorTagInternTable active=430368 max=430368 total=436080 I/art (27274): AllocatorTagMaps active=5616 max=6168 total=34392 I/art (27274): AllocatorTagLOS active=1024 max=1536 total=2044 I/art (27274): AllocatorTagSafeMap active=0 max=51936 total=533688 I/art (27274): AllocatorTagLOSMaps active=144 max=1248 total=5760 I/art (27274): AllocatorTagReferenceTable active=10944 max=11840 total=19136 I/art (27274): AllocatorTagHeapBitmap active=32 max=40 total=56 I/art (27274): AllocatorTagHeapBitmapLOS active=8 max=8 total=8 I/art (27274): AllocatorTagVerifier active=0 max=18844 total=1073156 I/art (27274): AllocatorTagModUnionCardSet active=5300 max=5920 total=56020 I/art (27274): AllocatorTagModUnionReferenceArray active=24864 max=24864 total=24864 I/art (27274): AllocatorTagJNILibrarires active=320 max=320 total=320 I/art (27274): AllocatorTagOatFile active=1400 max=1400 total=5852 Change-Id: Ibb470ef2e9c9a24563bb46422d46a55799704d82 (cherry picked from commit 5369c40f75fdcb1be7a7c06db212ce965c83a164)
* Make a couple of map checks debug only.Narayan Kamath2014-08-211-13/+27
| | | | | | | | | | | | | | | | | This cost us close to 80ms in app startup times. The checks that a reused region was within an already existent map has been demoted to a debug check. A couple of other negative checks have been removed outright because one of them was superflous and the other wasn't guaranteed to be correct. bug: 16828525 (cherry picked from commit bddaea2b88b0a19d9cc7a4dea772af8e829323b3) Change-Id: Ia6f3e69692bb9cb5b4ff6f47946ea38a56d4cdb6
* Check for a NULL pointer, do not call Build.Christopher Ferris2014-08-061-2/+2
| | | | | | | When calling BacktraceMap::Create(), a NULL pointer is returned if Build fails. Building twice can cause problems and might leak memory. Change-Id: I38a4100e534ef15a19883703aa504e795a14b6de
* ART: Fix memory unmapped twice issue in ElfFile::Load(bool)Jim_Guo2014-08-041-55/+105
| | | | | | | | | | | | | | | | | Root Cause: The overlapped memory region will be unmapped by (1) ~MemMap() of reservation MemMap (reserve) and (2) ~MemMap() of "reuse" MemMap (segment). Someone takes the memory region after (1) and it will be unmapped in (2). So, SIGSEGV occurs when using the unmapped memory region. Solution: Fixes this issue by skip unmap "reuse" MemMap in destructor. And always create reservation MemMap before "reuse" MemMap. (It also solved the fixupELF case which does not reserve the whole needed memory region). Bug: 16486685 Change-Id: I8f2538861d5c3fa7b9a04d2c3f516319cc060291
* Use the uncached form of BacktraceMap::Create.Christopher Ferris2014-08-041-3/+3
| | | | | | | | | | The code assumes that calling BacktraceMap::Create creates a map based on the current state of the maps. This is not true by default, so call the Create function indicating we want an uncached BacktraceMap object. (cherry picked from 27a10f618357cf85cc0677a04f0a5a3a8a437aed) Change-Id: Ic7a2dedaea9950174b24ede4dcda30ffe036fe93
* Fix the Mac build on x86-64.Ian Rogers2014-06-251-3/+3
| | | | Change-Id: I4ed3783a96d844de0b0a295df26d0a48c02a3726
* Mac doesn't define MAP_ANONYMOUSIan Rogers2014-06-231-0/+4
| | | | | | Fix mac build. Change-Id: I607e8fff227259fbf27e468193a705c8c3fc1b59
* Limit the size of files created by run-test to 2MB.Ian Rogers2014-06-221-12/+27
| | | | | | | In MemMap::MapAnonymous on the host, avoid creating ashmem regions that are backed by files, when the size of the file will be greater than the ulimit. Change-Id: I7cbf2ac59bf5869ed85850bea8d71898f3b7e1c7
* Remove deprecated WITH_HOST_DALVIK.Ian Rogers2014-06-101-0/+12
| | | | | | | | | | | | | | | | | | | | | | | Bug: 13751317 Fix the Mac build: - disable x86 selector removal that causes OS/X 10.9 kernel panics, - madvise don't need does zero memory on the Mac, factor into MemMap routine, - switch to the elf.h in elfutils to avoid Linux kernel dependencies, - we can't rely on exclusive_owner_ being available from other pthread libraries so maintain our own when futexes aren't available (we can't rely on the OS/X 10.8 hack any more), - fix symbol naming in assembly code, - work around C library differences, - disable backtrace in DumpNativeStack to avoid a broken libbacktrace dependency, - disable main thread signal handling logic, - align the stack in stub_test, - use $(HOST_SHLIB_SUFFIX) rather than .so in host make file variables. Not all host tests are passing on the Mac with this change. dex2oat works as does running HelloWorld. Change-Id: I5a232aedfb2028524d49daa6397a8e60f3ee40d3
* Merge "Verify there's no mem map gap for immune region not to break."Hiroshi Yamauchi2014-06-051-3/+92
|\
| * Verify there's no mem map gap for immune region not to break.Hiroshi Yamauchi2014-06-041-3/+92
| | | | | | | | | | | | | | | | | | | | | | This adds code that verifies that there's no memory map gap between the image space and the main space so that the immune region functionality won't silently break. For example, if there's a gap and a large object is allocated in that gap, the large object is incorrectly part of the immune region and the marking breaks. Bug: 14059466 Change-Id: Ie6ed82988d74b6d0562ebbbaac96ee43c15b14a6
* | Fix race condition in MemMap::MapAnonymous.Mathieu Chartier2014-05-301-3/+8
|/ | | | | | | | | | | | | | Previously we were using MAP_FIXED which introduced a serious race condition if MAP_32BIT was set since it would possibly overwrite an existing map at the address which we determined was free with msync. There was a window of time after we had msynced a page where another thread could map something at that page. The new method avoids using MAP_FIXED and unmaps allocations which succeed but aren't in the low 4GB when MAP_32BIT is set. Bug: 15338094 Bug: 14974497 Change-Id: I57f00baf4143e9fa17fb1d4c2be04b30705a2bfd
* ART: Randomize mem_map start address for linear scan searchAndreas Gampe2014-05-201-2/+58
| | | | | | | When using linear scan for mem_map, randomize the start of the search with getauxval(AT_RANDOM). Change-Id: Id1e4c86b928147d74b9b0b73ff704de5d87b4500
* Now we have a proper C++ library, use std::unique_ptr.Ian Rogers2014-05-191-2/+2
| | | | | | | Also remove the Android.libcxx.mk and other bits of stlport compatibility mechanics. Change-Id: Icdf7188ba3c79cdf5617672c1cfd0a68ae596a61
* ART: Move start of linear mmap_scan out of reserved spaceAndreas Gampe2014-05-161-2/+2
| | | | | | | | The first 64KB are protected by SELinux, and we will never be able to acquire them. Bug: 15024270 Change-Id: I186a0d5262d396a089d4028a8527a9c56f96dc49
* Compatibility layer to transition from UniquePtr to std::unique_ptr.Ian Rogers2014-05-151-1/+1
| | | | | | | | | Use ART_WITH_STLPORT (enabled for the target) to cause the use of UniquePtr, for the host switch to std::unique_ptr. For now the type remains called UniquePtr. Make dalvik compile with clang on the host, move its build to C++11. Change-Id: I5ba8d2757904bc089ed62047ea03de3c0853fb12
* ART: Resolve MAP_32BIT limitation in x86_64Qiming Shi2014-05-141-1/+15
| | | | | | | | | | | | | Add checks that ensure when low4gb is set and an expected pointer is given the requested memory fits into 4GB. On x86_64, only use MAP_32BIT when there is no expected pointer. This avoids a limitation in mmap (only 2GB visible). Add tests to check behavior. Original Author: Qiming Shi <qiming.shi@intel.com> Change-Id: Ia2e3e0a46764ef70126b0c264f1fae681622d3cb
* Merge "Fixes to mem_map wraparound and ARM64 quick_invoke assembly"Andreas Gampe2014-03-241-1/+1
|\
| * Fixes to mem_map wraparound and ARM64 quick_invoke assemblyAndreas Gampe2014-03-211-1/+1
| | | | | | | | | | | | | | | | | | There are only 6 free GPRs for passing in a non-static invoke. This corrupted one register for long-signature methods. The wrap-around did not actually wrap around correctly. Change-Id: I62658dadeb83bb22960b9455e211d26ffaa20f6f
* | Avoid strerror until we are sure there is an errorBrian Carlstrom2014-03-241-8/+14
|/ | | | Change-Id: I8f0c5a9cb1b07bfffd5ce9f9ca33f53c8834e9f5
* Fix sign problem, implement low-mem mmap wraparoundAndreas Gampe2014-03-211-1/+19
| | | | | | | | | | A signed value comparison meant that on 64b systems comparisons were false when pointers > 2GB were in use (as happens in long-running tests). Fix this to be uint. Implement a simple wrap-around in the MAP_32BIT emulation code. Change-Id: I09870b4755f2dca676e42e701fbb6f6eb4bb95d0
* Quick typo fix in the 4GB lowmem codeAndreas Gampe2014-03-171-2/+2
| | | | Change-Id: I3371776b0468cd8690e3811c7a1e57f5444e9d8f
* AArch64: Add memory allocation in low 4GBStuart Monteith2014-03-171-2/+57
| | | | | | | | | | | | | | | MAP_32BIT is implemented for only x86_64. Other 64bit platforms don't have an equivalent. This is a unsophisticated implemention of a scheme using msync and MAP_FIXED to reproduce the functionality of MAP_32BIT. Adds MAP_FIXED to RemapAtEnd, as the address used for the new mmap doesn't get located correctly without it on aarch64. Add MemMap::next_mem_pos_ to store last position. Add a safety assert. Change-Id: I61871ff7fc327554c43e1d7f448c3d376490f1ea
* Make MemMap::MapAnonymous() fail if the requested address is not available.Hiroshi Yamauchi2014-03-141-54/+86
| | | | | | | | | | | | | | | | | | Change MapAnonymous() so that a requested address vs. actual map address mismatch will cause a failure. The existing MapAnonymous() call sites do not check this. This should prevent potential rare case bugs where mmap does not happen to map a region at an specified address. There's a potential bug that if MapAnonymous() does not guarantee the requested address (and there's a gap between the image/oat files and the zygote/malloc space), then GC could in theory allocate a large object space in the gap. This would break the GC notion of the immune space. This change will prevent this by causing all non-moving spaces to be (really) adjacent, with no gaps in between, which CL 87711 missed. Change-Id: Id4adb0e30adbad497334d7e00def4c0c66b15719
* Print error message if ImageSpace::Init fails.Mathieu Chartier2014-03-051-4/+5
| | | | | | | | Also changed some of the args in mem_map.cc to print as hex. Bug: 13323732 Change-Id: I02cd81300793515d143e94473f48fc701e401b38
* Object model changes to support 64bit.Ian Rogers2014-02-061-2/+6
| | | | | | | | | | | | | | | | | | | | | | | Modify mirror objects so that references between them use an ObjectReference value type rather than an Object* so that functionality to compress larger references can be captured in the ObjectRefererence implementation. ObjectReferences are 32bit and all other aspects of object layout remain as they are currently. Expand fields in objects holding pointers so they can hold 64bit pointers. Its expected the size of these will come down by improving where we hold compiler meta-data. Stub out x86_64 architecture specific runtime implementation. Modify OutputStream so that reads and writes are of unsigned quantities. Make the use of portable or quick code more explicit. Templatize AtomicInteger to support more than just int32_t as a type. Add missing, and fix issues relating to, missing annotalysis information on the mutator lock. Refactor and share implementations for array copy between System and uses elsewhere in the runtime. Fix numerous 64bit build issues. Change-Id: I1a5694c251a42c9eff71084dfdd4b51fff716822
* Fix apps with more than one dex file with the same nameBrian Carlstrom2014-02-061-2/+9
| | | | | | | | | | | | Reverts most of 60836d5a9bcf8b30984aae4279a4f6233b0bf622 which I believe was an incorrect attempt to address issue introduced in 8d31bbd3d6536de12bc20e3d29cfe03fe848f9da, which is also reverted here. Also adds some debugging aids include operator<< for DexFile and MemMap and checksum information to OatFile logging. Bug: 12802375 Change-Id: Idd6f7dd487f6e01e9479cd15cd4b61580160e8a3
* Modify to use new BacktraceMap creation function.Christopher Ferris2014-01-271-4/+5
| | | | Change-Id: I703ef4a26917678236b931d81b7e4c758754742b
* Move __STDC_FORMAT_MACROS to a cflag.Ian Rogers2014-01-231-1/+0
| | | | | | | | | Current inttypes.h don't define stdint printf formatting characters for C++ but in the future this will change. Rather than #define __STDC_FORMAT_MACROS at the point of inclusion (conventional) pass it as a cflag so there is a single place to remove the #define when conventions change. Change-Id: Ice2fb07e19d8fc06ebc534c903a2d02497c31b3d
* 64bit friendly printf modifiers in mem map errors.Ian Rogers2014-01-231-3/+6
| | | | Change-Id: I197c6cf08053b9c833e50156a92965b3b66698eb
* Change to support new BacktraceMap.Christopher Ferris2014-01-161-17/+25
| | | | Change-Id: I291313583dca2c8e1e946504c442f5810f0fb477
* Add more logging when mmap fails.Mathieu Chartier2013-11-131-3/+4
| | | | | | We now print the reason that the mmap failed. Change-Id: Ie515e4bba117c9ea1f4297abb826d32172bea962
* am 7b5f0cf0: Use libbacktrace instead of libcorkscrew.Christopher Ferris2013-11-051-6/+6
|\ | | | | | | | | * commit '7b5f0cf08f74ff36760a813888779d28a175982d': Use libbacktrace instead of libcorkscrew.
| * Use libbacktrace instead of libcorkscrew.Christopher Ferris2013-11-041-6/+6
| | | | | | | | | | | | | | | | Also, removed the ignore frames of 2, this was causing threads to chop the lower two frames. The original code assumed that the calls to decode the frame were in the unwind trace, but that's not the case. Change-Id: Ifc0da0227f9114a5b462ef88e038439d58f951e9