History log of /art/runtime/base/mutex.h
Revision Date Author Comments
a98ffd745bbecb2e84a492194950c0b94966546b 26-Sep-2014 Mathieu Chartier <mathieuc@google.com> Fix broken runtime SetStatsEnabled logic

Previously, Runtime::SetStatsEnabled wouldn't take stats_enabled_
into account when deciding whether or not to increment / decrement
teh stats enabled counter. This resulted in counter underflows and
other errors which caused some CTS tests to fail.

Also added some locking to prevent race conditions.

Bug: 17360878

Change-Id: I779237d55dda4f35054a4d27fb2c660a38750fc0
1d6ee090fddd4bfd35c304d6ceb929d5c529dfcc 16-Sep-2014 Jeff Hao <jeffhao@google.com> Avoid suspending for alloc trace enabling when already suspended.

Bug: 17499772
Change-Id: Id98c10967b28e8859e5ac46f5878c304fb85c498
3256166df40981f1f1997a5f00303712277c963f 12-Sep-2014 Mathieu Chartier <mathieuc@google.com> Add native support for FinalizerList.makeCircularListIfUnenqueued

Called from FinalizerReference.enqueueSentinelReference to prevent
a race where the GC updates pendingNext of the sentinel reference
before enqueueSentinelReference.

Bug: 17462553

Change-Id: I7ad2fd250c2715d1aeb919bd548ef9aab24f30a2
f4cb036808b88fe60d71a705b2744284155cbc01 05-Sep-2014 Brian Carlstrom <bdc@google.com> Fix numerous issues with DdmVmInternal allocation tracking

Issues addressed:
- Using without JDWP attached caused native crash.
- When buffer is full (64k entries), number of entries reported was 0.
- Disabling tracking after disabling tracking caused native crash.
- Asking for allocations after disabled caused native crash.
- Lock ordering issues between mutator lock and alloc tracker lock.

Adding 098-ddmc test to cover these cases.

Bug: 17392248
Change-Id: I45c0abbfb3dd7a7421aea3bbba2ea8d05225e48b
59d9d668d4f4286813afe2b4e7c6db839222ce96 19-Aug-2014 Sebastien Hertz <shertz@google.com> Reduce lock contention when debugging

Uses a ReaderWriterMutex for the breakpoint lock to reduce contention during
debugging session.

Also adds missing thread safety annotations on fields and methods related to
instrumentation and debugging.

Bug: 16814665
Bug: 11667502
Change-Id: I056cdafa91109e0c83806c8d8df75c37ade0a354
6b932180c768d2150386e4e6c8e415d935b25471 07-Aug-2014 Vladimir Marko <vmarko@google.com> Fix performance regression in OatFile::GetOatDexFile().

Try to avoid calculating the canonical location of the
dex file if possible and when we have to calculate it,
cache the lookup result for subsequent lookups.

Bug: 16828525
Bug: 16859671

(cherry picked from commit 3f5838d7d0b9fc63db0ccc35c2ea05ed29264986)

Change-Id: Ifd9a45dada2cc724382fd03c10f6437a6b71e666
4bb932773e47b1ce04602d81ffa5a8a7d863eb10 07-Aug-2014 Vladimir Marko <vmarko@google.com> Fix performance regression in OatFile::GetOatDexFile().

Try to avoid calculating the canonical location of the
dex file if possible and when we have to calculate it,
cache the lookup result for subsequent lookups.

Bug: 16828525
Bug: 16859671

(cherry picked from commit 3f5838d7d0b9fc63db0ccc35c2ea05ed29264986)

Change-Id: Ifd9a45dada2cc724382fd03c10f6437a6b71e666
59952167697d3b7e6655cb76d087a809c4f615d8 18-Jul-2014 Ian Rogers <irogers@google.com> Avoid race in single thread suspension.

Don't allow more than one concurrent single thread suspension to avoid
potential cycles and deadlocks where threads try to suspend each other.
Bug: 16364458, 16354227

(cherry picked from commit f3d874c60ee3ada19ce26a5c4e532312b6f3a9e9)

Change-Id: I907f1d5591a6aa5c241d37d6b4a34f968f98df77
f3d874c60ee3ada19ce26a5c4e532312b6f3a9e9 18-Jul-2014 Ian Rogers <irogers@google.com> Avoid race in single thread suspension.

Don't allow more than one concurrent single thread suspension to avoid
potential cycles and deadlocks where threads try to suspend each other.
Bug: 16364458, 16354227

Change-Id: I907f1d5591a6aa5c241d37d6b4a34f968f98df77
37f3c968ecd04e77802fe17bb82dabc07de21ca1 17-Jul-2014 Ian Rogers <irogers@google.com> Avoid direct use of QuasiAtomic by using Atomic.

