summaryrefslogtreecommitdiffstats
path: root/compiler/image_writer.cc
Commit message (Collapse)AuthorAgeFilesLines
...
* Avoid use of std::string where we have const char*.Ian Rogers2014-08-121-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | Removing the ClassHelper caused std::string creation for all calls to Class::GetDescriptor and a significant performance regression. Make the std::string an out argument so the caller can maintain it and its life time while allowing GetDescriptor to return the common const char* case. Don't generate GC maps when compilation is disabled. Remove other uses of std::string that are occuring on critical paths. Use the cheaper SkipClass in CompileMethod in CompilerDriver. Specialize the utf8 as utf16 comparison code for the common shorter byte encoding. Force a bit of inlining, remove some UNLIKELYs (they are prone to pessimizing code), add some LIKELYs. x86-64 host 1-thread interpret-only of 57 apks: Before: 29.539s After: 23.467s Regular compile: Before: 1m35.347s After: 1m20.056s Bug: 16853450 Change-Id: Ic705ea24784bee24ab80084d06174cbf87d557ad
* Runtime can now be set to require relocationAlex Light2014-07-221-202/+24
| | | | | | | | | | | | | | Add a pair of runtime flags -Xrelocate and -Xnorelocate that can force the runtime to require that all files that are run are relocated, to prevent attacks based on the known art base address. Add support for running patchoat on oat files compiled without an image. Change run-test to have new --prebuild and --relocate flags. Bug: 15358152 Change-Id: I91166c62dd1ab80e5cbcb7883a2cd0d56afca32d
* Remove object_utils.h.Ian Rogers2014-07-161-1/+0
| | | | | | | | | Break into object_lock, field_helper and method_helper. Clean up header files following this. Also tidy some of the Handle code in response to compiler errors when resolving the changes in this CL. Change-Id: I73e63015a0f02a754d0866bfaf58208aebcaa295
* Improve performance of invokevirtual/invokeinterface with embedded imt/vtableMingyao Yang2014-07-111-26/+82
| | | | | | | | | Add an embedded version of imt/vtable into class object. Both tables start at fixed offset within class object so method/entry point can be loaded directly from class object for invokeinterface/invokevirtual. Bug: 8142917 Change-Id: I4240d58cfbe9250107c95c0708c036854c455968
* Fix some style nitpicksAlex Light2014-07-081-7/+6
| | | | Change-Id: Icfdd327f4ddf129f0a8607162c09ba271c1d49d9
* Add patchoat tool to Art.Alex Light2014-07-071-6/+76
| | | | | | | | | | | | | 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
* Add more read barriers to the class linker.Hiroshi Yamauchi2014-06-241-7/+28
| | | | | | | | | This change makes it possible to concurrently scan the remaining roots in the class linker (the non-class-table roots that are visited by ClassLinker::VisitRoots()) by adding read barriers. Bug: 12687968 Change-Id: I66fecf7a303eee7537429e018f38da8270b18c67
* Fix interpreter entrypoint initialization in the imageSebastien Hertz2014-06-021-9/+39
| | | | | | | | | | Sets the interpreter_to_interpreter_bridge entrypoint if the method is not compiled. This avoids the slow path through Quick compiler's world.i Bumps oat version to force recompilation of image. Bug: 15098601 Change-Id: I08f7dfce26ecc5ca88bdf21187b2909c0c069596
* Revert "Revert "Clean up image writer patching.""Mathieu Chartier2014-05-301-4/+4
| | | | | | This reverts commit fb241b6e93f8b54122b978ad0df23a9e514eef0f. Change-Id: I99da82fd549bcdc3c2fdfe496147897335c50b8e
* Revert "Clean up image writer patching."Mathieu Chartier2014-05-301-4/+4
| | | | | | This reverts commit fc3b871ca37593561e3b67006771710bf4d174ea. Change-Id: I4d1250f3adcd17fcd1b63496816e098db4d5be3c
* Clean up image writer patching.Mathieu Chartier2014-05-291-4/+4
| | | | | | | Also fixed an issue related to incorrect patching of non relative patches. Change-Id: I55b0b3814b65b7fa8749a934dfaaf07b97735304
* Add support for relative patching to quick offsets.Mathieu Chartier2014-05-291-12/+24
| | | | | | | | | | | | | We now have support for patching relative patches to quick offsets (interpreter bridge, generic trampoline). This fixes an issue where the compiler was generating relative branches to methods but then later deciding to not compile them, we now properly patch these in the image writer. Credits: agampe for help. Bug: 15283931 Change-Id: I3ea5278b39def6c442432fb14103a91c6eae6d0f
* Revert "Revert "Fix an outstanding compaction bug in interpreter.""Mathieu Chartier2014-05-231-9/+5
| | | | | | | | | | Fixed the generic trampoline to not use ToJObject when unnecessary. Bug: 15167269 This reverts commit 3bdb873122964da7937eb070cbcf2ef638a8e459. Change-Id: I0525d0e0f3afb753c770e1572070a0fa22b02271
* Revert "Fix an outstanding compaction bug in interpreter."Mathieu Chartier2014-05-221-5/+9
| | | | | | This reverts commit e09ae0920be57760fb390b6944bce420fa0b5582. Change-Id: I48036306130d5ccfec683d0dc3e9a642a02ee9c1
* Fix an outstanding compaction bug in interpreter.Mathieu Chartier2014-05-221-9/+5
| | | | | | | | | | | | | | | | Fixed a bug in DoFieldPut where the FieldHelper GetType could cause thread suspension which would result in a stale obj. Added more handles in the class linker to facilitate moving fiels and methods in the future. Removed un-necessarly passing handle references since these are value types and don't need to be passed by reference. Added a special NullHandle type which allows null handles without a handle scope. Change-Id: I1b51723920a2e4f4f8b2907066f578a3e879fd5b
* Now we have a proper C++ library, use std::unique_ptr.Ian Rogers2014-05-191-4/+4
| | | | | | | Also remove the Android.libcxx.mk and other bits of stlport compatibility mechanics. Change-Id: Icdf7188ba3c79cdf5617672c1cfd0a68ae596a61
* Delete ClassHelper and fix compaction bug in GetDirectInterfaceMathieu Chartier2014-05-181-4/+6
| | | | | | | | | | | Cleanup helps to prevent compaction bugs. Fixed a fairly serious compaction error caused by calling ClassHelper::GetDirectInterface without handling the case where it causes thread suspension due to ResolveType. Bug: 8981901 Change-Id: I82b3bb6dd48d21eb6ece7aae0733c4a23c2bc408
* Fix generic jni issue in ArtMethod::GetQuickFrameInfoDmitry Petrochenko2014-05-161-1/+2
| | | | | | | | | | | | | | | The 64-bit host mode fails to start due to incorrect detection of GetQuickGenericJniTrampoline. The quick_code is 32-bit and taken from oat file, but GetQuickGenericJniTrampoline returnf 0x7fffxx (64-bit) address of trampoline and execution went to incorrect way. Some clean-up. Original Author: Dmitry Petrochenko <dmitry.petrochenko@intel.com> Signed-off-by: Dmitry Petrochenko <dmitry.petrochenko@intel.com> Signed-off-by: Serguei Katkov <serguei.i.katkov@intel.com> Change-Id: I0952443b2a9f6833ad37ec373837ae208681fad7
* 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
* Add Handle/HandleScope and delete SirtRef.Mathieu Chartier2014-05-131-36/+39
| | | | | | | | | | | | | | | | Delete SirtRef and replaced it with Handle. Handles are value types which wrap around StackReference*. Renamed StackIndirectReferenceTable to HandleScope. Added a scoped handle wrapper which wraps around an Object** and restores it in its destructor. Renamed Handle::get -> Get. Bug: 8473721 Change-Id: Idbfebd4f35af629f0f43931b7c5184b334822c7a
* Replace the bool kDoReadBarrier template parameter with an enum.Hiroshi Yamauchi2014-05-011-1/+1
| | | | | | | | | Fix one kDoReadBarrier/kIsVolatile mixup in an Object::GetFieldObject call. Bug: 12687968 Change-Id: I896b1137b21a20c0504abd2bf3fe6f83805f3300
* Force inlining on trivial accessors.Ian Rogers2014-04-291-6/+6
| | | | | | | | | Make volatility for GetFieldObject a template parameter. Move some trivial mirror::String routines to a -inl.h. Bug: 14285442 Change-Id: Ie23b11d4f18cb15a62c3bbb42837a8aaf6b68f92
* Move mapping table and vmap table offsets to OatMethodHeader.Vladimir Marko2014-04-251-8/+0
| | | | | | | | | This change has a libcore/ companion CL "Remove ArtMethod's quick fields mapping table and vmap table." https://android-review.googlesource.com/91254 Bug: 11767815 Change-Id: I46ce2067e1ecd915da3890606498e31ffc332813
* Use non volatile lock words in semispace collector.Mathieu Chartier2014-04-171-8/+8
| | | | | | | | | | GSS FormulaEvaluationActions.EvaluateAndApplyChanges: Before GC time: 9.1s After GC time: 7.98s Fixed timing logger errors. Change-Id: I4193c6ccbbbe7a7220dfaabbf3472a5dcebae616
* Refactor space bitmap to support different alignments.Mathieu Chartier2014-04-141-3/+3
| | | | | | | | | | | Required for: Using space bitmaps instead of std::set in mod union table + remembered set. Using a bitmap instead of set for large object marking. Bug: 13571028 Change-Id: Id024e9563d4ca4278f79607cdb2f81895121b113
* Make the support code for read barriers a bit more general.Hiroshi Yamauchi2014-03-311-5/+7
| | | | | | | Add an option for Baker in addition to Brooks. Bug: 12687968 Change-Id: I8a31db817ff6686c72951b6534f588228e270b11
* Refactor image writer reference visiting logic.Mathieu Chartier2014-03-241-94/+35
| | | | | | Now uses Object::VisitReferences. Change-Id: I5a4557e10796d6f34596f2e8796ad9382121c567
* Allow patching between dex files in the boot classpath.Jeff Hao2014-03-121-6/+6
| | | | Change-Id: I53f219a5382d0fcd580e96e50025fdad4fc399df
* A few 64bit fixes.Ian Rogers2014-03-121-3/+6
| | | | Change-Id: I1fe189d638b9cb5127b897da6cecdad6902db930
* Add more VerifyObject calls.Mathieu Chartier2014-03-071-1/+1
| | | | | | | | | | | Added verify object calls to SirtRef, IndirectReferenceTable, ReferenceTable. Removed un-needed verify object in ScopedObjectAccess / DecodeJObject since object sources are handled. Bug: 12934910 Change-Id: I55a46a8ea61fed2a77526eda27fd2cce97a9b125
* Revert "Revert "Avoid compiling monster methods in boot image""Brian Carlstrom2014-03-051-5/+7
| | | | | | | | This reverts commit f679fab9be8905505d26a62bea257641f0bb0168. (cherry picked from commit 9d0bdfe63bec5a43d7668d9094a52caf77b6ed53) Change-Id: I72af1d44483edbd2a5f2e6b678e43f740d4613fd
* Support compiler filters for boot classpathBrian Carlstrom2014-03-041-7/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | image_writer.cc Remove assumption that all methods in the boot classpath are compiled oat_writer.cc Don't skip writing ArtMethod::quick_code_offset_ for methods that need resolution, leave that to ImageWriter dex2oat.cc Allow dex2dex compilation of image dex files by making the in memory pages writable in all cases, not just app case. oatdump.cc dump new OatHeader fields use ImageSpace.GetImageFilename, not command line image filename, since location may be in dalvik-cache remove inaccurate check about non-null GC map quick_trampoline_entrypoints.cc add and improve some DCHECKS that were useful while debugging class_linker.cc image_space.cc fix double facepalm parsed_options.cc fix zygote logging to not skip values to two part options like -classpath <foo> runtime.cc wireup parsed compiler options to runtime Change-Id: Iad314df0b80623c0663d61713d5098297ab9ac87
* Remove oat file location in the image.Nicolas Geoffray2014-03-041-2/+0
| | | | | | | | | The oat file is now always in the same directory, and has the same name as the image file. Only difference is the extension. This also removes the need for host-prefix. Change-Id: I16d1f7aeb1d58372d41921694664e9c321afc1ad
* Initial changes towards Generic JNI optionAndreas Gampe2014-03-031-3/+16
| | | | | | | | Some initial changes that lead to an UNIMPLEMENTED. Works by not compiling for JNI right now and tracking native methods which have neither quick nor portable code. Uses new trampoline. Change-Id: I5448654044eb2717752fd7359f4ef8bd5c17be6e
* (Experimental) Add Brooks pointers.Hiroshi Yamauchi2014-02-251-0/+6
| | | | | | | | | This feature is disabled by default. Verified that the Brooks pointers are installed correctly by using the CMS/SS collectors. Change-Id: Ia9be9814ab6e29169ac85edc4792ce8c81d552a9
* Avoid std::string allocations for finding an array class.Ian Rogers2014-02-241-1/+2
| | | | | | | | | | | | Introduce ClassLinker::FindArrayClass which performs an array class lookup given the element/component class. This has a 16 element cache of recently looked up arrays. Pass the current thread to ClassLinker Find .. Class routines to avoid calls to Thread::Current(). Avoid some uses of FindClass in the debugger where WellKnownClasses is a faster and more compacting GC friendly alternative. Change-Id: I60e231820b349543a7edb3ceb9cf1ce92db3c843
* Fix and optimize verify object.Mathieu Chartier2014-02-211-29/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | VerifyObject no longer resides in heap. You can now enable VerifyObject for non-debug builds. VerifyStack is still slow, so it is now guarded by its own flag. Fixed the image writer to not use verification at places where verification fails due to invalid reads. Fixed RosAlloc to use SizeOf which doesn't call verify object. Added a flag paremeter to some of the mirror getters / setters to be able to selectively disable VerifyObject on certain calls. Optimized the GC to not verify each object multiple times during object scanning if verify object is enabled. Added 3 verification options: verify reads, verify this, and verify writes so that you can select how much verification you want for mirror getters and setters. Removed some useless DCHECKs which would slow debug builds without providing any benefits. TODO: RosAlloc verification doesn't currently work with verify objects. Bug: 12934910 Bug: 12879358 Change-Id: Ic61033104dfc334543f89b0fc0ad8cd4f4015d69
* Remove blacklistSebastien Hertz2014-02-171-18/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Removes the class initialization blacklist and use transaction to detect and revert class initialization attempting to invoke native method. This only concerns class initialization happening at compilation time when generating an image (like boot.art for the system). In transactional mode, we log every object's field assignment and array update. Therefore we're able to abort a transaction to restore values of fields and array as they were before the transaction starts. We also log changes to the intern string table so we can restore its state prior to transaction start. Since transactional mode only happens at compilation time, we don't need to log all these changes at runtime. In order to reduce the overhead of testing if transactional mode is on/off, we templatize interfaces of mirror::Object and mirror::Array, respectively responsible for setting a field and setting an array element. For various reasons, we skip some specific fields from transaction: - Object's class and array's length must remain unchanged so garbage collector can compute object's size. - Immutable fields only set during class loading: list of fields, method, dex caches, vtables, ... as all classes have been loaded and verified before a transaction occurs. - Object's monitor for performance reason. Before generating the image, we browse the heap to collect objects that need to be written into it. Since the heap may still holds references to unreachable objects due to aborted transactions, we trigger one collection at the end of the class preinitialization phase. Since the transaction is held by the runtime and all compilation threads share the same runtime, we need to ensure only one compilation thread has exclusive access to the runtime. To workaround this issue, we force class initialization phase to run with only one thread. Note this is only done when generating image so application compilation is not impacted. This issue will be addressed in a separate CL. Bug: 9676614 Change-Id: I221910a9183a5ba6c2b99a277f5a5a68bc69b5f9
* Support Direct Method/Type access for X86Mark Mendell2014-02-101-1/+13
| | | | | | | | | | | Thumb generates code to optimize calls to methods within core.oat. Implement this for X86 as well, but take advantage of mov with 32 bit immediate and call relative with 32 bit immediate. Fix some incorrect return locations for long inlines. Change-Id: I1907bdfc7574f3d0aa76c7fad13dc537acdf1ed3 Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
* Object model changes to support 64bit.Ian Rogers2014-02-061-68/+64
| | | | | | | | | | | | | | | | | | | | | | | 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
* Use direct class pointers at allocation sites in the compiled code.Hiroshi Yamauchi2014-01-231-13/+53
| | | | | | | | | | | | | | | | | | | | | | | - Rather than looking up a class from its type ID (and checking if it's resolved/initialized, resolving/initializing if not), use direct class pointers, if possible (boot-code-to-boot-class pointers and app-code-to-boot-class pointers.) - This results in a 1-2% speedup in Ritz MemAllocTest on Nexus 4. - Embedding the object size (along with class pointers) caused a 1-2% slowdown in MemAllocTest and isn't implemented in this change. - TODO: do the same for array allocations. - TODO: when/if an application gets its own image, implement app-code-to-app-class pointers. - Fix a -XX:gc bug. cf. https://android-review.googlesource.com/79460/ - Add /tmp/android-data/dalvik-cache to the list of locations to remove oat files in clean-oat-host. cf. https://android-review.googlesource.com/79550 - Add back a dropped UNLIKELY in FindMethodFromCode(). cf. https://android-review.googlesource.com/74205 Bug: 9986565 Change-Id: I590b96bd21f7a7472f88e36752e675547559a5b1
* Remove intialized static storage from dex cache.Ian Rogers2014-01-081-1/+0
| | | | | | | | | The initialized static storage array is used by compiled code to determine if for a sget/sput class initialization is necessary. The compiled code typically doesn't require this test as the class is pre-initialized or the class being accessed is the same as the current method. Change-Id: Icbc45e692b3d0ac61e559e69edb6c9b29439e571
* Don't rely on gcc extensionsBernhard Rosenkränzer2013-12-121-2/+2
| | | | | | | | | | | | | | Make the code more compatible with different compilers. clang doesn't allow extra static qualifiers on template specializations, const qualifiers on function types, or inline attributes on lambda functions, and is more picky about casting away constness with reinterpret_cast. These modifications are compatible with both gcc and clang. Change-Id: I739b10df2780bec537827a13679fd2bcc2cc7188 Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
* Compact zygote.Mathieu Chartier2013-11-221-1/+1
| | | | | | | | | | | | | | | | | | | | | We now start out using the bump pointer allocator and switch to the free list collector (ROSAlloc) after the zygote forks. Before compaction: Zygote size: 9060352 After compaction Zygote size: 8425864 The main reason the size doesn't reduce more is that most of the zygote space is non-movable objects allocated by VMRuntime.newNonMovableObject. The objects which are non-movable but could be movable include around 10000 classes and some number of fields and methods. Bug: 8981901 Change-Id: Iea21b70fb7af27cb7e92d72070d278a5cd4026ac
* Don't read characters from 0 length strings.Ian Rogers2013-11-141-1/+6
| | | | | | Caught by valgrind. Bug: 11670287 Change-Id: I3acf4855c8662b804cf0c24680fc21c50c435bdb
* Fix image writer bitmap size calculation.Mathieu Chartier2013-11-131-2/+4
| | | | | | | | Wasn't properly dividing by 8 inside of the image header creation. This resulted in a bitmap size which was larger than it should be inside of the image. Change-Id: I344d1f3c1794a7cff3c9e22afc7fdabedf74413c
* Compacting collector.Mathieu Chartier2013-11-111-153/+193
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The compacting collector is currently similar to semispace. It works by copying objects back and forth between two bump pointer spaces. There are types of objects which are "non-movable" due to current runtime limitations. These are Classes, Methods, and Fields. Bump pointer spaces are a new type of continuous alloc space which have no lock in the allocation code path. When you allocate from these it uses atomic operations to increase an index. Traversing the objects in the bump pointer space relies on Object::SizeOf matching the allocated size exactly. Runtime changes: JNI::GetArrayElements returns copies objects if you attempt to get the backing data of a movable array. For GetArrayElementsCritical, we return direct backing storage for any types of arrays, but temporarily disable the GC until the critical region is completed. Added a new runtime call called VisitObjects, this is used in place of the old pattern which was flushing the allocation stack and walking the bitmaps. Changed image writer to be compaction safe and use object monitor word for forwarding addresses. Added a bunch of added SIRTs to ClassLinker, MethodLinker, etc.. TODO: Enable switching allocators, compacting on background, etc.. Bug: 8981901 Change-Id: I3c886fd322a6eef2b99388d19a765042ec26ab99
* Lazily compute object identity hash codes.Mathieu Chartier2013-10-311-2/+7
| | | | | | | | | | | | | | | Before, we computed identity hashcodes whenever we inflated a monitor. This caused issues since it meant that we would have all of these hash codes in the image, causing locks to excessively inflate during application run time. This change makes it so that we lazily compute hash codes. When a thin lock gets inflated, we assign a hash code of 0 assigned to it. This value signifies no hash code. When we try to get the identity hash code of an object with an inflated monitor, it gets computed if it is 0. Change-Id: Iae6acd1960515a36e74644e5b1323ff336731806
* Merge "Don't use UTF16 length as length for MUTF8." into dalvik-devIan Rogers2013-10-301-2/+2
|\
| * Don't use UTF16 length as length for MUTF8.Ian Rogers2013-10-301-2/+2
| | | | | | | | | | | | Bug 11367555. Change-Id: Ia0b07072a1a49d435c3b71ed9a668b316b7ff5d8