summaryrefslogtreecommitdiffstats
path: root/runtime/monitor.h
Commit message (Collapse)AuthorAgeFilesLines
* Move mirror::ArtMethod to nativeMathieu Chartier2015-06-021-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Optimizing + quick tests are passing, devices boot. TODO: Test and fix bugs in mips64. Saves 16 bytes per most ArtMethod, 7.5MB reduction in system PSS. Some of the savings are from removal of virtual methods and direct methods object arrays. Bug: 19264997 (cherry picked from commit e401d146407d61eeb99f8d6176b2ac13c4df1e33) Change-Id: I622469a0cfa0e7082a2119f3d6a9491eb61e3f3d Fix some ArtMethod related bugs Added root visiting for runtime methods, not currently required since the GcRoots in these methods are null. Added missing GetInterfaceMethodIfProxy in GetMethodLine, fixes --trace run-tests 005, 044. Fixed optimizing compiler bug where we used a normal stack location instead of double on ARM64, this fixes the debuggable tests. TODO: Fix JDWP tests. Bug: 19264997 Change-Id: I7c55f69c61d1b45351fd0dc7185ffe5efad82bd3 ART: Fix casts for 64-bit pointers on 32-bit compiler. Bug: 19264997 Change-Id: Ief45cdd4bae5a43fc8bfdfa7cf744e2c57529457 Fix JDWP tests after ArtMethod change Fixes Throwable::GetStackDepth for exception event detection after internal stack trace representation change. Adds missing ArtMethod::GetInterfaceMethodIfProxy call in case of proxy method. Bug: 19264997 Change-Id: I363e293796848c3ec491c963813f62d868da44d2 Fix accidental IMT and root marking regression Was always using the conflict trampoline. Also included fix for regression in GC time caused by extra roots. Most of the regression was IMT. Fixed bug in DumpGcPerformanceInfo where we would get SIGABRT due to detached thread. EvaluateAndApplyChanges: From ~2500 -> ~1980 GC time: 8.2s -> 7.2s due to 1s less of MarkConcurrentRoots Bug: 19264997 Change-Id: I4333e80a8268c2ed1284f87f25b9f113d4f2c7e0 Fix bogus image test assert Previously we were comparing the size of the non moving space to size of the image file. Now we properly compare the size of the image space against the size of the image file. Bug: 19264997 Change-Id: I7359f1f73ae3df60c5147245935a24431c04808a [MIPS64] Fix art_quick_invoke_stub argument offsets. ArtMethod reference's size got bigger, so we need to move other args and leave enough space for ArtMethod* and 'this' pointer. This fixes mips64 boot. Bug: 19264997 Change-Id: I47198d5f39a4caab30b3b77479d5eedaad5006ab
* Fix mismatched malloc/free delete/new.Christopher Ferris2015-04-271-0/+4
| | | | | | | | | | | | | | | Modify the monitor code to override the delete operator. The problem is the new operator is overloaded to return a pointer returned by posix_memalign, but then it's freed with a delete, not a free call. Also, fix the debugger code to use the [] for a std::unique_ptr to match how the value is actually allocated. Both problems found by ASAN. Bug: 18202869 Change-Id: I2f3a2c02a7f35399b7ba6717b08a035089fab00d
* Switch from memalign to posix_memalign for Mac buildBrian Carlstrom2015-03-031-5/+7
| | | | Change-Id: Id320015ea3999605954f53b5e266f53e968c7065
* Reserve bits in the lock word for read barriers.Hiroshi Yamauchi2015-03-031-0/+13
| | | | | | | | | This prepares for the CC collector to use the standard object header model by storing the read barrier state in the lock word. Bug: 19355854 Bug: 12687968 Change-Id: Ia7585662dd2cebf0479a3e74f734afe5059fb70f
* More of the concurrent copying collector.Hiroshi Yamauchi2015-01-231-1/+2
| | | | | Bug: 12687968 Change-Id: I62f70274d47df6d6cab714df95c518b750ce3105
* Add native memory accounting through custom allocator.Mathieu Chartier2014-08-291-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* Merge "ART: Do not recursively abort when visiting locks in a bad state"Andreas Gampe2014-08-161-1/+3
|\
| * ART: Do not recursively abort when visiting locks in a bad stateAndreas Gampe2014-08-181-1/+3
| | | | | | | | | | | | | | | | | | | | This avoids a nested abort in VisitLocks. Bug: 17080621, 16382675 (cherry picked from commit 760172c3ccd6e75f6f1a89d8006934e8ffb1303e) Change-Id: Id604976ac9dcac0e319fb25cab4d2cbc98d7ee24
* | Tidy up monitor comments.Ian Rogers2014-08-151-6/+30
| | | | | | | | Change-Id: Ib9d993f964ba6e2bec1979b486c26d3920a4a40c
* | Make Monitor::Wait more robust to spurious Inflate failures.Ian Rogers2014-08-151-0/+7
|/ | | | | | Bug: 17062710 Change-Id: Ife5f6b335caacc70cab543cd568676d277d3beb6 (cherry picked from commit 6f22fc166ed6c11cad229bff442c064e704de101)
* Add GcRoot to clean up and enforce read barriers.Hiroshi Yamauchi2014-07-291-3/+4
| | | | | | | | | | | | | Introduce a value-type wrapper around Object* for GC roots so that 1) we won't have to directly add the read barrier code in many places and 2) we can avoid accidentally bypassing/missing read barriers on GC roots (the GcRoot interface ensures that the read barrier is executed on a read). The jdwp test passed. Bug: 12687968 Change-Id: Ib167c7c325b3c7e3900133578815f04d219972a1
* Use memory chunks for monitors on LP64Andreas Gampe2014-07-101-1/+9
| | | | | | | | | | | | | | Monitor IDs in lock words are only 30b. On a 32b system that works fine, as memory is usually aligned enough that shifting works out. On 64b systems, the virtual memory space is too large for that. This adds memory chunks into which we allocate the monitors so that we have base_addr + offset and can use the offset as the monitor ID. To allow for relatively compact but growable storage, we use a list of chunks. Added a global lock for the monitor pool. Change-Id: I0e290c4914a2556e0b2eef9902422d7c4dcf536d
* Add logging to monitor deflation.Mathieu Chartier2014-06-241-1/+2
| | | | Change-Id: I0251ff19e0a3c3b9edc7c7e296f15eb3229f8f7c
* Add read barriers for the class and the intern tables.Hiroshi Yamauchi2014-06-131-1/+1
| | | | | | | | | Add read barriers for the strong roots in the intern table and the (strong) roots in the class table to make possible concurrent scanning of them. Bug: 12687968 Change-Id: If6edc33a37e65a8494e66dc3b144138b1530367f
* Add read barriers to the weak roots in the intern table.Hiroshi Yamauchi2014-05-281-2/+2
| | | | | Bug: 12687968 Change-Id: I424f1df76a7e3d7154fb9f3c951c973d19bd640f
* Revert "Revert "Fix an outstanding compaction bug in interpreter.""Mathieu Chartier2014-05-231-1/+1
| | | | | | | | | | Fixed the generic trampoline to not use ToJObject when unnecessary. Bug: 15167269 This reverts commit 3bdb873122964da7937eb070cbcf2ef638a8e459. Change-Id: I0525d0e0f3afb753c770e1572070a0fa22b02271
* Merge "Revert "Fix an outstanding compaction bug in interpreter.""Mathieu Chartier2014-05-221-1/+1
|\
| * Revert "Fix an outstanding compaction bug in interpreter."Mathieu Chartier2014-05-221-1/+1
| | | | | | | | | | | | This reverts commit e09ae0920be57760fb390b6944bce420fa0b5582. Change-Id: I48036306130d5ccfec683d0dc3e9a642a02ee9c1
* | Merge "Fix an outstanding compaction bug in interpreter."Mathieu Chartier2014-05-221-1/+1
|\ \ | |/
| * Fix an outstanding compaction bug in interpreter.Mathieu Chartier2014-05-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Merge "Add a read barrier for weak roots in monitors."Hiroshi Yamauchi2014-05-221-2/+6
|\ \ | |/ |/|
| * Add a read barrier for weak roots in monitors.Hiroshi Yamauchi2014-05-211-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | A weak root requires a read barrier for the to-space invariant to hold because the object pointed to by a weak root can't be marked/forwarded like the one pointed to by a strong root (GC does not know if it's alive or not at that point) and because, without a read barrier, a mutator could access it and obtain a from-space reference, which would violate the to-space invariant. TODO: do similar for the other types of weak roots. Bug: 12687968 Change-Id: I563a0fa4f875e0c21ac96f57696959454e13b15a
* | Begin migration of art::Atomic to std::atomic.Ian Rogers2014-05-201-1/+1
|/ | | | Change-Id: I4858d9cbed95e5ca560956b9dabd976cebe68333
* Add Handle/HandleScope and delete SirtRef.Mathieu Chartier2014-05-131-2/+2
| | | | | | | | | | | | | | | | 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
* Force inlining on trivial accessors.Ian Rogers2014-04-291-6/+4
| | | | | | | | | Make volatility for GetFieldObject a template parameter. Move some trivial mirror::String routines to a -inl.h. Bug: 14285442 Change-Id: Ie23b11d4f18cb15a62c3bbb42837a8aaf6b68f92
* Comment disallow new monitors.Ian Rogers2014-04-171-0/+4
| | | | Change-Id: Ie50424c73be051f9856ef9e86bdbf83fa76bbc48
* Add monitor deflation.Mathieu Chartier2014-04-071-3/+5
| | | | | | | | | | | We now deflate the monitors when we perform a heap trim. This causes a pause but it shouldn't matter since we should be in a state where we don't care about pauses. Memory savings are hard to measure. Fixed integer overflow bug in GetEstimatedLastIterationThroughput. Bug: 13733906 Change-Id: I4e0e68add02e7f43370b3a5ea763d6fe8a5b212c
* Add more VerifyObject calls.Mathieu Chartier2014-03-071-0/+2
| | | | | | | | | | | 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
* Enable annotalysis on clang ART builds.Ian Rogers2014-03-061-3/+4
| | | | | | | | | | | Fix clang build errors aswell as restructure locking/mutex code for correct thread safety analysis support. Reorder make dependencies so that host builds build first as they should provide better compilation errors than target. Remove host's use of -fno-omit-frame-pointer as it has no value with correct use of CFI, which we should have. Change-Id: I72cea8da9a3757b1a0b3acb4081feccb7c6cef90
* Remove using mirror::* in jni internal.Mathieu Chartier2014-02-141-1/+1
| | | | | | | | | Cleans up the code since it helps make it easier to spot moving GC related bugs. Also fixed moving GC bugs in MonitorEnter, and FindFieldID. Change-Id: I794e4fbcc2010875fc6b299c6d4c9fb0f071b71a
* Add root types and thread id to root visiting.Mathieu Chartier2014-02-111-2/+3
| | | | | | | Enables us to pass the root type and thread id to hprof. Bug: 12680863 Change-Id: I6a0f1f9e3aa8f9b4033d695818ae7ca3460d67cb
* Object model changes to support 64bit.Ian Rogers2014-02-061-4/+13
| | | | | | | | | | | | | | | | | | | | | | | 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
* Tidy up memory barriers.Ian Rogers2013-12-201-1/+1
| | | | Change-Id: I937ea93e6df1835ecfe2d4bb7d84c24fe7fc097b
* Fix portable + mips build.Mathieu Chartier2013-11-121-0/+3
| | | | Change-Id: Ia200e582b04c84973281e12331777351feb8a401
* Compacting collector.Mathieu Chartier2013-11-111-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-6/+9
| | | | | | | | | | | | | | | 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
* Fix object identity hash.Mathieu Chartier2013-10-291-5/+16
| | | | | | | | | | | | | The object identity hash is now stored in the monitor word after being computed. Hashes are computed by a pseudo random number generator. When we write the image, we eagerly compute object hashes to prevent pages getting dirtied. Bug: 8981901 Change-Id: Ic8edacbacb0afc7055fd740a52444929f88ed564
* Notify doesn't inflate, rename helper.Ian Rogers2013-10-111-3/+3
| | | | Change-Id: I85c93b522478b3116a66630856a2370ec0fda490
* Inflate contended lock word by suspending owner.Ian Rogers2013-10-021-50/+56
| | | | | | | | | | | | | | | | | | | | Bug 6961405. Don't inflate monitors for Notify and NotifyAll. Tidy lock word, handle recursive lock case alongside unlocked case and move assembly out of line (except for ARM quick). Also handle null in out-of-line assembly as the test is quick and the enter/exit code is already a safepoint. To gain ownership of a monitor on behalf of another thread, monitor contenders must not hold the monitor_lock_, so they wait on a condition variable. Reduce size of per mutex contention log. Be consistent in calling thin lock thread ids just thread ids. Fix potential thread death races caused by the use of FindThreadByThreadId, make it invariant that returned threads are either self or suspended now. Code size reduction on ARM boot.oat 0.2%. Old nexus 7 speedup 0.25%, new nexus 7 speedup 1.4%, nexus 10 speedup 2.24%, nexus 4 speedup 2.09% on DeltaBlue. Change-Id: Id52558b914f160d9c8578fdd7fc8199a9598576a
* resolved conflicts for merge of bb0140e0 to dalvik-devMathieu Chartier2013-09-201-0/+4
|\ | | | | | | Change-Id: I31e0c05c5e917cf3275296a7f65bd8b78ec9b78b
| * Re-enable concurrent system weak sweeping.Mathieu Chartier2013-09-201-2/+4
| | | | | | | | | | | | | | | | | | | | | | Enabled by disallowing new system weaks during the pause and re-allowing it after the system weaks have been swept. Reduces GC pause by ~1ms. Fixes pause regression caused by fix for Bug: 10626133 Change-Id: If49d33e7ef19cb728ed3cef5187acfa53b9b05d8
* | Refactor system weak sweeping, add support for modification.Mathieu Chartier2013-09-171-3/+3
|/ | | | | | Required for moving collectors. Change-Id: Ib97ba4a05af1139f8d388077a15e62bcb9534855
* Don't scan image space when starting runtime.Ian Rogers2013-08-231-0/+3
| | | | | | | | | | | | | | | | | Bug 10432288. Find Classes and Strings from dex caches lazily rather than when the image is loaded. Make class status changes do notifies when there can be waiters. For Class lookup there's a pathology if we always search dex caches and so after 1000 failures move all classes into the class table. Be consistent in using "const char*" for class linker descriptors as this most easily agrees with the type in the dex file. Improve the intern run-test so that it has a case of a literal contained in the image. Modify image_test to allow any valid lock word rather than expecting 0, ideally we wouldn't see inflated monitors but we do due to NotifyAll (see bug 6961405). Change-Id: Ia9bfa748eeccb9b4498784b97c6823141b1f6db8
* Refactor java.lang.reflect implementationBrian Carlstrom2013-08-131-4/+4
| | | | | | | | | | | 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 runtime/explicit issuesBrian Carlstrom2013-07-171-1/+1
| | | | Change-Id: I352ba0b427f1ff9b22887693952b180eae0839ba
* 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/+211
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