Change-Id: I92d0f822cddb2085de7cbb4c44c3a429081892a2
6093a5c277e54bcd949dd6fac7b3856e5f371d06 18-Jul-2014 Ian Rogers <irogers@google.com> Avoid race in single thread suspension.

Don't allow more than one concurrent single thread suspension to avoid
potential cycles and deadlocks where threads try to suspend each other.
Bug: 16364458, 16354227

(cherry picked from commit f3d874c60ee3ada19ce26a5c4e532312b6f3a9e9)

Change-Id: I907f1d5591a6aa5c241d37d6b4a34f968f98df77
c7190697f8665e706f6ebb4ae36fa63c46a32cd5 09-Jul-2014 Ian Rogers <irogers@google.com> Remove legacy CAS implementations from mutex.

Removes the use of __sync_bool_compare_and_swap and android_atomic_cas and uses
intention revealing atomic operations from art::Atomic (which will eventually
give way to std::atomic).

Change-Id: Iea44e1923f6706ec04b5459fe25427282c189a7e
74240819ae09e29b2753ef38f4eb4be1c2762e2e 17-Apr-2014 Andreas Gampe <agampe@google.com> Use memory chunks for monitors on LP64

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
7de77dd4f2d3cbb0615ee001589eb99ae82c3dcc 14-Jun-2014 Raghu Gandham <raghu.gandham@imgtec.com> Assign a lower Locklevel for Mutexes used in QuasiAtomic operations.
This fixes the CompilerDriverTest on MIPS. The test was failing when
Transaction::Abort() acquired intern_table_lock_ and log_lock_
and subsequently performed QuasiAtomic operations.

Change-Id: I9fcda51221f1f298bcb5dd0e10019bd2034ab8ae
c5f17732d8144491c642776b6b48c85dfadf4b52 06-Jun-2014 Ian Rogers <irogers@google.com> Remove deprecated WITH_HOST_DALVIK.

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
3eed93dd5be03e5539827bebf0f414251a12e15e 04-Jun-2014 Hiroshi Yamauchi <yamauchi@google.com> Verify there's no mem map gap for immune region not to break.

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
ffddfdf6fec0b9d98a692e27242eecb15af5ead2 03-Jun-2014 Tim Murray <timmurray@google.com> DO NOT MERGE

Merge ART from AOSP to lmp-preview-dev.

Change-Id: I0f578733a4b8756fd780d4a052ad69b746f687a9
9e36931cc79ca665908db9575126881d1cfdea5a 21-May-2014 Chao-ying Fu <chao-ying.fu@intel.com> Move modify_ldt_lock into global lock order.

Mutex modify_ldt_lock was being removed during runtime shutdown while
daemons thread may still detach. Avoid this by placing in global lock
order.
This fixes cts dalvik vm-tests-tf that hang on some x86 devices.

By irogers: also, tidy global locks to agree with enum constants and
add extra verification that the global annotalysis order agrees with
the LockLevel order. Bumped the oat version and moved the locks as
LockLevel additions previously caused entrypoints to be moved. Make
unattached lock not handle the default mutex level case by moving the
allocated thread ids lock into the global order.

Change-Id: I9d03f19d44ea254accf0ceae8022563c77f7a02f
Signed-off-by: Chao-ying Fu <chao-ying.fu@intel.com>
3e5cf305db800b2989ad57b7cde8fb3cc9fa1b9e 21-May-2014 Ian Rogers <irogers@google.com> Begin migration of art::Atomic to std::atomic.

Change-Id: I4858d9cbed95e5ca560956b9dabd976cebe68333
2d1ab0a7bf7639d1af0c453415f9625110c34f6d 09-May-2014 Mathieu Chartier <mathieuc@google.com> Use WaitHoldingLocks in ReferenceProcessor::GetReferent.

The caller may be holding other locks, so we must use this or else
we get bad mutexes held errors. Also added a lock level for the
reference processor.

Change-Id: I364a303a4106982bd9bfaac5b116cea1638ea6d3
440e4ceb310349ee8eb569495bc04d3d7fbe71cb 01-Apr-2014 Mathieu Chartier <mathieuc@google.com> Add monitor deflation.

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
4d25df3f76f864b7629ac8c0046d46997f293d8d 21-Mar-2014 Sebastien Hertz <shertz@google.com> Refactor deoptimization support in debugger

This CL prepares breakpoint support for inlined methods where we'll have to
deoptimize everything.

We move deoptimization-related information to Dbg class only (deoptimization
request queue, full deoptimization event count and deoptimization lock). We
replace MethodInstrumentionRequest by DeoptimizationRequest. This is used to
know which kind of deoptimization is required for a particular event.

It also simplifies lock ordering a bit during event setup: we no longer need to
hold the deoptimization lock while holding the breakpoint lock. Moreover, the
deoptimization lock should be held only after the event list lock.

