Lines Matching defs:self

41 #include "interp/Jit.h"         // need for self verification
77 Certain debugger events may inspire threads to self-suspend.
152 The thread must move to a non-blocked state (and self-suspend) after
169 operations and self-suspend. For this to work, the VM must:
245 static void waitForThreadSuspend(Thread* self, Thread* thread);
376 void dvmLockThreadList(Thread* self)
380 if (self == NULL) /* try to get it from TLS */
381 self = dvmThreadSelf();
383 if (self != NULL) {
384 oldStatus = self->status;
385 self->status = THREAD_VMWAIT;
393 if (self != NULL)
394 self->status = oldStatus;
457 Thread* self = dvmThreadSelf();
459 if (!dvmCheckSuspendPending(self)) {
481 self->threadId, who, getSuspendCauseStr(why));
493 self->threadId, who, getSuspendCauseStr(why));
534 Thread* self = dvmThreadSelf(); // may be null
539 dvmLockThreadList(self);
541 if (self != NULL)
542 threadId = self->threadId;
546 if (target == self) {
592 dvmLockThreadList(self);
604 if (target == self) {
658 Thread* self;
661 self = gDvm.threadList;
662 assert(self->threadId == kMainThreadId);
665 if (!createFakeEntryFrame(self))
669 dvmSetJniEnvThreadId(pEnv, self);
670 dvmSetThreadJNIEnv(self, (JNIEnv*) pEnv);
793 /* include self in non-daemon threads (mainly for AttachCurrentThread) */
909 * If we were called by dvmAttachCurrentThread, the self value is
1013 * Explore our sense of self. Stuffs the thread pointer into TLS.
1036 * pthread library when a thread is exiting and the "self" pointer in TLS
1058 Thread* self = (Thread*) arg;
1059 assert(self != NULL);
1062 self->threadId, arg, self->threadExitCheckCount);
1064 if (self->status == THREAD_ZOMBIE) {
1066 self->threadId);
1070 if (self->threadExitCheckCount < kMaxCount) {
1075 self->threadId, self->threadExitCheckCount);
1076 self->threadExitCheckCount++;
1077 int cc = pthread_setspecific(gDvm.pthreadKeySelf, self);
1080 self->threadId);
1085 self->threadId);
1237 Thread* self = dvmThreadSelf();
1277 dvmLockThreadList(self);
1304 ThreadStatus oldStatus = dvmChangeStatus(self, THREAD_VMWAIT);
1308 dvmChangeStatus(self, oldStatus);
1341 * So, we change our own status to VMWAIT, and self-suspend if
1361 * - put self into THREAD_VMWAIT so GC doesn't wait for us
1405 dvmLockThreadList(self);
1406 assert(self->status == THREAD_RUNNING);
1407 self->status = THREAD_VMWAIT;
1426 /* change status back to RUNNING, self-suspending if necessary */
1427 dvmChangeStatus(self, THREAD_RUNNING);
1440 dvmLockThreadList(self);
1462 Thread* self = (Thread*) arg;
1464 std::string threadName(dvmGetThreadName(self));
1470 dvmLockThreadList(self);
1471 prepareThread(self);
1473 LOG_THREAD("threadid=%d: created from interp", self->threadId);
1479 self->status = THREAD_STARTING;
1495 while (self->status != THREAD_VMWAIT)
1503 self->jniEnv = dvmCreateJNIEnv(self);
1509 dvmChangeStatus(self, THREAD_RUNNING);
1517 dvmDbgPostThreadStart(self);
1527 int priority = dvmGetFieldInt(self->threadObj,
1529 dvmChangeThreadPriority(self, priority);
1537 Method* run = self->threadObj->clazz->vtable[gDvm.voffJavaLangThread_run];
1540 ALOGV("threadid=%d: calling run()", self->threadId);
1542 dvmCallMethod(self, run, self->threadObj, &unused);
1543 ALOGV("threadid=%d: exiting", self->threadId);
1567 static void threadExitUncaughtException(Thread* self, Object* group)
1574 self->threadId, group);
1581 exception = dvmGetException(self);
1583 dvmAddTrackedAlloc(exception, self);
1584 dvmClearException(self);
1592 handlerObj = dvmGetFieldObject(self->threadObj,
1608 dvmCallMethod(self, uncaughtHandler, handlerObj, &unused,
1609 self->threadObj, exception);
1614 dvmSetException(self, exception);
1619 dvmClearException(self);
1621 dvmReleaseTrackedAlloc(exception, self);
1625 dvmAddToSuspendCounts(self, -self->suspendCount, 0);
1686 Thread* self = dvmThreadSelf();
1687 ThreadStatus oldStatus = dvmChangeStatus(self, THREAD_VMWAIT);
1688 dvmLockThreadList(self);
1697 dvmChangeStatus(self, oldStatus);
1705 dvmChangeStatus(self, oldStatus);
1777 Thread* self = NULL;
1784 /* allocate thread struct, and establish a basic sense of self */
1785 self = allocThread(gDvm.stackSize);
1786 if (self == NULL)
1788 setThreadSelf(self);
1795 dvmLockThreadList(self);
1796 ok = prepareThread(self);
1801 self->jniEnv = dvmCreateJNIEnv(self);
1802 if (self->jniEnv == NULL)
1811 if (!createFakeRunFrame(self))
1818 LOG_THREAD("threadid=%d: adding to list (attached)", self->threadId);
1820 dvmLockThreadList(self);
1822 self->next = gDvm.threadList->next;
1823 if (self->next != NULL)
1824 self->next->prev = self;
1825 self->prev = gDvm.threadList;
1826 gDvm.threadList->next = self;
1846 assert(self->status == THREAD_INITIALIZING);
1847 dvmChangeStatus(self, THREAD_VMWAIT);
1850 dvmChangeStatus(self, THREAD_RUNNING);
1864 self->threadObj = threadObj;
1865 dvmSetFieldInt(vmThreadObj, gDvm.offJavaLangVMThread_vmData, (u4)self);
1881 assert(dvmCheckException(self));
1897 dvmCallMethod(self, init, threadObj, &unused, (Object*)pArgs->group,
1899 if (dvmCheckException(self)) {
1941 dvmReleaseTrackedAlloc(threadObj, self);
1942 dvmReleaseTrackedAlloc(vmThreadObj, self);
1943 dvmReleaseTrackedAlloc((Object*)threadNameStr, self);
1946 self->threadId, pArgs->name);
1950 dvmDbgPostThreadStart(self);
1955 dvmLockThreadList(self);
1956 unlinkThread(self);
1962 dvmReleaseTrackedAlloc(threadObj, self);
1963 dvmReleaseTrackedAlloc(vmThreadObj, self);
1964 dvmReleaseTrackedAlloc((Object*)threadNameStr, self);
1965 if (self != NULL) {
1966 if (self->jniEnv != NULL) {
1967 dvmDestroyJNIEnv(self->jniEnv);
1968 self->jniEnv = NULL;
1970 freeThread(self);
2001 Thread* self = dvmThreadSelf();
2013 int curDepth = dvmComputeExactFrameDepth(self->interpSave.curFrame);
2019 assert(!dvmIsBreakFrame((u4*)self->interpSave.curFrame));
2020 StackSaveArea* ssa = SAVEAREA_FROM_FP(self->interpSave.curFrame);
2028 dvmDumpThread(self, false);
2033 group = dvmGetFieldObject(self->threadObj, gDvm.offJavaLangThread_group);
2034 LOG_THREAD("threadid=%d: detach (group=%p)", self->threadId, group);
2041 dvmReleaseJniMonitors(self);
2046 if (dvmCheckException(self))
2047 threadExitUncaughtException(self, group);
2056 dvmCallMethod(self, removeThread, group, &unused, self->threadObj);
2065 vmThread = dvmGetFieldObject(self->threadObj,
2067 dvmAddTrackedAlloc(vmThread, self);
2068 dvmSetFieldObject(self->threadObj, gDvm.offJavaLangThread_vmThread, NULL);
2082 dvmDbgPostThreadDeath(self);
2088 dvmLockObject(self, vmThread);
2089 dvmObjectNotifyAll(self, vmThread);
2090 dvmUnlockObject(self, vmThread);
2092 dvmReleaseTrackedAlloc(vmThread, self);
2100 volatile void* raw = reinterpret_cast<volatile void*>(&self->status);
2111 * could get wedged. Since self->threadObj is still valid, the Thread
2121 self->threadId);
2129 dvmLockThreadList(self);
2134 dvmDestroyJNIEnv(self->jniEnv);
2135 self->jniEnv = NULL;
2137 self->status = THREAD_ZOMBIE;
2142 unlinkThread(self);
2148 if (!dvmGetFieldBoolean(self->threadObj, gDvm.offJavaLangThread_daemon)) {
2152 ALOGV("threadid=%d: last non-daemon thread", self->threadId);
2163 ALOGV("threadid=%d: bye!", self->threadId);
2164 releaseThreadId(self);
2169 freeThread(self);
2240 Thread* self = dvmThreadSelf();
2244 if (self->handle == dvmJdwpGetDebugThread(gDvm.jdwpState)) {
2255 dvmAddToSuspendCounts(self, 1, 1);
2260 assert(self->suspendCount > 0);
2261 self->status = THREAD_SUSPENDED;
2262 LOG_THREAD("threadid=%d: self-suspending (dbg)", self->threadId);
2273 // self->threadId, (int) self->handle);
2277 while (self->suspendCount != 0) {
2280 if (self->suspendCount != 0) {
2288 self->threadId, self->suspendCount, self->dbgSuspendCount);
2291 assert(self->suspendCount == 0 && self->dbgSuspendCount == 0);
2292 self->status = THREAD_RUNNING;
2293 LOG_THREAD("threadid=%d: self-reviving (dbg), status=%d",
2294 self->threadId, self->status);
2427 static void waitForThreadSuspend(Thread* self, Thread* thread)
2480 self->threadId, retryCount,
2499 self->threadId, thread->threadId);
2511 self->threadId,
2537 * we might have to self-suspend if somebody else beats us here.
2545 Thread* self = dvmThreadSelf();
2553 * resume, so lockThreadSuspend() will cause us to self-suspend.
2559 LOG_THREAD("threadid=%d: SuspendAll starting", self->threadId);
2567 //assert(self->suspendCount == 0);
2572 dvmLockThreadList(self);
2576 if (thread == self)
2602 * self-suspending for the debugger) it won't block while we're waiting
2606 if (thread == self)
2615 waitForThreadSuspend(self, thread);
2618 self->threadId, thread->threadId, thread->status,
2625 LOG_THREAD("threadid=%d: SuspendAll complete", self->threadId);
2635 Thread* self = dvmThreadSelf();
2639 LOG_THREAD("threadid=%d: ResumeAll starting", self->threadId);
2646 dvmLockThreadList(self);
2649 if (thread == self)
2706 LOG_THREAD("threadid=%d: ResumeAll waking others", self->threadId);
2721 LOG_THREAD("threadid=%d: ResumeAll complete", self->threadId);
2730 Thread* self = dvmThreadSelf();
2734 LOG_THREAD("threadid=%d: UndoDebuggerSusp starting", self->threadId);
2741 dvmLockThreadList(self);
2744 if (thread == self)
2774 LOG_THREAD("threadid=%d: UndoDebuggerSusp complete", self->threadId);
2808 * Wait until another thread self-suspends. This is specifically for
2824 Thread* self = dvmThreadSelf();
2827 self->threadId, thread->threadId);
2830 assert(thread != self);
2831 assert(self->status != THREAD_RUNNING);
2833 waitForThreadSuspend(self, thread);
2836 self->threadId, thread->threadId);
2845 static bool fullSuspendCheck(Thread* self)
2847 assert(self != NULL);
2848 assert(self->suspendCount >= 0);
2852 * access to self->suspendCount.
2856 bool needSuspend = (self->suspendCount != 0);
2858 LOG_THREAD("threadid=%d: self-suspending", self->threadId);
2859 ThreadStatus oldStatus = self->status; /* should be RUNNING */
2860 self->status = THREAD_SUSPENDED;
2863 while (self->suspendCount != 0) {
2873 assert(self->suspendCount == 0 && self->dbgSuspendCount == 0);
2874 self->status = oldStatus;
2875 LOG_THREAD("threadid=%d: self-reviving, status=%d",
2876 self->threadId, self->status);
2888 bool dvmCheckSuspendPending(Thread* self)
2890 assert(self != NULL);
2891 if (self->suspendCount == 0) {
2894 return fullSuspendCheck(self);
2901 * The "self" argument, which may be NULL, is accepted as an optimization.
2905 ThreadStatus dvmChangeStatus(Thread* self, ThreadStatus newStatus)
2909 if (self == NULL)
2910 self = dvmThreadSelf();
2913 self->threadId, self->status, newStatus);
2915 oldStatus = self->status;
2970 volatile void* raw = reinterpret_cast<volatile void*>(&self->status);
2973 if (self->suspendCount != 0) {
2974 fullSuspendCheck(self);
2985 volatile void* raw = reinterpret_cast<volatile void*>(&self->status);
3226 /* get some bits from /proc/self/stat */
3235 snprintf(schedstatBuf, sizeof(schedstatBuf), "/proc/self/task/%d/schedstat", tid);
3312 * Works best when the thread in question is "self" or has been suspended.
3377 " | group=\"%s\" sCount=%d dsCount=%d obj=%p self=%p\n",
3518 DIR* d = opendir("/proc/self/task");