Lines Matching refs: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.
109 dvmInitMutex(&mon->lock);
148 * Returns the thread id of the thread owning the given lock.
153 u4 lock;
157 * Since we're reading the lock value multiple times, latch it so
160 lock = obj->lock;
161 if (LW_SHAPE(lock) == LW_SHAPE_THIN) {
162 return LW_LOCK_OWNER(lock);
164 owner = LW_MONITOR(lock)->owner;
170 * Get the thread that holds the lock on the specified object. The
173 * The caller must lock the thread list before calling here.
186 * objects's lock.
198 * Free the monitor associated with an object and make the object's lock
205 assert(LW_SHAPE(mon->obj->lock) == LW_SHAPE_FAT);
207 /* This lock is associated with an object
209 * anyone could be holding this lock would be
214 assert(pthread_mutex_trylock(&mon->lock) == 0);
215 assert(pthread_mutex_unlock(&mon->lock) == 0);
216 dvmDestroyMutex(&mon->lock);
317 /* Emit the lock owner source code file name, <= 37 bytes. */
352 if (dvmTryLockMutex(&mon->lock) != 0) {
362 dvmLockMutex(&mon->lock);
410 * Try to lock a monitor.
421 if (dvmTryLockMutex(&mon->lock) == 0) {
450 dvmUnlockMutex(&mon->lock);
491 * Links a thread into a monitor's wait set. The monitor lock must be
515 * Unlinks a thread from a monitor's wait set. The monitor lock must
626 /* Make sure that we hold the lock. */
654 * deep in a recursive lock, and we need to restore that later.
703 * Release the monitor lock and wait for a notification or
706 dvmUnlockMutex(&mon->lock);
728 /* Reacquire the monitor lock. */
772 /* Make sure that we hold the lock. */
804 /* Make sure that we hold the lock. */
826 * internal lock state. The calling thread must own the lock.
835 assert(LW_SHAPE(obj->lock) == LW_SHAPE_THIN);
836 assert(LW_LOCK_OWNER(obj->lock) == self->threadId);
840 /* Propagate the lock state. */
841 thin = obj->lock;
845 /* Publish the updated lock word. */
846 android_atomic_release_store(thin, (int32_t *)&obj->lock);
868 thinp = &obj->lock;
873 * The lock is a thin lock. The owner field is used to
878 * The calling thread owns the lock. Increment the
881 obj->lock += 1 << LW_LOCK_COUNT_SHIFT;
882 if (LW_LOCK_COUNT(obj->lock) == LW_LOCK_COUNT_MASK) {
885 * the lock so the next acquire will not overflow the
892 * The lock is unowned. Install the thread id of the
906 ALOGV("(%d) spin on lock %p: %#x (%#x) %#x",
907 threadId, &obj->lock, 0, *thinp, thin);
909 * The lock is owned by another thread. Notify the VM
914 * Spin until the thin lock is released or inflated.
920 * Check the shape of the lock word. Another thread
921 * may have inflated the lock while we were waiting.
926 * The lock has been released. Install the
935 * loop and proceed to inflate the lock.
941 * The lock has not been released. Yield so
964 * The thin lock was inflated by another thread.
968 ALOGV("(%d) lock %p surprise-fattened",
969 threadId, &obj->lock);
974 ALOGV("(%d) spin on lock done %p: %#x (%#x) %#x",
975 threadId, &obj->lock, 0, *thinp, thin);
977 * We have acquired the thin lock. Let the VM know that
982 * Fatten the lock.
985 ALOGV("(%d) lock %p fattened", threadId, &obj->lock);
989 * The lock is a fat lock.
991 assert(LW_MONITOR(obj->lock) != NULL);
992 lockMonitor(self, LW_MONITOR(obj->lock));
1009 * Cache the lock word as its value can change while we are
1012 thin = *(volatile u4 *)&obj->lock;
1015 * The lock is thin. We must ensure that the lock is owned
1020 * We are the lock owner. It is safe to update the lock
1021 * without CAS as lock ownership guards the lock itself.
1025 * The lock was not recursively acquired, the common
1030 android_atomic_release_store(thin, (int32_t*)&obj->lock);
1034 * lock recursion count field.
1036 obj->lock -= 1 << LW_LOCK_COUNT_SHIFT;
1040 * We do not own the lock. The JVM spec requires that we
1048 * The lock is fat. We must check to see if unlockMonitor has
1051 assert(LW_MONITOR(obj->lock) != NULL);
1052 if (!unlockMonitor(self, LW_MONITOR(obj->lock))) {
1069 u4 thin = *(volatile u4 *)&obj->lock;
1071 /* If the lock is still thin, we need to fatten it.
1074 /* Make sure that 'self' holds the lock.
1082 /* This thread holds the lock. We need to fatten the lock
1083 * so 'self' can block on it. Don't update the object lock
1084 * field yet, because 'self' needs to acquire the lock before
1088 ALOGV("(%d) lock %p fattened by wait()", self->threadId, &obj->lock);
1090 mon = LW_MONITOR(obj->lock);
1099 u4 thin = *(volatile u4 *)&obj->lock;
1101 /* If the lock is still thin, there aren't any waiters;
1102 * waiting on an object forces lock fattening.
1105 /* Make sure that 'self' holds the lock.
1116 /* It's a fat lock.
1127 u4 thin = *(volatile u4 *)&obj->lock;
1129 /* If the lock is still thin, there aren't any waiters;
1130 * waiting on an object forces lock fattening.
1133 /* Make sure that 'self' holds the lock.
1144 /* It's a fat lock.
1231 u4 lock, owner, hashState;
1239 lw = &obj->lock;
1271 * We already own the lock so we can update the hash state
1278 * We do not own the lock. Try acquiring the lock. Should
1283 * If the lock is thin assume it is unowned. We simulate
1286 lock = (LW_HASH_STATE_HASHED << LW_HASH_STATE_SHIFT);
1289 (int32_t)lock,
1300 * The monitor lock has been acquired. Change the
1310 * At this point we have failed to acquire the lock. We must
1315 * Cache the lock word as its value can change between
1318 lock = *lw;
1319 if (LW_SHAPE(lock) == LW_SHAPE_THIN) {
1323 owner = LW_LOCK_OWNER(lock);
1326 * If the lock has no owner do not bother scanning the
1337 thread = LW_MONITOR(lock)->owner;
1341 * thread list lock was acquired. Try again.