Bug: 12187616
Change-Id: Iff13f004adaeb25e5d609238bacce0b9720510e6
719d1a33f6569864f529e5a3fff59e7bca97aad0 06-Mar-2014 Ian Rogers <irogers@google.com> Enable annotalysis on clang ART builds.

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
ef7d42fca18c16fbaf103822ad16f23246e2905d 06-Jan-2014 Ian Rogers <irogers@google.com> Object model changes to support 64bit.

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
b122a4bbed34ab22b4c1541ee25e5cf22f12a926 20-Nov-2013 Ian Rogers <irogers@google.com> Tidy up memory barriers.

Change-Id: I937ea93e6df1835ecfe2d4bb7d84c24fe7fc097b
c01417898a6e4f8a5663d6c0556982488c133cdf 15-Nov-2013 Chris Dearman <chris.dearman@imgtec.com> [MIPS] Enable futex support

Change-Id: I4095d889229fe1b96f7b276d7952b3578c8fcd6d
46bc778f1feed02b20d25e3d03470c93ca2c0506 13-Nov-2013 Mathieu Chartier <mathieuc@google.com> Fix portable + mips build.

Change-Id: Ia200e582b04c84973281e12331777351feb8a401
590fee9e8972f872301c2d16a575d579ee564bee 13-Sep-2013 Mathieu Chartier <mathieuc@google.com> Compacting collector.

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
d9c4fc94fa618617f94e1de9af5f034549100753 02-Oct-2013 Ian Rogers <irogers@google.com> Inflate contended lock word by suspending owner.

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
08f2e7b59fab9df108d3d91e6eeb4bbccbb325d1 10-Sep-2013 Jeff Hao <jeffhao@google.com> Disable lock contention logging by default.

The verifier runs out of memory with lock contention logging on nakasi.

Bug: 10646091
Change-Id: I8ddffdb48d779a20107bae7013cbe92d13dc8bdb
4aa48fccbd3782d78207a79541b61948a066b8fc 20-Aug-2013 Ian Rogers <irogers@google.com> Enable contention logging by default.

Change-Id: I86314b2dabed81e6fbdeb0ab451ba8176407873e
2e250c826b3c405d675017efe79e5db3651c9ee6 15-Aug-2013 Brian Carlstrom <bdc@google.com> Revert "Always enable lock level checks."

This reverts commit ccf124800fe025be3ca05c28a60514909ca66a11.
00ae676e307c8e3c3b19852f41ad0547c4c523b8 05-Aug-2013 Sebastien Hertz <shertz@google.com> Fix typo in mutex.h file.

Change-Id: I11db56161025285022ea1137fb7749751d14b347
(cherry picked from commit 702a85b33c57da99e83698129a289687cdb0be1f)
1afde13b36cc1d67528104c2b1395495f669cd3f 07-Aug-2013 Hiroshi Yamauchi <yamauchi@google.com> Polish the lock contention logging.

- Make the code compilable.
- Surround the code with kLogLockContentions instead of #ifdef CONTENTION_LOGGING.
- Dump contended locks before never-contended locks for better log readability.
- Change the wait time unit from ms to us for better precision.

Bug: 9986464
Change-Id: I121c6ccf4424d3e0339b0dcd25e18976b41fe4f3
b0f871965d588cce066785728fb105248b38bb4a 08-Aug-2013 Dragos Sbirlea <dragoss@google.com> Removed unused friend classes for tests.

Change-Id: I7f08b0cd4abbbc82f329a8bec0d0994327b6dba9
702a85b33c57da99e83698129a289687cdb0be1f 05-Aug-2013 Sebastien Hertz <shertz@google.com> Fix typo in mutex.h file.

Change-Id: I11db56161025285022ea1137fb7749751d14b347
834b394ee759ed31c5371d8093d7cd8cd90014a8 31-Jul-2013 Brian Carlstrom <bdc@google.com> Merge remote-tracking branch 'goog/dalvik-dev' into merge-art-to-dalvik-dev

Change-Id: I323e9e8c29c3e39d50d9aba93121b26266c52a46
23d5cffcb8e32aaa6ce0895ade28849f72d90463 10-Jul-2013 Brian Carlstrom <bdc@google.com> Revert "Always enable lock level checks." DO NOT MERGE

This reverts commit ccf124800fe025be3ca05c28a60514909ca66a11.

(cherry picked from commit 27c590edf6c24107b6473e84e526c432bd081f6e)

Change-Id: Id3f58a0e92bb7719d6099c7b288b8a33c2456c40
fc0e3219edc9a5bf81b166e82fd5db2796eb6a0d 17-Jul-2013 Brian Carlstrom <bdc@google.com> Fix multiple inclusion guards to match new pathnames

Change-Id: Id7735be1d75bc315733b1773fba45c1deb8ace43
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