• Home
  • Raw
  • Download

Lines Matching refs:thread

234 static bool prepareThread(Thread* thread);
235 static void setThreadSelf(Thread* thread);
236 static void unlinkThread(Thread* thread);
237 static void freeThread(Thread* thread);
238 static void assignThreadId(Thread* thread);
239 static bool createFakeEntryFrame(Thread* thread);
240 static bool createFakeRunFrame(Thread* thread);
243 static void threadExitUncaughtException(Thread* thread, Object* group);
245 static void waitForThreadSuspend(Thread* self, Thread* thread);
254 Thread* thread; in dvmThreadStartup() local
285 thread = allocThread(gDvm.mainThreadStackSize); in dvmThreadStartup()
286 if (thread == NULL) in dvmThreadStartup()
290 thread->status = THREAD_RUNNING; in dvmThreadStartup()
296 prepareThread(thread); in dvmThreadStartup()
297 gDvm.threadList = thread; in dvmThreadStartup()
683 Thread* thread; in dvmPrepMainThread() local
694 thread = gDvm.threadList; in dvmPrepMainThread()
695 assert(thread->threadId == kMainThreadId); in dvmPrepMainThread()
736 dvmCallMethod(thread, init, threadObj, &unused, groupObj, threadNameStr, in dvmPrepMainThread()
738 if (dvmCheckException(thread)) { in dvmPrepMainThread()
755 dvmCallMethod(thread, init, vmThreadObj, &unused, threadObj); in dvmPrepMainThread()
756 if (dvmCheckException(thread)) { in dvmPrepMainThread()
763 dvmSetFieldInt(vmThreadObj, gDvm.offJavaLangVMThread_vmData, (u4)thread); in dvmPrepMainThread()
773 thread->threadObj = threadObj; in dvmPrepMainThread()
807 Thread* thread; in allocThread() local
810 thread = (Thread*) calloc(1, sizeof(Thread)); in allocThread()
811 if (thread == NULL) in allocThread()
815 assert((((uintptr_t)&thread->interpBreak.all) & 0x7) == 0); in allocThread()
816 assert(sizeof(thread->interpBreak) == sizeof(thread->interpBreak.all)); in allocThread()
820 if (dvmSelfVerificationShadowSpaceAlloc(thread) == NULL) in allocThread()
826 thread->status = THREAD_INITIALIZING; in allocThread()
839 dvmSelfVerificationShadowSpaceFree(thread); in allocThread()
841 free(thread); in allocThread()
850 dvmSelfVerificationShadowSpaceFree(thread); in allocThread()
852 free(thread); in allocThread()
858 thread->interpStackSize = interpStackSize; in allocThread()
859 thread->interpStackStart = stackBottom + interpStackSize; in allocThread()
860 thread->interpStackEnd = stackBottom + STACK_OVERFLOW_RESERVE; in allocThread()
863 thread->mainHandlerTable = dvmAsmInstructionStart; in allocThread()
864 thread->altHandlerTable = dvmAsmAltInstructionStart; in allocThread()
865 thread->interpBreak.ctl.curHandlerTable = thread->mainHandlerTable; in allocThread()
869 dvmInitInterpStack(thread, interpStackSize); in allocThread()
872 dvmInitInterpreterState(thread); in allocThread()
874 return thread; in allocThread()
900 static bool prepareThread(Thread* thread) in prepareThread() argument
902 assignThreadId(thread); in prepareThread()
903 thread->handle = pthread_self(); in prepareThread()
904 thread->systemTid = dvmGetSysThreadId(); in prepareThread()
912 setThreadSelf(thread); in prepareThread()
915 thread->threadId, thread->interpStackStart - thread->interpStackSize); in prepareThread()
920 dvmInitMutex(&thread->invokeReq.lock); in prepareThread()
921 pthread_cond_init(&thread->invokeReq.cv, NULL); in prepareThread()
929 if (!thread->jniLocalRefTable.init(kJniLocalRefMin, in prepareThread()
933 if (!dvmInitReferenceTable(&thread->internalLocalRefTable, in prepareThread()
937 memset(&thread->jniMonitorRefTable, 0, sizeof(thread->jniMonitorRefTable)); in prepareThread()
939 pthread_cond_init(&thread->waitCond, NULL); in prepareThread()
940 dvmInitMutex(&thread->waitMutex); in prepareThread()
943 dvmInitMutex(&thread->callbackMutex); in prepareThread()
953 static void unlinkThread(Thread* thread) in unlinkThread() argument
955 LOG_THREAD("threadid=%d: removing from list", thread->threadId); in unlinkThread()
956 if (thread == gDvm.threadList) { in unlinkThread()
957 assert(thread->prev == NULL); in unlinkThread()
958 gDvm.threadList = thread->next; in unlinkThread()
960 assert(thread->prev != NULL); in unlinkThread()
961 thread->prev->next = thread->next; in unlinkThread()
963 if (thread->next != NULL) in unlinkThread()
964 thread->next->prev = thread->prev; in unlinkThread()
965 thread->prev = thread->next = NULL; in unlinkThread()
971 static void freeThread(Thread* thread) in freeThread() argument
973 if (thread == NULL) in freeThread()
977 LOGVV("threadid=%d: freeing", thread->threadId); in freeThread()
979 if (thread->interpStackStart != NULL) { in freeThread()
982 interpStackBottom = thread->interpStackStart; in freeThread()
983 interpStackBottom -= thread->interpStackSize; in freeThread()
987 if (munmap(interpStackBottom, thread->interpStackSize) != 0) in freeThread()
992 thread->jniLocalRefTable.destroy(); in freeThread()
993 dvmClearReferenceTable(&thread->internalLocalRefTable); in freeThread()
994 if (&thread->jniMonitorRefTable.table != NULL) in freeThread()
995 dvmClearReferenceTable(&thread->jniMonitorRefTable); in freeThread()
998 dvmSelfVerificationShadowSpaceFree(thread); in freeThread()
1000 free(thread->stackTraceSample); in freeThread()
1001 free(thread); in freeThread()
1015 static void setThreadSelf(Thread* thread) in setThreadSelf() argument
1019 cc = pthread_setspecific(gDvm.pthreadKeySelf, thread); in setThreadSelf()
1027 if (thread != NULL) { in setThreadSelf()
1028 ALOGE("pthread_setspecific(%p) failed, err=%d", thread, cc); in setThreadSelf()
1099 static void assignThreadId(Thread* thread) in assignThreadId() argument
1112 thread->threadId = num + 1; in assignThreadId()
1114 assert(thread->threadId != 0); in assignThreadId()
1120 static void releaseThreadId(Thread* thread) in releaseThreadId() argument
1122 assert(thread->threadId > 0); in releaseThreadId()
1123 dvmClearBit(gDvm.threadIdMap, thread->threadId - 1); in releaseThreadId()
1124 thread->threadId = 0; in releaseThreadId()
1135 static bool createFakeEntryFrame(Thread* thread) in createFakeEntryFrame() argument
1153 assert(thread->threadId == kMainThreadId); /* main thread only */ in createFakeEntryFrame()
1155 if (!dvmPushJNIFrame(thread, gDvm.methDalvikSystemNativeStart_main)) in createFakeEntryFrame()
1162 u4* framePtr = (u4*) thread->interpSave.curFrame; in createFakeEntryFrame()
1174 static bool createFakeRunFrame(Thread* thread) in createFakeRunFrame() argument
1176 return dvmPushJNIFrame(thread, gDvm.methDalvikSystemNativeStart_run); in createFakeRunFrame()
2184 void dvmSuspendThread(Thread* thread) in dvmSuspendThread() argument
2186 assert(thread != NULL); in dvmSuspendThread()
2187 assert(thread != dvmThreadSelf()); in dvmSuspendThread()
2191 dvmAddToSuspendCounts(thread, 1, 1); in dvmSuspendThread()
2194 thread->threadId, thread->suspendCount); in dvmSuspendThread()
2197 waitForThreadSuspend(dvmThreadSelf(), thread); in dvmSuspendThread()
2211 void dvmResumeThread(Thread* thread) in dvmResumeThread() argument
2213 assert(thread != NULL); in dvmResumeThread()
2214 assert(thread != dvmThreadSelf()); in dvmResumeThread()
2218 if (thread->suspendCount > 0) { in dvmResumeThread()
2219 dvmAddToSuspendCounts(thread, -1, -1); in dvmResumeThread()
2222 thread->threadId); in dvmResumeThread()
2226 thread->threadId, thread->suspendCount); in dvmResumeThread()
2228 if (thread->suspendCount == 0) { in dvmResumeThread()
2303 static void dumpWedgedThread(Thread* thread) in dumpWedgedThread() argument
2309 dvmDumpThread(thread, true); in dumpWedgedThread()
2323 int dvmRaiseThreadPriorityIfNeeded(Thread* thread, int* pSavedThreadPrio, in dvmRaiseThreadPriorityIfNeeded() argument
2327 *pSavedThreadPrio = getpriority(PRIO_PROCESS, thread->systemTid); in dvmRaiseThreadPriorityIfNeeded()
2330 thread->threadId, thread->systemTid); in dvmRaiseThreadPriorityIfNeeded()
2333 if (get_sched_policy(thread->systemTid, pSavedThreadPolicy) != 0) { in dvmRaiseThreadPriorityIfNeeded()
2335 thread->threadId, thread->systemTid); in dvmRaiseThreadPriorityIfNeeded()
2345 if (set_sched_policy(thread->systemTid, SP_FOREGROUND) != 0) { in dvmRaiseThreadPriorityIfNeeded()
2346 ALOGW("Couldn't set fg policy on tid %d", thread->systemTid); in dvmRaiseThreadPriorityIfNeeded()
2350 thread->systemTid, *pSavedThreadPolicy); in dvmRaiseThreadPriorityIfNeeded()
2360 if (setpriority(PRIO_PROCESS, thread->systemTid, kHigher) != 0) { in dvmRaiseThreadPriorityIfNeeded()
2362 thread->systemTid, kHigher); in dvmRaiseThreadPriorityIfNeeded()
2366 thread->systemTid, *pSavedThreadPrio, kHigher); in dvmRaiseThreadPriorityIfNeeded()
2376 void dvmResetThreadPriority(Thread* thread, int changeFlags, in dvmResetThreadPriority() argument
2380 if (set_sched_policy(thread->systemTid, savedThreadPolicy) != 0) { in dvmResetThreadPriority()
2382 thread->systemTid, savedThreadPolicy); in dvmResetThreadPriority()
2385 thread->systemTid, savedThreadPolicy); in dvmResetThreadPriority()
2390 if (setpriority(PRIO_PROCESS, thread->systemTid, savedThreadPrio) != 0) in dvmResetThreadPriority()
2393 thread->systemTid, savedThreadPrio); in dvmResetThreadPriority()
2396 thread->systemTid, savedThreadPrio); in dvmResetThreadPriority()
2427 static void waitForThreadSuspend(Thread* self, Thread* thread) in waitForThreadSuspend() argument
2441 while (thread->status == THREAD_RUNNING) { in waitForThreadSuspend()
2453 assert(thread->systemTid != 0); in waitForThreadSuspend()
2454 priChangeFlags = dvmRaiseThreadPriorityIfNeeded(thread, in waitForThreadSuspend()
2467 gDvmJit.hasNewChain && thread->inJitCodeCache) { in waitForThreadSuspend()
2468 ALOGD("JIT unchain all for threadid=%d", thread->threadId); in waitForThreadSuspend()
2481 thread->threadId, priChangeFlags); in waitForThreadSuspend()
2484 dumpWedgedThread(thread); in waitForThreadSuspend()
2499 self->threadId, thread->threadId); in waitForThreadSuspend()
2502 dvmNukeThread(thread); in waitForThreadSuspend()
2516 dvmResetThreadPriority(thread, priChangeFlags, savedThreadPrio, in waitForThreadSuspend()
2546 Thread* thread; in dvmSuspendAllThreads() local
2575 for (thread = gDvm.threadList; thread != NULL; thread = thread->next) { in dvmSuspendAllThreads()
2576 if (thread == self) in dvmSuspendAllThreads()
2581 thread->handle == dvmJdwpGetDebugThread(gDvm.jdwpState)) in dvmSuspendAllThreads()
2584 dvmAddToSuspendCounts(thread, 1, in dvmSuspendAllThreads()
2605 for (thread = gDvm.threadList; thread != NULL; thread = thread->next) { in dvmSuspendAllThreads()
2606 if (thread == self) in dvmSuspendAllThreads()
2611 thread->handle == dvmJdwpGetDebugThread(gDvm.jdwpState)) in dvmSuspendAllThreads()
2615 waitForThreadSuspend(self, thread); in dvmSuspendAllThreads()
2618 self->threadId, thread->threadId, thread->status, in dvmSuspendAllThreads()
2619 thread->suspendCount, thread->dbgSuspendCount); in dvmSuspendAllThreads()
2636 Thread* thread; in dvmResumeAllThreads() local
2648 for (thread = gDvm.threadList; thread != NULL; thread = thread->next) { in dvmResumeAllThreads()
2649 if (thread == self) in dvmResumeAllThreads()
2654 thread->handle == dvmJdwpGetDebugThread(gDvm.jdwpState)) in dvmResumeAllThreads()
2659 if (thread->suspendCount > 0) { in dvmResumeAllThreads()
2660 dvmAddToSuspendCounts(thread, -1, in dvmResumeAllThreads()
2666 thread->threadId); in dvmResumeAllThreads()
2731 Thread* thread; in dvmUndoDebuggerSuspensions() local
2743 for (thread = gDvm.threadList; thread != NULL; thread = thread->next) { in dvmUndoDebuggerSuspensions()
2744 if (thread == self) in dvmUndoDebuggerSuspensions()
2748 if (thread->handle == dvmJdwpGetDebugThread(gDvm.jdwpState)) { in dvmUndoDebuggerSuspensions()
2749 assert(thread->dbgSuspendCount == 0); in dvmUndoDebuggerSuspensions()
2753 assert(thread->suspendCount >= thread->dbgSuspendCount); in dvmUndoDebuggerSuspensions()
2754 dvmAddToSuspendCounts(thread, -thread->dbgSuspendCount, in dvmUndoDebuggerSuspensions()
2755 -thread->dbgSuspendCount); in dvmUndoDebuggerSuspensions()
2788 bool dvmIsSuspended(const Thread* thread) in dvmIsSuspended() argument
2803 return (thread->suspendCount != 0 && in dvmIsSuspended()
2804 thread->status != THREAD_RUNNING); in dvmIsSuspended()
2822 void dvmWaitForSuspend(Thread* thread) in dvmWaitForSuspend() argument
2827 self->threadId, thread->threadId); in dvmWaitForSuspend()
2829 assert(thread->handle != dvmJdwpGetDebugThread(gDvm.jdwpState)); in dvmWaitForSuspend()
2830 assert(thread != self); in dvmWaitForSuspend()
2833 waitForThreadSuspend(self, thread); in dvmWaitForSuspend()
2836 self->threadId, thread->threadId); in dvmWaitForSuspend()
3041 Thread* thread = gDvm.threadList; in dvmGetThreadFromThreadObject() local
3042 while (thread != NULL) { in dvmGetThreadFromThreadObject()
3043 if ((Thread*)vmData == thread) in dvmGetThreadFromThreadObject()
3046 thread = thread->next; in dvmGetThreadFromThreadObject()
3049 if (thread == NULL) { in dvmGetThreadFromThreadObject()
3067 Thread* thread; in dvmGetThreadByHandle() local
3068 for (thread = gDvm.threadList; thread != NULL; thread = thread->next) { in dvmGetThreadByHandle()
3069 if (thread->handle == handle) in dvmGetThreadByHandle()
3072 return thread; in dvmGetThreadByHandle()
3083 Thread* thread; in dvmGetThreadByThreadId() local
3084 for (thread = gDvm.threadList; thread != NULL; thread = thread->next) { in dvmGetThreadByThreadId()
3085 if (thread->threadId == threadId) in dvmGetThreadByThreadId()
3088 return thread; in dvmGetThreadByThreadId()
3091 void dvmChangeThreadPriority(Thread* thread, int newPriority) in dvmChangeThreadPriority() argument
3093 os_changeThreadPriority(thread, newPriority); in dvmChangeThreadPriority()
3100 bool dvmIsOnThreadList(const Thread* thread) in dvmIsOnThreadList() argument
3105 if (thread == gDvm.threadList) { in dvmIsOnThreadList()
3108 ret = thread->prev != NULL || thread->next != NULL; in dvmIsOnThreadList()
3119 void dvmDumpThread(Thread* thread, bool isRunning) in dvmDumpThread() argument
3124 dvmDumpThreadEx(&target, thread, isRunning); in dvmDumpThread()
3279 static bool shouldShowNativeStack(Thread* thread) { in shouldShowNativeStack() argument
3281 if (thread->status == THREAD_VMWAIT) { in shouldShowNativeStack()
3286 if (thread->status == THREAD_TIMED_WAIT || thread->status == THREAD_WAIT) { in shouldShowNativeStack()
3291 if (thread->status == THREAD_RUNNING) { in shouldShowNativeStack()
3300 u4* fp = thread->interpSave.curFrame; in shouldShowNativeStack()
3316 void dvmDumpThreadEx(const DebugOutputTarget* target, Thread* thread, in dvmDumpThreadEx() argument
3338 threadObj = thread->threadObj; in dvmDumpThreadEx()
3340 ALOGI("Can't dump thread %d: threadObj not set", thread->threadId); in dvmDumpThreadEx()
3364 getSchedulerStats(&schedStats, thread->systemTid); in dvmDumpThreadEx()
3369 priority, thread->threadId, dvmGetThreadStatusStr(thread->status), in dvmDumpThreadEx()
3371 thread->inJitCodeCache ? " JIT" : "" in dvmDumpThreadEx()
3378 groupName, thread->suspendCount, thread->dbgSuspendCount, in dvmDumpThreadEx()
3379 thread->threadObj, thread); in dvmDumpThreadEx()
3382 thread->systemTid, getpriority(PRIO_PROCESS, thread->systemTid), in dvmDumpThreadEx()
3383 schedStats.policy, schedStats.priority, schedStats.group, (int)thread->handle); in dvmDumpThreadEx()
3385 dumpSchedStat(target, thread->systemTid); in dvmDumpThreadEx()
3387 if (shouldShowNativeStack(thread)) { in dvmDumpThreadEx()
3388 dvmDumpNativeStack(target, thread->systemTid); in dvmDumpThreadEx()
3392 dvmDumpRunningThreadStack(target, thread); in dvmDumpThreadEx()
3394 dvmDumpThreadStack(target, thread); in dvmDumpThreadEx()
3403 std::string dvmGetThreadName(Thread* thread) { in dvmGetThreadName() argument
3404 if (thread->threadObj == NULL) { in dvmGetThreadName()
3410 dvmGetFieldObject(thread->threadObj, gDvm.offJavaLangThread_name); in dvmGetThreadName()
3461 for (Thread* thread = gDvm.threadList; thread != NULL; thread = thread->next) { in isDalvikThread() local
3462 if (thread->systemTid == tid) { in isDalvikThread()
3491 Thread* thread; in dvmDumpAllThreadsEx() local
3507 thread = gDvm.threadList; in dvmDumpAllThreadsEx()
3508 while (thread != NULL) { in dvmDumpAllThreadsEx()
3509 dvmDumpThreadEx(target, thread, false); in dvmDumpAllThreadsEx()
3512 assert(thread->next == NULL || thread->next->prev == thread); in dvmDumpAllThreadsEx()
3514 thread = thread->next; in dvmDumpAllThreadsEx()
3555 void dvmNukeThread(Thread* thread) in dvmNukeThread() argument
3590 dvmThreadSelf()->threadId, thread->threadId, thread->systemTid); in dvmNukeThread()
3591 killResult = pthread_kill(thread->handle, SIG); in dvmNukeThread()
3596 killResult = pthread_kill(thread->handle, SIG); in dvmNukeThread()