summaryrefslogtreecommitdiffstats
path: root/runtime/mirror/class-inl.h
Commit message (Collapse)AuthorAgeFilesLines
* Set vtable in class object to null after linking.Mingyao Yang2014-07-221-5/+45
| | | | | | | | This is follow-up work of embedding imt and vtable for faster interface/virtual call dispatching. Once vtable becomes embedded, the original vtable is nulled. Change-Id: I307696657d1e283654169dbecb8f7815c42bbabc
* Revert "Revert "Revert "Revert "Add intrinsic for Reference.get()""""Fred Shih2014-07-151-0/+30
| | | | | | | Fixed TargetReg issue causing build failure for x86. This reverts commit 9e82bd3f0ce9e5f5777bea2f752ff3e251d32f9f. Change-Id: I7e6a526954467aaf68deeed999880dfe9aa5f06e
* Improve performance of invokevirtual/invokeinterface with embedded imt/vtableMingyao Yang2014-07-111-6/+106
| | | | | | | | | 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
* Add missing class initialization during compilation and testsSebastien Hertz2014-07-101-0/+8
| | | | | | | | | | | | | | | | | Adds missing class initialization during compilation and tests, especially java.lang.Class. Otherwise, we'd be able to execute code while the referring class is not initialized or initializing. Also adds mirror::Class::AssertInitializedOrInitializingInThread method to check class initialization when entering the interpreter: the called method's declaring class must either be initialized or be initializing by the current thread (other threads must be waiting for the class initialization to complete holding its lock). Note we only do this check in debug build. Bump oat version to force compilation. Bug: 15899971 Change-Id: I9a4edd3739a3ca4cf1c4929dcbb44cdf7a1ca1fe
* Add read barriers to the constant roots.Hiroshi Yamauchi2014-06-271-2/+4
| | | | | | | | | This change makes it possible to concurrently scan the constant roots (the roots visited by Runtime::VisitConstantRoots()) such as the class of java.lang.Class by adding read barriers. Bug: 12687968 Change-Id: If1afea471c4e1093688d2db37b7f1fc2742edeef
* Add mark compact collector.Mathieu Chartier2014-06-191-1/+3
| | | | | | | | | | | | | | | | | | | | | | The mark compact collector is a 4 phase collection, doing a normal full mark_sweep, calculating forwarding addresses of objects in the from space, updating references of objects in the from space, and moving the objects in the from space. Support is diabled by default since it needs to have non movable classes and field arrays. Performance numbers is around 50% as fast. The main advantage that this has over semispace is that the worst case memory usage is 50% since we only need one space isntead of two. TODO: Make field arrays and classes movable. This causes complication since Object::VisitReferences relies on these, so if we update the fields of an object but another future object uses this object to figure out what fields are reference fields it doesn't work. Bug: 14059466 Change-Id: I661ed3b71ad4dde124ef80312c95696b4a5665a1
* Simplify Class::IsArtFieldClass().Hiroshi Yamauchi2014-05-201-9/+4
| | | | | | | | | | | | | | | | | | | Fix the slight glitch that when ImageSpace::VerifyImageAllocations() called in ImageSpace::Create(), the ArtField and ArtMethod class roots weren't set, which were used by DCHECKs in Object::Size(), which VerifyImageAllocations() calls, by delaying the point of the VerifyImageAllocations() call to Runtime::Init() at which point the class linker has set the class roots. To completely disable read barriers from Object::SizeOf(), the ReadBarrierOption template parameter should have been added to Class::GetInstanceField(), which calls GetFieldObject(), when it's called from Class::IsArtFieldClass(). This change fixes this by removing the need for the call, instead of adding the ReadBarrierOption parameter. Bug: 12687968 Change-Id: Ibbecc08f4e3b898851805d690dff8ccac55e94f2
* Now we have a proper C++ library, use std::unique_ptr.Ian Rogers2014-05-191-13/+13
| | | | | | | 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-2/+22
| | | | | | | | | | | 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
* Make it possible to disable read barriers in Class::GetObjectSize()Hiroshi Yamauchi2014-05-091-1/+14
| | | | | | | | | This is a leftover from cl/91831 (commit 9103c86a98524e9ddfd14f8cee56e919f68eee9b) that attempted to make it possible to disable read barriers in Object::SizeOf(). Bug: 12687968 Change-Id: I2b05076832936881ec61bc21b6eb6b7c04e0a1f0
* Merge "Add finalizer references from the entrypoints."Mathieu Chartier2014-05-021-3/+12
|\
| * Add finalizer references from the entrypoints.Mathieu Chartier2014-05-011-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We now have an invariant where we never allocate finalizable objects with the Initialized or Resolved entrypoints. This speeds up allocation by only doing the check in the slow path. Before: MemAllocTest: 3625, 3707, 3641 EvaluateAndApplyChanges: 3448, 3421, 3413 After: MemAllocTest: 3164, 3109, 3135 EvaluateAndApplyChanges: 3272, 3299, 3353 Bug: 14078487 Change-Id: I2b0534af3e7c75ea5e5257cf3647744f7abfb74e
* | Replace the bool kDoReadBarrier template parameter with an enum.Hiroshi Yamauchi2014-05-011-5/+5
|/ | | | | | | | | Fix one kDoReadBarrier/kIsVolatile mixup in an Object::GetFieldObject call. Bug: 12687968 Change-Id: I896b1137b21a20c0504abd2bf3fe6f83805f3300
* Force inlining on trivial accessors.Ian Rogers2014-04-291-42/+56
| | | | | | | | | Make volatility for GetFieldObject a template parameter. Move some trivial mirror::String routines to a -inl.h. Bug: 14285442 Change-Id: Ie23b11d4f18cb15a62c3bbb42837a8aaf6b68f92
* More code for the read barrier support.Hiroshi Yamauchi2014-04-221-0/+13
| | | | | | | | | | | | Make it possible to disable the RB in Object::SizeOf() (and the functions it calls transitively) which the collector will need to call to get the size of an object when copying. Add Object::AtomicSetReadBarrierPointer() for atomic write of a RB pointer. Bug: 12687968 Change-Id: Ibedd252860ac7ccd17e4e7d71b377a8892b48ff0
* Fix Object::Clone()'s pre-fence barrier.Hiroshi Yamauchi2014-04-031-2/+9
| | | | | | | | | | | | | | Pass in a pre-fence barrier object that sets in the array length instead of setting it after returning from AllocObject(). Fix another potential bug due to the wrong default pre-fence barrier parameter value. Since this appears error-prone, removed the default parameter value and make it an explicit parameter. Fix another potential moving GC bug due to a lack of a SirtRef. Bug: 13097759 Change-Id: I466aa0e50f9e1a5dbf20be5a195edee619c7514e
* Refactor object reference visiting logic.Mathieu Chartier2014-03-241-0/+6
| | | | | | | Refactored the reference visiting logic to be in mirror::Object instead of MarkSweep. Change-Id: I773249478dc463d83b465e85c2402320488577c0
* Fix SafePrettyTypeOf to never call VerifyObject.Mathieu Chartier2014-03-031-1/+2
| | | | | | | Calling VerifyObject from the segfault handler caused another segfault. Change-Id: I459646594d830cbb110a4ac2bac25a7b90794854
* Fix and optimize verify object.Mathieu Chartier2014-02-211-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Do not FixupStaticTrampolines of uninitialized classesBrian Carlstrom2014-02-191-1/+1
| | | | | Bug: 13027732 Change-Id: I5966d63afd8fbcd091801297290f117f3c9cb44c
* Remove blacklistSebastien Hertz2014-02-171-16/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Object model changes to support 64bit.Ian Rogers2014-02-061-69/+61
| | | | | | | | | | | | | | | | | | | | | | | 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
* Make DexCache references const.Vladimir Marko2014-02-041-6/+6
| | | | | | Clean up after https://android-review.googlesource.com/80446 . Change-Id: I32dac9d8aa68bb891ec8b551d771f65db7be409d
* Don't assume resolved type has the same dex cache.Vladimir Marko2014-02-031-8/+32
| | | | | | | | | When we resolve a type with a certain DexCache that type's GetDexCache() doesn't necessarily return the same DexCache. This could have led to the wrong DexFile being used in access checks by the CompilerDriver. Change-Id: I2c836477f69f142bcbff902207dc0ad83854a398
* Clean up access checks.Vladimir Marko2014-01-211-0/+63
| | | | Change-Id: Ia62ba6c8f1d0a9bfbbfde2d7be4c52c0f982b9d2
* Thread local bump pointer allocator.Mathieu Chartier2013-12-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added a thread local allocator to the heap, each thread has three pointers which specify the thread local buffer: start, cur, and end. When the remaining space in the thread local buffer isn't large enough for the allocation, the allocator allocates a new thread local buffer using the bump pointer allocator. The bump pointer space had to be modified to accomodate thread local buffers. These buffers are called "blocks", where a block is a buffer which contains a set of adjacent objects. Blocks aren't necessarily full and may have wasted memory towards the end. Blocks have an 8 byte header which specifies their size and is required for traversing bump pointer spaces. Memory usage is in between full bump pointer and ROSAlloc since madvised memory limits wasted ram to an average of 1/2 page per block. Added a runtime option -XX:UseTLAB which specifies whether or not to use the thread local allocator. Its a NOP if the garbage collector is not the semispace collector. TODO: Smarter block accounting to prevent us reading objects until we either hit the end of the block or GetClass() == null which signifies that the block isn't 100% full. This would provide a slight speedup to BumpPointerSpace::Walk. Timings: -XX:HeapMinFree=4m -XX:HeapMaxFree=8m -Xmx48m ritzperf memalloc: Dalvik -Xgc:concurrent: 11678 Dalvik -Xgc:noconcurrent: 6697 -Xgc:MS: 5978 -Xgc:SS: 4271 -Xgc:CMS: 4150 -Xgc:SS -XX:UseTLAB: 3255 Bug: 9986565 Bug: 12042213 Change-Id: Ib7e1d4b199a8199f3b1de94b0a7b6e1730689cad
* Search for miranda methods in virtual methods instead of interface.Jeff Hao2013-11-211-1/+1
| | | | | | | | | Also added tests that get miranda methods via reflection and jni. Miranda methods can't be found via reflection, and have the interface class as their declaring class when found via jni. Bug: 11736932 Change-Id: I92b4fdf31be64269898ed2686a28dfb6008b213a
* Refactor allocation entrypoints.Mathieu Chartier2013-11-201-15/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | Adds support for switching entrypoints during runtime. Enables addition of new allocators with out requiring significant copy paste. Slight speedup on ritzperf probably due to more inlining. TODO: Ensuring that the entire allocation path is inlined so that the switch statement in the allocation code is optimized out. Rosalloc measurements: 4583 4453 4439 4434 4751 After change: 4184 4287 4131 4335 4097 Change-Id: I1352a3cbcdf6dae93921582726324d91312df5c9
* Compacting collector.Mathieu Chartier2013-11-111-7/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Implement Interface Method Tables (IMT).Jeff Hao2013-10-291-0/+8
| | | | Change-Id: Idf7fe85e1293453a8ad862ff2380dcd5db4e3a39
* Fix incorrect initial dex cache size.Mathieu Chartier2013-10-231-3/+1
| | | | | | | | | | We were previously setting it to be sizeof(DexCacheClass) instead of sizeof(DexCache). This was causing some problems with compaction when I relied on the object sizes being accurate to visit objects in the bump pointer space. Bug: 8981901 Change-Id: Iede04763aced041986b1b239368fc867143ad70d
* Split the allocation path into 'instrumented' and 'uninstrumented'Hiroshi Yamauchi2013-09-251-2/+12
| | | | | | | | | | | | | | | | | | ones. The instrumented path is equivalent to the existing allocation path that checks for three instrumentation mechanisms (the debugger allocation tracking, the runtime allocation stats collection, and valgrind) for every allocation. The uinstrumented path does not perform these checks. We use the uninstrumented path by default and enable the instrumented path only when any of the three mechanisms is enabled. The uninstrumented version of Heap::AllocObject() is inlined. This change improves the Ritz MemAllocTest by ~4% on Nexus 4 and ~3% on Host/x86. Bug: 9986565 Change-Id: I3e68dfff6789d77bbdcea98457b694e1b5fcef5f
* More allocation code optimizations.Hiroshi Yamauchi2013-09-111-0/+9
| | | | | | | | | | | - Inline Class::AllocObject() and Array::Alloc(). - Inline some short Mutex functions and add LIKELY/UNLIKELY to some Mutex functions. - This change improves the Ritz MemAllocTest by ~6% on Nexus 4 and ~10% on host. Bug: 9986565 Change-Id: I1606c74ddb21676cbc1de1a40e9b076fc23eaea4
* Refactor java.lang.reflect implementationBrian Carlstrom2013-08-131-44/+43
| | | | | | | | | | | Cherry-picked from commit ed41d5c44299ec5d44b8514f6e17f802f48094d1. Move to ArtMethod/Field instead of AbstractMethod/Field and have java.lang.reflect APIs delegate to ArtMethod/ArtField. Bug: 10014286. Change-Id: Iafc1d8c5b62562c9af8fb9fd8c5e1d61270536e7
* Fix cpplint whitespace/braces issuesBrian Carlstrom2013-07-171-3/+3
| | | | Change-Id: Ide80939faf8e8690d8842dde8133902ac725ed1a
* Fix multiple inclusion guards to match new pathnamesBrian Carlstrom2013-07-171-3/+3
| | | | Change-Id: Id7735be1d75bc315733b1773fba45c1deb8ace43
* Create separate Android.mk for main build targetsBrian Carlstrom2013-07-121-0/+349
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