2 * Copyright (C) 2008 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * Variables with library scope.
20 * Prefer this over scattered static and global variables -- it's easier to
21 * view the state in a debugger, it makes clean shutdown simpler, we can
22 * trivially dump the state into a crash log, and it dodges most naming
23 * collisions that will arise when we are embedded in a larger program.
25 * If we want multiple VMs per process, this can get stuffed into TLS (or
26 * accessed through a Thread field). May need to pass it around for some
27 * of the early initialization functions.
29 #ifndef DALVIK_GLOBALS_H_
30 #define DALVIK_GLOBALS_H_
38 /* private structures */
44 * One of these for each -ea/-da/-esa/-dsa on the command line.
46 struct AssertionControl {
47 char* pkgOrClass; /* package/class string, or NULL for esa/dsa */
48 int pkgOrClassLen; /* string length, for quick compare */
49 bool enable; /* enable or disable */
50 bool isPackage; /* string ended with "..."? */
54 * Register map generation mode. Only applicable when generateRegisterMaps
55 * is enabled. (The "disabled" state is not folded into this because
56 * there are callers like dexopt that want to enable/disable without
57 * specifying the configuration details.)
59 * "TypePrecise" is slower and requires additional storage for the register
60 * maps, but allows type-precise GC. "LivePrecise" is even slower and
61 * requires additional heap during processing, but allows live-precise GC.
63 enum RegisterMapMode {
64 kRegisterMapModeUnknown = 0,
65 kRegisterMapModeTypePrecise,
66 kRegisterMapModeLivePrecise
70 * Profiler clock source.
72 enum ProfilerClockSource {
73 kProfilerClockSourceThreadCpu,
74 kProfilerClockSourceWall,
75 kProfilerClockSourceDual,
79 * All fields are initialized to zero.
81 * Storage allocated here must be freed by a subsystem shutdown function.
85 * Some options from the command line or environment.
87 char* bootClassPathStr;
90 size_t heapStartingSize;
91 size_t heapMaximumSize;
92 size_t heapGrowthLimit;
93 double heapTargetUtilization;
97 size_t mainThreadStackSize;
102 bool verboseShutdown;
104 bool jdwpAllowed; // debugging allowed for this process?
105 bool jdwpConfigured; // has debugging info been provided?
106 JdwpTransportType jdwpTransport;
112 ProfilerClockSource profilerClockSource;
115 * Lock profiling threshold value in milliseconds. Acquires that
116 * exceed threshold are logged. Acquires within the threshold are
117 * logged with a probability of $\frac{time}{threshold}$ . If the
118 * threshold is unset no additional logging occurs.
120 u4 lockProfThreshold;
122 int (*vfprintfHook)(FILE*, const char*, va_list);
123 void (*exitHook)(int);
124 void (*abortHook)(void);
125 bool (*isSensitiveThreadHook)(void);
130 bool verifyDexChecksum;
131 char* stackTraceFile; // for SIGQUIT-inspired output
135 DexOptimizerMode dexOptMode;
136 DexClassVerifyMode classVerifyMode;
138 bool generateRegisterMaps;
139 RegisterMapMode registerMapMode;
141 bool monitorVerification;
151 bool concurrentMarkSweep;
152 bool verifyCardTable;
153 bool disableExplicitGc;
155 int assertionCtrlCount;
156 AssertionControl* assertionCtrl;
158 ExecutionMode executionMode;
160 bool commonInit; /* whether common stubs are generated */
161 bool constInit; /* whether global constants are initialized */
164 * VM init management.
170 * java.lang.System properties set from the command line with -D.
171 * This is effectively a set, where later entries override earlier
174 std::vector<std::string>* properties;
177 * Where the VM goes to find system classes.
179 ClassPathEntry* bootClassPath;
180 /* used by the DEX optimizer to load classes from an unfinished DEX */
181 DvmDex* bootClassPathOptExtra;
182 bool optimizingBootstrapClass;
185 * Loaded classes, hashed by class name. Each entry is a ClassObject*,
186 * allocated in GC space.
188 HashTable* loadedClasses;
191 * Value for the next class serial number to be assigned. This is
192 * incremented as we load classes. Failed loads and races may result
193 * in some numbers being skipped, and the serial number is not
194 * guaranteed to start at 1, so the current value should not be used
195 * as a count of loaded classes.
197 volatile int classSerialNumber;
200 * Classes with a low classSerialNumber are probably in the zygote, and
201 * their InitiatingLoaderList is not used, to promote sharing. The list is
204 InitiatingLoaderList* initiatingLoaderList;
210 /* A mutex that guards access to the interned string tables. */
211 pthread_mutex_t internLock;
213 /* Hash table of strings interned by the user. */
214 HashTable* internedStrings;
216 /* Hash table of strings interned by the class loader. */
217 HashTable* literalStrings;
220 * Classes constructed directly by the vm.
223 /* the class Class */
224 ClassObject* classJavaLangClass;
226 /* synthetic classes representing primitive types */
227 ClassObject* typeVoid;
228 ClassObject* typeBoolean;
229 ClassObject* typeByte;
230 ClassObject* typeShort;
231 ClassObject* typeChar;
232 ClassObject* typeInt;
233 ClassObject* typeLong;
234 ClassObject* typeFloat;
235 ClassObject* typeDouble;
237 /* synthetic classes for arrays of primitives */
238 ClassObject* classArrayBoolean;
239 ClassObject* classArrayByte;
240 ClassObject* classArrayShort;
241 ClassObject* classArrayChar;
242 ClassObject* classArrayInt;
243 ClassObject* classArrayLong;
244 ClassObject* classArrayFloat;
245 ClassObject* classArrayDouble;
248 * Quick lookups for popular classes used internally.
250 ClassObject* classJavaLangClassArray;
251 ClassObject* classJavaLangClassLoader;
252 ClassObject* classJavaLangObject;
253 ClassObject* classJavaLangObjectArray;
254 ClassObject* classJavaLangString;
255 ClassObject* classJavaLangThread;
256 ClassObject* classJavaLangVMThread;
257 ClassObject* classJavaLangThreadGroup;
258 ClassObject* classJavaLangStackTraceElement;
259 ClassObject* classJavaLangStackTraceElementArray;
260 ClassObject* classJavaLangAnnotationAnnotationArray;
261 ClassObject* classJavaLangAnnotationAnnotationArrayArray;
262 ClassObject* classJavaLangReflectAccessibleObject;
263 ClassObject* classJavaLangReflectConstructor;
264 ClassObject* classJavaLangReflectConstructorArray;
265 ClassObject* classJavaLangReflectField;
266 ClassObject* classJavaLangReflectFieldArray;
267 ClassObject* classJavaLangReflectMethod;
268 ClassObject* classJavaLangReflectMethodArray;
269 ClassObject* classJavaLangReflectProxy;
270 ClassObject* classJavaNioDirectByteBuffer;
271 ClassObject* classLibcoreReflectAnnotationFactory;
272 ClassObject* classLibcoreReflectAnnotationMember;
273 ClassObject* classLibcoreReflectAnnotationMemberArray;
274 ClassObject* classOrgApacheHarmonyDalvikDdmcChunk;
275 ClassObject* classOrgApacheHarmonyDalvikDdmcDdmServer;
276 ClassObject* classJavaLangRefFinalizerReference;
279 * classes representing exception types. The names here don't include
280 * packages, just to keep the use sites a bit less verbose. All are
281 * in java.lang, except where noted.
283 ClassObject* exAbstractMethodError;
284 ClassObject* exArithmeticException;
285 ClassObject* exArrayIndexOutOfBoundsException;
286 ClassObject* exArrayStoreException;
287 ClassObject* exClassCastException;
288 ClassObject* exClassCircularityError;
289 ClassObject* exClassFormatError;
290 ClassObject* exClassNotFoundException;
291 ClassObject* exError;
292 ClassObject* exExceptionInInitializerError;
293 ClassObject* exFileNotFoundException; /* in java.io */
294 ClassObject* exIOException; /* in java.io */
295 ClassObject* exIllegalAccessError;
296 ClassObject* exIllegalAccessException;
297 ClassObject* exIllegalArgumentException;
298 ClassObject* exIllegalMonitorStateException;
299 ClassObject* exIllegalStateException;
300 ClassObject* exIllegalThreadStateException;
301 ClassObject* exIncompatibleClassChangeError;
302 ClassObject* exInstantiationError;
303 ClassObject* exInstantiationException;
304 ClassObject* exInternalError;
305 ClassObject* exInterruptedException;
306 ClassObject* exLinkageError;
307 ClassObject* exNegativeArraySizeException;
308 ClassObject* exNoClassDefFoundError;
309 ClassObject* exNoSuchFieldError;
310 ClassObject* exNoSuchFieldException;
311 ClassObject* exNoSuchMethodError;
312 ClassObject* exNullPointerException;
313 ClassObject* exOutOfMemoryError;
314 ClassObject* exRuntimeException;
315 ClassObject* exStackOverflowError;
316 ClassObject* exStaleDexCacheError; /* in dalvik.system */
317 ClassObject* exStringIndexOutOfBoundsException;
318 ClassObject* exThrowable;
319 ClassObject* exTypeNotPresentException;
320 ClassObject* exUnsatisfiedLinkError;
321 ClassObject* exUnsupportedOperationException;
322 ClassObject* exVerifyError;
323 ClassObject* exVirtualMachineError;
325 /* method offsets - Object */
326 int voffJavaLangObject_equals;
327 int voffJavaLangObject_hashCode;
328 int voffJavaLangObject_toString;
330 /* field offsets - String */
331 int offJavaLangString_value;
332 int offJavaLangString_count;
333 int offJavaLangString_offset;
334 int offJavaLangString_hashCode;
336 /* field offsets - Thread */
337 int offJavaLangThread_vmThread;
338 int offJavaLangThread_group;
339 int offJavaLangThread_daemon;
340 int offJavaLangThread_name;
341 int offJavaLangThread_priority;
342 int offJavaLangThread_uncaughtHandler;
343 int offJavaLangThread_contextClassLoader;
345 /* method offsets - Thread */
346 int voffJavaLangThread_run;
348 /* field offsets - ThreadGroup */
349 int offJavaLangThreadGroup_name;
350 int offJavaLangThreadGroup_parent;
352 /* field offsets - VMThread */
353 int offJavaLangVMThread_thread;
354 int offJavaLangVMThread_vmData;
356 /* method offsets - ThreadGroup */
357 int voffJavaLangThreadGroup_removeThread;
359 /* field offsets - Throwable */
360 int offJavaLangThrowable_stackState;
361 int offJavaLangThrowable_cause;
363 /* method offsets - ClassLoader */
364 int voffJavaLangClassLoader_loadClass;
366 /* direct method pointers - ClassLoader */
367 Method* methJavaLangClassLoader_getSystemClassLoader;
369 /* field offsets - java.lang.reflect.* */
370 int offJavaLangReflectConstructor_slot;
371 int offJavaLangReflectConstructor_declClass;
372 int offJavaLangReflectField_slot;
373 int offJavaLangReflectField_declClass;
374 int offJavaLangReflectMethod_slot;
375 int offJavaLangReflectMethod_declClass;
377 /* field offsets - java.lang.ref.Reference */
378 int offJavaLangRefReference_referent;
379 int offJavaLangRefReference_queue;
380 int offJavaLangRefReference_queueNext;
381 int offJavaLangRefReference_pendingNext;
383 /* field offsets - java.lang.ref.FinalizerReference */
384 int offJavaLangRefFinalizerReference_zombie;
386 /* method pointers - java.lang.ref.ReferenceQueue */
387 Method* methJavaLangRefReferenceQueueAdd;
389 /* method pointers - java.lang.ref.FinalizerReference */
390 Method* methJavaLangRefFinalizerReferenceAdd;
392 /* constructor method pointers; no vtable involved, so use Method* */
393 Method* methJavaLangStackTraceElement_init;
394 Method* methJavaLangReflectConstructor_init;
395 Method* methJavaLangReflectField_init;
396 Method* methJavaLangReflectMethod_init;
397 Method* methOrgApacheHarmonyLangAnnotationAnnotationMember_init;
399 /* static method pointers - android.lang.annotation.* */
401 methOrgApacheHarmonyLangAnnotationAnnotationFactory_createAnnotation;
403 /* direct method pointers - java.lang.reflect.Proxy */
404 Method* methJavaLangReflectProxy_constructorPrototype;
406 /* field offsets - java.lang.reflect.Proxy */
407 int offJavaLangReflectProxy_h;
409 /* field offsets - java.io.FileDescriptor */
410 int offJavaIoFileDescriptor_descriptor;
412 /* direct method pointers - dalvik.system.NativeStart */
413 Method* methDalvikSystemNativeStart_main;
414 Method* methDalvikSystemNativeStart_run;
416 /* assorted direct buffer helpers */
417 Method* methJavaNioDirectByteBuffer_init;
418 int offJavaNioBuffer_capacity;
419 int offJavaNioBuffer_effectiveDirectAddress;
421 /* direct method pointers - org.apache.harmony.dalvik.ddmc.DdmServer */
422 Method* methDalvikDdmcServer_dispatch;
423 Method* methDalvikDdmcServer_broadcast;
425 /* field offsets - org.apache.harmony.dalvik.ddmc.Chunk */
426 int offDalvikDdmcChunk_type;
427 int offDalvikDdmcChunk_data;
428 int offDalvikDdmcChunk_offset;
429 int offDalvikDdmcChunk_length;
432 * Thread list. This always has at least one element in it (main),
433 * and main is always the first entry.
435 * The threadListLock is used for several things, including the thread
436 * start condition variable. Generally speaking, you must hold the
437 * threadListLock when:
438 * - adding/removing items from the list
439 * - waiting on or signaling threadStartCond
440 * - examining the Thread struct for another thread (this is to avoid
441 * one thread freeing the Thread struct while another thread is
445 pthread_mutex_t threadListLock;
447 pthread_cond_t threadStartCond;
450 * The thread code grabs this before suspending all threads. There
451 * are a few things that can cause a "suspend all":
452 * (1) the GC is starting;
453 * (2) the debugger has sent a "suspend all" request;
454 * (3) a thread has hit a breakpoint or exception that the debugger
455 * has marked as a "suspend all" event;
456 * (4) the SignalCatcher caught a signal that requires suspension.
457 * (5) (if implemented) the JIT needs to perform a heavyweight
458 * rearrangement of the translation cache or JitTable.
460 * Because we use "safe point" self-suspension, it is never safe to
461 * do a blocking "lock" call on this mutex -- if it has been acquired,
462 * somebody is probably trying to put you to sleep. The leading '_' is
463 * intended as a reminder that this lock is special.
465 pthread_mutex_t _threadSuspendLock;
468 * Guards Thread->suspendCount for all threads, and
469 * provides the lock for the condition variable that all suspended threads
470 * sleep on (threadSuspendCountCond).
472 * This has to be separate from threadListLock because of the way
473 * threads put themselves to sleep.
475 pthread_mutex_t threadSuspendCountLock;
478 * Suspended threads sleep on this. They should sleep on the condition
479 * variable until their "suspend count" is zero.
481 * Paired with "threadSuspendCountLock".
483 pthread_cond_t threadSuspendCountCond;
486 * Sum of all threads' suspendCount fields. Guarded by
487 * threadSuspendCountLock.
489 int sumThreadSuspendCount;
492 * MUTEX ORDERING: when locking multiple mutexes, always grab them in
493 * this order to avoid deadlock:
495 * (1) _threadSuspendLock (use lockThreadSuspend())
496 * (2) threadListLock (use dvmLockThreadList())
497 * (3) threadSuspendCountLock (use lockThreadSuspendCount())
502 * Thread ID bitmap. We want threads to have small integer IDs so
503 * we can use them in "thin locks".
505 BitVector* threadIdMap;
508 * Manage exit conditions. The VM exits when all non-daemon threads
509 * have exited. If the main thread returns early, we need to sleep
510 * on a condition variable.
512 int nonDaemonThreadCount; /* must hold threadListLock to access */
513 pthread_cond_t vmExitCond;
516 * The set of DEX files loaded by custom class loaders.
518 HashTable* userDexFiles;
521 * JNI global reference table.
523 IndirectRefTable jniGlobalRefTable;
524 IndirectRefTable jniWeakGlobalRefTable;
525 pthread_mutex_t jniGlobalRefLock;
526 pthread_mutex_t jniWeakGlobalRefLock;
529 * JNI pinned object table (used for primitive arrays).
531 ReferenceTable jniPinRefTable;
532 pthread_mutex_t jniPinRefLock;
535 * Native shared library table.
537 HashTable* nativeLibs;
540 * GC heap lock. Functions like gcMalloc() acquire this before making
541 * any changes to the heap. It is held throughout garbage collection.
543 pthread_mutex_t gcHeapLock;
546 * Condition variable to queue threads waiting to retry an
547 * allocation. Signaled after a concurrent GC is completed.
549 pthread_cond_t gcHeapCond;
551 /* Opaque pointer representing the heap. */
554 /* The card table base, modified as needed for marking cards. */
555 u1* biasedCardTableBase;
558 * Pre-allocated throwables.
560 Object* outOfMemoryObj;
561 Object* internalErrorObj;
562 Object* noClassDefFoundErrorObj;
564 /* Monitor list, so we can free them */
565 /*volatile*/ Monitor* monitorList;
567 /* Monitor for Thread.sleep() implementation */
568 Monitor* threadSleepMon;
570 /* set when we create a second heap inside the zygote */
571 bool newZygoteHeapAllocated;
576 pthread_key_t pthreadKeySelf; /* Thread*, for dvmThreadSelf */
579 * Cache results of "A instanceof B".
581 AtomicCache* instanceofCache;
583 /* inline substitution table, used during optimization */
584 InlineSub* inlineSubs;
587 * Bootstrap class loader linear allocator.
589 LinearAllocHdr* pBootLoaderAlloc;
592 * Compute some stats on loaded classes.
594 int numLoadedClasses;
595 int numDeclaredMethods;
596 int numDeclaredInstFields;
597 int numDeclaredStaticFields;
599 /* when using a native debugger, set this to suppress watchdog timers */
600 bool nativeDebuggerActive;
603 * JDWP debugger support.
605 * Note: Each thread will normally determine whether the debugger is active
606 * for it by referring to its subMode flags. "debuggerActive" here should be
607 * seen as "debugger is making requests of 1 or more threads".
609 bool debuggerConnected; /* debugger or DDMS is connected */
610 bool debuggerActive; /* debugger is making requests */
611 JdwpState* jdwpState;
614 * Registry of objects known to the debugger.
616 HashTable* dbgRegistry;
619 * Debugger breakpoint table.
621 BreakpointSet* breakpointSet;
624 * Single-step control struct. We currently only allow one thread to
625 * be single-stepping at a time, which is all that really makes sense,
626 * but it's possible we may need to expand this to be per-thread.
628 StepControl stepControl;
631 * DDM features embedded in the VM.
633 bool ddmThreadNotification;
636 * Zygote (partially-started process) support
641 * Used for tracking allocations that we report to DDMS. When the feature
642 * is enabled (through a DDMS request) the "allocRecords" pointer becomes
645 pthread_mutex_t allocTrackerLock;
646 AllocRecord* allocRecords;
647 int allocRecordHead; /* most-recently-added entry */
648 int allocRecordCount; /* #of valid entries */
649 int allocRecordMax; /* Number of allocated entries. */
652 * When a profiler is enabled, this is incremented. Distinct profilers
653 * include "dmtrace" method tracing, emulator method tracing, and
654 * possibly instruction counting.
656 * The purpose of this is to have a single value that shows whether any
657 * profiling is going on. Individual thread will normally check their
658 * thread-private subMode flags to take any profiling action.
660 volatile int activeProfilers;
663 * State for method-trace profiling.
665 MethodTraceState methodTrace;
666 Method* methodTraceGcMethod;
667 Method* methodTraceClassPrepMethod;
670 * State for emulator tracing.
672 void* emulatorTracePage;
673 int emulatorTraceEnableCount;
676 * Global state for memory allocation profiling.
678 AllocProfState allocProf;
681 * Pointers to the original methods for things that have been inlined.
682 * This makes it easy for us to output method entry/exit records for
683 * the method calls we're not actually making. (Used by method
686 Method** inlinedMethods;
689 * Dalvik instruction counts (kNumPackedOpcodes entries).
691 int* executedInstrCounts;
692 int instructionCountEnableCount;
695 * Signal catcher thread (for SIGQUIT).
697 pthread_t signalCatcherHandle;
698 bool haltSignalCatcher;
701 * Stdout/stderr conversion thread.
703 bool haltStdioConverter;
704 bool stdioConverterReady;
705 pthread_t stdioConverterHandle;
706 pthread_mutex_t stdioConverterLock;
707 pthread_cond_t stdioConverterCond;
712 * pid of the system_server process. We track it so that when system server
713 * crashes the Zygote process will be killed and restarted.
715 pid_t systemServerPid;
717 int kernelGroupScheduling;
719 //#define COUNT_PRECISE_METHODS
720 #ifdef COUNT_PRECISE_METHODS
721 PointerSet* preciseMethods;
724 /* some RegisterMap statistics, useful during development */
725 void* registerMapStats;
727 #ifdef VERIFIER_STATS
728 VerifierStats verifierStats;
731 /* String pointed here will be deposited on the stack frame of dvmAbort */
732 const char *lastMessage;
735 extern struct DvmGlobals gDvm;
737 #if defined(WITH_JIT)
739 /* Trace profiling modes. Ordering matters - off states before on states */
740 enum TraceProfilingModes {
741 kTraceProfilingDisabled = 0, // Not profiling
742 kTraceProfilingPeriodicOff = 1, // Periodic profiling, off phase
743 kTraceProfilingContinuous = 2, // Always profiling
744 kTraceProfilingPeriodicOn = 3 // Periodic profiling, on phase
748 * Exiting the compiled code w/o chaining will incur overhead to look up the
749 * target in the code cache which is extra work only when JIT is enabled. So
750 * we want to monitor it closely to make sure we don't have performance bugs.
753 kInlineCacheMiss = 0,
754 kCallsiteInterpreted,
761 * JIT-specific global state
763 struct DvmJitGlobals {
765 * Guards writes to Dalvik PC (dPC), translated code address (codeAddr) and
766 * chain fields within the JIT hash table. Note carefully the access
768 * Only writes are guarded, and the guarded fields must be updated in a
769 * specific order using atomic operations. Further, once a field is
770 * written it cannot be changed without halting all threads.
772 * The write order is:
775 * 3) chain [if necessary]
777 * This mutex also guards both read and write of curJitTableEntries.
779 pthread_mutex_t tableLock;
781 /* The JIT hash table. Note that for access speed, copies of this pointer
782 * are stored in each thread. */
783 struct JitEntry *pJitEntryTable;
785 /* Array of compilation trigger threshold counters */
786 unsigned char *pProfTable;
788 /* Trace profiling counters */
789 struct JitTraceProfCounters *pJitTraceProfCounters;
791 /* Copy of pProfTable used for temporarily disabling the Jit */
792 unsigned char *pProfTableCopy;
794 /* Size of JIT hash table in entries. Must be a power of 2 */
795 unsigned int jitTableSize;
797 /* Mask used in hash function for JitTable. Should be jitTableSize-1 */
798 unsigned int jitTableMask;
800 /* How many entries in the JitEntryTable are in use */
801 unsigned int jitTableEntriesUsed;
803 /* Bytes allocated for the code cache */
804 unsigned int codeCacheSize;
806 /* Trigger for trace selection */
807 unsigned short threshold;
809 /* JIT Compiler Control */
810 bool haltCompilerThread;
812 bool methodTraceSupport;
814 Thread* compilerThread;
815 pthread_t compilerHandle;
816 pthread_mutex_t compilerLock;
817 pthread_mutex_t compilerICPatchLock;
818 pthread_cond_t compilerQueueActivity;
819 pthread_cond_t compilerQueueEmpty;
820 volatile int compilerQueueLength;
821 int compilerHighWater;
822 int compilerWorkEnqueueIndex;
823 int compilerWorkDequeueIndex;
824 int compilerICPatchIndex;
826 /* JIT internal stats */
827 int compilerMaxQueued;
828 int translationChains;
830 /* Compiled code cache */
834 * This is used to store the base address of an in-flight compilation whose
835 * class object pointers have been calculated to populate literal pool.
836 * Once the compiler thread has changed its status to VM_WAIT, we cannot
837 * guarantee whether GC has happened before the code address has been
838 * installed to the JIT table. Because of that, this field can only
839 * been cleared/overwritten by the compiler thread if it is in the
840 * THREAD_RUNNING state or in a safe point.
842 void *inflightBaseAddr;
844 /* Translation cache version (protected by compilerLock */
847 /* Bytes used by the code templates */
848 unsigned int templateSize;
850 /* Bytes already used in the code cache */
851 unsigned int codeCacheByteUsed;
853 /* Number of installed compilations in the cache */
854 unsigned int numCompilations;
856 /* Flag to indicate that the code cache is full */
860 unsigned int pageSizeMask;
862 /* Lock to change the protection type of the code cache */
863 pthread_mutex_t codeCacheProtectionLock;
865 /* Number of times that the code cache has been reset */
866 int numCodeCacheReset;
868 /* Number of times that the code cache reset request has been delayed */
869 int numCodeCacheResetDelayed;
871 /* true/false: compile/reject opcodes specified in the -Xjitop list */
872 bool includeSelectedOp;
874 /* true/false: compile/reject methods specified in the -Xjitmethod list */
875 bool includeSelectedMethod;
877 /* true/false: compile/reject traces with offset specified in the -Xjitoffset list */
878 bool includeSelectedOffset;
880 /* Disable JIT for selected opcodes - one bit for each opcode */
881 char opList[(kNumPackedOpcodes+7)/8];
883 /* Disable JIT for selected methods */
884 HashTable *methodTable;
886 /* Disable JIT for selected classes */
887 HashTable *classTable;
889 /* Disable JIT for selected offsets */
890 unsigned int pcTable[COMPILER_PC_OFFSET_SIZE];
891 int num_entries_pcTable;
893 /* Flag to dump all compiled code */
896 /* Flag to dump compiled binary code in bytes */
899 /* Per-process debug flag toggled when receiving a SIGUSR2 */
900 bool receivedSIGUSR2;
902 /* Trace profiling mode */
903 TraceProfilingModes profileMode;
905 /* Periodic trace profiling countdown timer */
906 int profileCountdown;
908 /* Vector to disable selected optimizations */
911 /* Table to track the overall and trace statistics of hot methods */
912 HashTable* methodStatsTable;
914 /* Filter method compilation blacklist with call-graph information */
917 /* New translation chain has been set up */
918 volatile bool hasNewChain;
920 #if defined(WITH_SELF_VERIFICATION)
921 /* Spin when error is detected, volatile so GDB can reset it */
922 volatile bool selfVerificationSpin;
925 /* Framework or stand-alone? */
926 bool runningInAndroidFramework;
928 /* Framework callback happened? */
929 bool alreadyEnabledViaFramework;
931 /* Framework requests to disable the JIT for good */
934 #if defined(SIGNATURE_BREAKPOINT)
935 /* Signature breakpoint */
936 u4 signatureBreakpointSize; // # of words
937 u4 *signatureBreakpoint; // Signature content
940 #if defined(WITH_JIT_TUNING)
941 /* Performance tuning counters */
942 int addrLookupsFound;
943 int addrLookupsNotFound;
944 int noChainExit[kNoChainExitLast];
947 int invokeMonomorphic;
948 int invokePolymorphic;
950 int invokeMonoGetterInlined;
951 int invokeMonoSetterInlined;
952 int invokePolyGetterInlined;
953 int invokePolySetterInlined;
960 int codeCachePatches;
961 int numCompilerThreadBlockGC;
963 u8 compilerThreadBlockGCStart;
964 u8 compilerThreadBlockGCTime;
965 u8 maxCompilerThreadBlockGCTime;
968 #if defined(ARCH_IA32)
969 JitOptLevel optLevel;
972 /* Place arrays at the end to ease the display in gdb sessions */
974 /* Work order queue for compilations */
975 CompilerWorkOrder compilerWorkQueue[COMPILER_WORK_QUEUE_SIZE];
977 /* Work order queue for predicted chain patching */
978 ICPatchWorkOrder compilerICPatchQueue[COMPILER_IC_PATCH_QUEUE_SIZE];
981 extern struct DvmJitGlobals gDvmJit;
983 #if defined(WITH_JIT_TUNING)
984 extern int gDvmICHitCount;
989 struct DvmJniGlobals {
994 // Provide backwards compatibility for pre-ICS apps on ICS.
995 bool workAroundAppJniBugs;
997 // Debugging help for third-party developers. Similar to -Xjnitrace.
998 bool logThirdPartyJni;
1000 // We only support a single JavaVM per process.
1004 extern struct DvmJniGlobals gDvmJni;
1006 #endif // DALVIK_GLOBALS_H_