Lines Matching defs:lock
37 * The two states of an Object's lock are referred to as "thin" and
38 * "fat". A lock may transition from the "thin" state to the "fat"
39 * state and this transition is referred to as inflation. Once a lock
42 * The lock value itself is stored in Object.lock. The LSB of the
43 * lock encodes its state. When cleared, the lock is in the "thin"
47 * lock count thread id hash state 0
49 * When set, the lock is in the "fat" state and its bits are formatted
73 Thread* owner; /* which thread currently owns the lock? */
74 int lockCount; /* owner's recursive lock depth */
79 pthread_mutex_t lock;
84 * Who last acquired this monitor, when lock sampling is enabled.
105 dvmInitMutex(&mon->lock);
144 * Returns the thread id of the thread owning the given lock.
149 u4 lock;
153 * Since we're reading the lock value multiple times, latch it so
156 lock = obj->lock;
157 if (LW_SHAPE(lock) == LW_SHAPE_THIN) {
158 return LW_LOCK_OWNER(lock);
160 owner = LW_MONITOR(lock)->owner;
166 * Get the thread that holds the lock on the specified object. The
169 * The caller must lock the thread list before calling here.
182 * objects's lock.
194 * Free the monitor associated with an object and make the object's lock
201 assert(LW_SHAPE(mon->obj->lock) == LW_SHAPE_FAT);
203 /* This lock is associated with an object
205 * anyone could be holding this lock would be
210 assert(pthread_mutex_trylock(&mon->lock) == 0);
211 assert(pthread_mutex_unlock(&mon->lock) == 0);
212 dvmDestroyMutex(&mon->lock);
318 /* Emit the lock owner source code file name, <= 37 bytes. */
341 * Lock a monitor.
353 if (dvmTryLockMutex(&mon->lock) != 0) {
363 dvmLockMutex(&mon->lock);
411 * Try to lock a monitor.
422 if (dvmTryLockMutex(&mon->lock) == 0) {
451 dvmUnlockMutex(&mon->lock);
492 * Links a thread into a monitor's wait set. The monitor lock must be
516 * Unlinks a thread from a monitor's wait set. The monitor lock must
627 /* Make sure that we hold the lock. */
655 * deep in a recursive lock, and we need to restore that later.
704 * Release the monitor lock and wait for a notification or
707 dvmUnlockMutex(&mon->lock);
729 /* Reacquire the monitor lock. */
773 /* Make sure that we hold the lock. */
805 /* Make sure that we hold the lock. */
827 * internal lock state. The calling thread must own the lock.
836 assert(LW_SHAPE(obj->lock) == LW_SHAPE_THIN);
837 assert(LW_LOCK_OWNER(obj->lock) == self->threadId);
841 /* Propagate the lock state. */
842 thin = obj->lock;
846 /* Publish the updated lock word. */
847 android_atomic_release_store(thin, (int32_t *)&obj->lock);
869 thinp = &obj->lock;
874 * The lock is a thin lock. The owner field is used to
879 * The calling thread owns the lock. Increment the
882 obj->lock += 1 << LW_LOCK_COUNT_SHIFT;
883 if (LW_LOCK_COUNT(obj->lock) == LW_LOCK_COUNT_MASK) {
886 * the lock so the next acquire will not overflow the
893 * The lock is unowned. Install the thread id of the
907 ALOGV("(%d) spin on lock %p: %#x (%#x) %#x",
908 threadId, &obj->lock, 0, *thinp, thin);
910 * The lock is owned by another thread. Notify the VM
915 * Spin until the thin lock is released or inflated.
921 * Check the shape of the lock word. Another thread
922 * may have inflated the lock while we were waiting.
927 * The lock has been released. Install the
936 * loop and proceed to inflate the lock.
942 * The lock has not been released. Yield so
965 * The thin lock was inflated by another thread.
969 ALOGV("(%d) lock %p surprise-fattened",
970 threadId, &obj->lock);
975 ALOGV("(%d) spin on lock done %p: %#x (%#x) %#x",
976 threadId, &obj->lock, 0, *thinp, thin);
978 * We have acquired the thin lock. Let the VM know that
983 * Fatten the lock.
986 ALOGV("(%d) lock %p fattened", threadId, &obj->lock);
990 * The lock is a fat lock.
992 assert(LW_MONITOR(obj->lock) != NULL);
993 lockMonitor(self, LW_MONITOR(obj->lock));
1010 * Cache the lock word as its value can change while we are
1013 thin = *(volatile u4 *)&obj->lock;
1016 * The lock is thin. We must ensure that the lock is owned
1021 * We are the lock owner. It is safe to update the lock
1022 * without CAS as lock ownership guards the lock itself.
1026 * The lock was not recursively acquired, the common
1031 android_atomic_release_store(thin, (int32_t*)&obj->lock);
1035 * lock recursion count field.
1037 obj->lock -= 1 << LW_LOCK_COUNT_SHIFT;
1041 * We do not own the lock. The JVM spec requires that we
1049 * The lock is fat. We must check to see if unlockMonitor has
1052 assert(LW_MONITOR(obj->lock) != NULL);
1053 if (!unlockMonitor(self, LW_MONITOR(obj->lock))) {
1070 u4 thin = *(volatile u4 *)&obj->lock;
1072 /* If the lock is still thin, we need to fatten it.
1075 /* Make sure that 'self' holds the lock.
1083 /* This thread holds the lock. We need to fatten the lock
1084 * so 'self' can block on it. Don't update the object lock
1085 * field yet, because 'self' needs to acquire the lock before
1089 ALOGV("(%d) lock %p fattened by wait()", self->threadId, &obj->lock);
1091 mon = LW_MONITOR(obj->lock);
1100 u4 thin = *(volatile u4 *)&obj->lock;
1102 /* If the lock is still thin, there aren't any waiters;
1103 * waiting on an object forces lock fattening.
1106 /* Make sure that 'self' holds the lock.
1117 /* It's a fat lock.
1128 u4 thin = *(volatile u4 *)&obj->lock;
1130 /* If the lock is still thin, there aren't any waiters;
1131 * waiting on an object forces lock fattening.
1134 /* Make sure that 'self' holds the lock.
1145 /* It's a fat lock.
1232 u4 lock, owner, hashState;
1240 lw = &obj->lock;
1272 * We already own the lock so we can update the hash state
1279 * We do not own the lock. Try acquiring the lock. Should
1284 * If the lock is thin assume it is unowned. We simulate
1287 lock = (LW_HASH_STATE_HASHED << LW_HASH_STATE_SHIFT);
1290 (int32_t)lock,
1301 * The monitor lock has been acquired. Change the
1311 * At this point we have failed to acquire the lock. We must
1316 * Cache the lock word as its value can change between
1319 lock = *lw;
1320 if (LW_SHAPE(lock) == LW_SHAPE_THIN) {
1324 owner = LW_LOCK_OWNER(lock);
1327 * If the lock has no owner do not bother scanning the
1338 thread = LW_MONITOR(lock)->owner;
1342 * thread list lock was acquired. Try again.