Lines Matching refs:gDvmJit
34 return gDvmJit.compilerQueueLength;
39 assert(gDvmJit.compilerWorkQueue[gDvmJit.compilerWorkDequeueIndex].kind
42 gDvmJit.compilerWorkQueue[gDvmJit.compilerWorkDequeueIndex];
43 gDvmJit.compilerWorkQueue[gDvmJit.compilerWorkDequeueIndex++].kind =
45 if (gDvmJit.compilerWorkDequeueIndex == COMPILER_WORK_QUEUE_SIZE) {
46 gDvmJit.compilerWorkDequeueIndex = 0;
48 gDvmJit.compilerQueueLength--;
49 if (gDvmJit.compilerQueueLength == 0) {
50 dvmSignalCond(&gDvmJit.compilerQueueEmpty);
54 if (gDvmJit.compilerQueueLength > gDvmJit.compilerMaxQueued)
55 gDvmJit.compilerMaxQueued = gDvmJit.compilerQueueLength;
76 gDvmJit.codeCacheFull = true; // Force reset
79 dvmLockMutex(&gDvmJit.compilerLock);
80 pthread_cond_wait(&gDvmJit.compilerQueueActivity,
81 &gDvmJit.compilerLock);
82 dvmUnlockMutex(&gDvmJit.compilerLock);
102 dvmLockMutex(&gDvmJit.compilerLock);
107 if (gDvmJit.compilerQueueLength == COMPILER_WORK_QUEUE_SIZE ||
108 gDvmJit.codeCacheFull == true) {
109 dvmUnlockMutex(&gDvmJit.compilerLock);
113 for (numWork = gDvmJit.compilerQueueLength,
114 i = gDvmJit.compilerWorkDequeueIndex;
118 if (gDvmJit.compilerWorkQueue[i++].pc == pc) {
119 dvmUnlockMutex(&gDvmJit.compilerLock);
128 &gDvmJit.compilerWorkQueue[gDvmJit.compilerWorkEnqueueIndex];
136 newOrder->result.cacheVersion = gDvmJit.cacheVersion;
139 gDvmJit.compilerWorkEnqueueIndex++;
140 if (gDvmJit.compilerWorkEnqueueIndex == COMPILER_WORK_QUEUE_SIZE)
141 gDvmJit.compilerWorkEnqueueIndex = 0;
142 gDvmJit.compilerQueueLength++;
143 cc = pthread_cond_signal(&gDvmJit.compilerQueueActivity);
146 dvmUnlockMutex(&gDvmJit.compilerLock);
155 dvmLockMutex(&gDvmJit.compilerLock);
156 while (workQueueLength() != 0 && !gDvmJit.haltCompilerThread &&
164 dvmRelativeCondWait(&gDvmJit.compilerQueueEmpty, &gDvmJit.compilerLock, 1000, 0);
166 dvmUnlockMutex(&gDvmJit.compilerLock);
174 fd = ashmem_create_region("dalvik-jit-code-cache", gDvmJit.codeCacheSize);
177 gDvmJit.codeCacheSize);
180 gDvmJit.codeCache = mmap(NULL, gDvmJit.codeCacheSize,
184 if (gDvmJit.codeCache == MAP_FAILED) {
185 ALOGE("Failed to mmap the JIT code cache of size %d: %s", gDvmJit.codeCacheSize, strerror(errno));
189 gDvmJit.pageSizeMask = getpagesize() - 1;
192 // ALOGD("Code cache starts at %p", gDvmJit.codeCache);
198 memcpy((void *) gDvmJit.codeCache,
210 gDvmJit.templateSize = templateSize;
211 gDvmJit.codeCacheByteUsed = templateSize;
214 dvmCompilerCacheFlush((intptr_t) gDvmJit.codeCache,
215 (intptr_t) gDvmJit.codeCache + templateSize, 0);
217 gDvmJit.codeCacheByteUsed = 0;
218 stream = (char*)gDvmJit.codeCache + gDvmJit.codeCacheByteUsed;
219 ALOGV("codeCache = %p stream = %p before initJIT", gDvmJit.codeCache, stream);
222 gDvmJit.templateSize = (stream - streamStart);
223 gDvmJit.codeCacheByteUsed = (stream - streamStart);
227 int result = mprotect(gDvmJit.codeCache, gDvmJit.codeCacheSize,
284 int byteUsed = gDvmJit.codeCacheByteUsed;
306 gDvmJit.codeCacheByteUsed, gDvmJit.numCodeCacheReset,
307 ++gDvmJit.numCodeCacheResetDelayed);
312 dvmLockMutex(&gDvmJit.compilerLock);
315 gDvmJit.cacheVersion++;
326 UNPROTECT_CODE_CACHE(gDvmJit.codeCache, gDvmJit.codeCacheByteUsed);
331 dvmCompilerCacheClear((char *) gDvmJit.codeCache + gDvmJit.templateSize,
332 gDvmJit.codeCacheByteUsed - gDvmJit.templateSize);
334 dvmCompilerCacheFlush((intptr_t) gDvmJit.codeCache,
335 (intptr_t) gDvmJit.codeCache +
336 gDvmJit.codeCacheByteUsed, 0);
338 PROTECT_CODE_CACHE(gDvmJit.codeCache, gDvmJit.codeCacheByteUsed);
341 gDvmJit.codeCacheByteUsed = gDvmJit.templateSize;
342 gDvmJit.numCompilations = 0;
345 memset(gDvmJit.compilerWorkQueue, 0,
347 gDvmJit.compilerWorkEnqueueIndex = gDvmJit.compilerWorkDequeueIndex = 0;
348 gDvmJit.compilerQueueLength = 0;
351 dvmLockMutex(&gDvmJit.compilerICPatchLock);
352 gDvmJit.compilerICPatchIndex = 0;
353 dvmUnlockMutex(&gDvmJit.compilerICPatchLock);
359 gDvmJit.inflightBaseAddr = NULL;
362 gDvmJit.codeCacheFull = false;
364 dvmUnlockMutex(&gDvmJit.compilerLock);
368 byteUsed, ++gDvmJit.numCodeCacheReset,
369 gDvmJit.numCodeCacheResetDelayed);
381 if (gDvmJit.codeCacheFull) {
401 if (gDvmJit.codeCache == NULL) {
412 gDvmJit.compilerThread = dvmThreadSelf();
414 dvmLockMutex(&gDvmJit.compilerLock);
417 gDvmJit.methodStatsTable = dvmHashTableCreate(32, NULL);
423 dvmUnlockMutex(&gDvmJit.compilerLock);
428 assert(gDvmJit.jitTableSize &&
429 !(gDvmJit.jitTableSize & (gDvmJit.jitTableSize - 1)));
431 dvmInitMutex(&gDvmJit.tableLock);
432 dvmLockMutex(&gDvmJit.tableLock);
434 calloc(gDvmJit.jitTableSize, sizeof(*pJitTable));
437 dvmUnlockMutex(&gDvmJit.tableLock);
452 dvmUnlockMutex(&gDvmJit.tableLock);
455 memset(pJitProfTable, gDvmJit.threshold, JIT_PROF_SIZE);
456 for (i=0; i < gDvmJit.jitTableSize; i++) {
457 pJitTable[i].u.info.chain = gDvmJit.jitTableSize;
460 assert(pJitTable[0].u.info.chain == gDvmJit.jitTableSize);
469 dvmUnlockMutex(&gDvmJit.tableLock);
473 gDvmJit.pJitEntryTable = pJitTable;
474 gDvmJit.jitTableMask = gDvmJit.jitTableSize - 1;
475 gDvmJit.jitTableEntriesUsed = 0;
476 gDvmJit.compilerHighWater =
482 gDvmJit.pProfTable = dvmDebuggerOrProfilerActive() ? NULL : pJitProfTable;
483 gDvmJit.pProfTableCopy = pJitProfTable;
484 gDvmJit.pJitTraceProfCounters = pJitTraceProfCounters;
486 dvmUnlockMutex(&gDvmJit.tableLock);
516 * can be pasted into the gDvmJit.signatureBreakpoint[] array and next time
532 gDvmJit.signatureBreakpointSize = 4;
533 gDvmJit.signatureBreakpoint =
534 malloc(sizeof(u4) * gDvmJit.signatureBreakpointSize);
535 gDvmJit.signatureBreakpoint[0] = 0x512000bc;
536 gDvmJit.signatureBreakpoint[1] = 0x37016eaf;
537 gDvmJit.signatureBreakpoint[2] = 0x6ea866af;
538 gDvmJit.signatureBreakpoint[3] = 0x6f696028;
615 if (gDvmJit.runningInAndroidFramework &&
616 !gDvmJit.alreadyEnabledViaFramework) {
628 dvmLockMutex(&gDvmJit.compilerLock);
629 pthread_cond_wait(&gDvmJit.compilerQueueActivity,
630 &gDvmJit.compilerLock);
631 dvmUnlockMutex(&gDvmJit.compilerLock);
634 dvmLockMutex(&gDvmJit.compilerLock);
639 dvmRelativeCondWait(&gDvmJit.compilerQueueActivity,
640 &gDvmJit.compilerLock, 3000, 0);
641 dvmUnlockMutex(&gDvmJit.compilerLock);
643 if (gDvmJit.haltCompilerThread) {
650 dvmLockMutex(&gDvmJit.compilerLock);
656 while (!gDvmJit.haltCompilerThread) {
659 cc = pthread_cond_signal(&gDvmJit.compilerQueueEmpty);
661 pthread_cond_wait(&gDvmJit.compilerQueueActivity,
662 &gDvmJit.compilerLock);
667 dvmUnlockMutex(&gDvmJit.compilerLock);
686 if (!gDvmJit.blockingMode)
689 if (gDvmJit.jitTableEntriesUsed >
690 (gDvmJit.jitTableSize - gDvmJit.jitTableSize/4)) {
692 dvmJitResizeJitTable(gDvmJit.jitTableSize * 2);
697 gDvmJit.codeCacheFull |= resizeFail;
699 if (gDvmJit.haltCompilerThread) {
701 } else if (!gDvmJit.codeCacheFull) {
712 dvmLockMutex(&gDvmJit.compilerLock);
714 gDvmJit.cacheVersion) &&
723 dvmUnlockMutex(&gDvmJit.compilerLock);
729 gDvmJit.jitTime += dvmGetRelativeTimeUsec() - startTime;
731 dvmLockMutex(&gDvmJit.compilerLock);
735 pthread_cond_signal(&gDvmJit.compilerQueueEmpty);
736 dvmUnlockMutex(&gDvmJit.compilerLock);
753 dvmInitMutex(&gDvmJit.compilerLock);
754 dvmInitMutex(&gDvmJit.compilerICPatchLock);
755 dvmInitMutex(&gDvmJit.codeCacheProtectionLock);
756 dvmLockMutex(&gDvmJit.compilerLock);
757 pthread_cond_init(&gDvmJit.compilerQueueActivity, NULL);
758 pthread_cond_init(&gDvmJit.compilerQueueEmpty, NULL);
761 gDvmJit.compilerWorkEnqueueIndex = gDvmJit.compilerWorkDequeueIndex = 0;
762 gDvmJit.compilerQueueLength = 0;
763 dvmUnlockMutex(&gDvmJit.compilerLock);
770 return dvmCreateInternalThread(&gDvmJit.compilerHandle, "Compiler",
779 gDvmJit.pProfTable = NULL;
780 gDvmJit.pProfTableCopy = NULL;
784 gDvmJit.profileMode == kTraceProfilingContinuous) {
786 while (gDvmJit.compilerQueueLength)
790 if (gDvmJit.compilerHandle) {
792 gDvmJit.haltCompilerThread = true;
794 dvmLockMutex(&gDvmJit.compilerLock);
795 pthread_cond_signal(&gDvmJit.compilerQueueActivity);
796 dvmUnlockMutex(&gDvmJit.compilerLock);
798 if (pthread_join(gDvmJit.compilerHandle, &threadReturn) != 0)
828 if (gDvmJit.pProfTableCopy == NULL) {
841 !gDvmJit.methodTraceSupport) {
847 dvmLockMutex(&gDvmJit.compilerLock);
848 gDvmJit.cacheVersion++; // invalidate compilations in flight
849 gDvmJit.methodTraceSupport = true;
850 resetRequired = (gDvmJit.numCompilations != 0);
851 dvmUnlockMutex(&gDvmJit.compilerLock);
859 dvmLockMutex(&gDvmJit.tableLock);
860 jitActive = gDvmJit.pProfTable != NULL;
864 gDvmJit.pProfTable = gDvmJit.pProfTableCopy;
866 gDvmJit.pProfTable = NULL;
869 dvmUnlockMutex(&gDvmJit.tableLock);