Globals.h revision 8552f4498a720a6fcb34ebab69d6e3c34bee491d
1/* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 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 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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. 15 */ 16 17/* 18 * Variables with library scope. 19 * 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. 24 * 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. 28 */ 29#ifndef _DALVIK_GLOBALS 30#define _DALVIK_GLOBALS 31 32#include <stdarg.h> 33#include <pthread.h> 34 35#define MAX_BREAKPOINTS 20 /* used for a debugger optimization */ 36 37/* private structures */ 38typedef struct GcHeap GcHeap; 39typedef struct BreakpointSet BreakpointSet; 40typedef struct InlineSub InlineSub; 41 42/* 43 * One of these for each -ea/-da/-esa/-dsa on the command line. 44 */ 45typedef struct AssertionControl { 46 char* pkgOrClass; /* package/class string, or NULL for esa/dsa */ 47 int pkgOrClassLen; /* string length, for quick compare */ 48 bool enable; /* enable or disable */ 49 bool isPackage; /* string ended with "..."? */ 50} AssertionControl; 51 52/* 53 * Execution mode, e.g. interpreter vs. JIT. 54 */ 55typedef enum ExecutionMode { 56 kExecutionModeUnknown = 0, 57 kExecutionModeInterpPortable, 58 kExecutionModeInterpFast, 59#if defined(WITH_JIT) 60 kExecutionModeJit, 61#endif 62} ExecutionMode; 63 64/* 65 * All fields are initialized to zero. 66 * 67 * Storage allocated here must be freed by a subsystem shutdown function or 68 * from within freeGlobals(). 69 */ 70struct DvmGlobals { 71 /* 72 * Some options from the command line or environment. 73 */ 74 char* bootClassPathStr; 75 char* classPathStr; 76 77 unsigned int heapSizeStart; 78 unsigned int heapSizeMax; 79 unsigned int stackSize; 80 81 bool verboseGc; 82 bool verboseJni; 83 bool verboseClass; 84 bool verboseShutdown; 85 86 bool jdwpAllowed; // debugging allowed for this process? 87 bool jdwpConfigured; // has debugging info been provided? 88 int jdwpTransport; 89 bool jdwpServer; 90 char* jdwpHost; 91 int jdwpPort; 92 bool jdwpSuspend; 93 94 /* use wall clock as method profiler clock source? */ 95 bool profilerWallClock; 96 97 /* 98 * Lock profiling threshold value in milliseconds. Acquires that 99 * exceed threshold are logged. Acquires within the threshold are 100 * logged with a probability of $\frac{time}{threshold}$ . If the 101 * threshold is unset no additional logging occurs. 102 */ 103 u4 lockProfThreshold; 104 105 int (*vfprintfHook)(FILE*, const char*, va_list); 106 void (*exitHook)(int); 107 void (*abortHook)(void); 108 109 int jniGrefLimit; // 0 means no limit 110 char* jniTrace; 111 bool reduceSignals; 112 bool noQuitHandler; 113 bool verifyDexChecksum; 114 char* stackTraceFile; // for SIGQUIT-inspired output 115 116 bool logStdio; 117 118 DexOptimizerMode dexOptMode; 119 DexClassVerifyMode classVerifyMode; 120 121 bool dexOptForSmp; 122 123 /* 124 * GC option flags. 125 */ 126 bool preciseGc; 127 bool preVerify; 128 bool postVerify; 129 bool generateRegisterMaps; 130 bool concurrentMarkSweep; 131 bool verifyCardTable; 132 133 int assertionCtrlCount; 134 AssertionControl* assertionCtrl; 135 136 ExecutionMode executionMode; 137 138 /* 139 * VM init management. 140 */ 141 bool initializing; 142 int initExceptionCount; 143 bool optimizing; 144 145 /* 146 * java.lang.System properties set from the command line. 147 */ 148 int numProps; 149 int maxProps; 150 char** propList; 151 152 /* 153 * Where the VM goes to find system classes. 154 */ 155 ClassPathEntry* bootClassPath; 156 /* used by the DEX optimizer to load classes from an unfinished DEX */ 157 DvmDex* bootClassPathOptExtra; 158 bool optimizingBootstrapClass; 159 160 /* 161 * Loaded classes, hashed by class name. Each entry is a ClassObject*, 162 * allocated in GC space. 163 */ 164 HashTable* loadedClasses; 165 166 /* 167 * Value for the next class serial number to be assigned. This is 168 * incremented as we load classes. Failed loads and races may result 169 * in some numbers being skipped, and the serial number is not 170 * guaranteed to start at 1, so the current value should not be used 171 * as a count of loaded classes. 172 */ 173 volatile int classSerialNumber; 174 175 /* 176 * Classes with a low classSerialNumber are probably in the zygote, and 177 * their InitiatingLoaderList is not used, to promote sharing. The list is 178 * kept here instead. 179 */ 180 InitiatingLoaderList* initiatingLoaderList; 181 182 /* 183 * Interned strings. 184 */ 185 186 /* A mutex that guards access to the interned string tables. */ 187 pthread_mutex_t internLock; 188 189 /* Hash table of strings interned by the user. */ 190 HashTable* internedStrings; 191 192 /* Hash table of strings interned by the class loader. */ 193 HashTable* literalStrings; 194 195 /* 196 * Quick lookups for popular classes used internally. 197 */ 198 ClassObject* classJavaLangClass; 199 ClassObject* classJavaLangClassArray; 200 ClassObject* classJavaLangError; 201 ClassObject* classJavaLangObject; 202 ClassObject* classJavaLangObjectArray; 203 ClassObject* classJavaLangRuntimeException; 204 ClassObject* classJavaLangString; 205 ClassObject* classJavaLangThread; 206 ClassObject* classJavaLangVMThread; 207 ClassObject* classJavaLangThreadGroup; 208 ClassObject* classJavaLangThrowable; 209 ClassObject* classJavaLangStackOverflowError; 210 ClassObject* classJavaLangStackTraceElement; 211 ClassObject* classJavaLangStackTraceElementArray; 212 ClassObject* classJavaLangAnnotationAnnotationArray; 213 ClassObject* classJavaLangAnnotationAnnotationArrayArray; 214 ClassObject* classJavaLangReflectAccessibleObject; 215 ClassObject* classJavaLangReflectConstructor; 216 ClassObject* classJavaLangReflectConstructorArray; 217 ClassObject* classJavaLangReflectField; 218 ClassObject* classJavaLangReflectFieldArray; 219 ClassObject* classJavaLangReflectMethod; 220 ClassObject* classJavaLangReflectMethodArray; 221 ClassObject* classJavaLangReflectProxy; 222 ClassObject* classJavaLangExceptionInInitializerError; 223 ClassObject* classJavaLangRefPhantomReference; 224 ClassObject* classJavaLangRefReference; 225 ClassObject* classJavaNioReadWriteDirectByteBuffer; 226 ClassObject* classJavaSecurityAccessController; 227 ClassObject* classOrgApacheHarmonyLangAnnotationAnnotationFactory; 228 ClassObject* classOrgApacheHarmonyLangAnnotationAnnotationMember; 229 ClassObject* classOrgApacheHarmonyLangAnnotationAnnotationMemberArray; 230 231 /* synthetic classes for arrays of primitives */ 232 ClassObject* classArrayBoolean; 233 ClassObject* classArrayChar; 234 ClassObject* classArrayFloat; 235 ClassObject* classArrayDouble; 236 ClassObject* classArrayByte; 237 ClassObject* classArrayShort; 238 ClassObject* classArrayInt; 239 ClassObject* classArrayLong; 240 241 /* method offsets - Object */ 242 int voffJavaLangObject_equals; 243 int voffJavaLangObject_hashCode; 244 int voffJavaLangObject_toString; 245 int voffJavaLangObject_finalize; 246 247 /* field offsets - Class */ 248 int offJavaLangClass_pd; 249 250 /* field offsets - String */ 251 int javaLangStringReady; /* 0=not init, 1=ready, -1=initing */ 252 int offJavaLangString_value; 253 int offJavaLangString_count; 254 int offJavaLangString_offset; 255 int offJavaLangString_hashCode; 256 257 /* field offsets - Thread */ 258 int offJavaLangThread_vmThread; 259 int offJavaLangThread_group; 260 int offJavaLangThread_daemon; 261 int offJavaLangThread_name; 262 int offJavaLangThread_priority; 263 264 /* method offsets - Thread */ 265 int voffJavaLangThread_run; 266 267 /* field offsets - VMThread */ 268 int offJavaLangVMThread_thread; 269 int offJavaLangVMThread_vmData; 270 271 /* method offsets - ThreadGroup */ 272 int voffJavaLangThreadGroup_removeThread; 273 274 /* field offsets - Throwable */ 275 int offJavaLangThrowable_stackState; 276 int offJavaLangThrowable_cause; 277 278 /* field offsets - java.lang.reflect.* */ 279 int offJavaLangReflectAccessibleObject_flag; 280 int offJavaLangReflectConstructor_slot; 281 int offJavaLangReflectConstructor_declClass; 282 int offJavaLangReflectField_slot; 283 int offJavaLangReflectField_declClass; 284 int offJavaLangReflectMethod_slot; 285 int offJavaLangReflectMethod_declClass; 286 287 /* field offsets - java.lang.ref.Reference */ 288 int offJavaLangRefReference_referent; 289 int offJavaLangRefReference_queue; 290 int offJavaLangRefReference_queueNext; 291 int offJavaLangRefReference_pendingNext; 292 293 /* method pointers - java.lang.ref.Reference */ 294 Method* methJavaLangRefReference_enqueueInternal; 295 296 /* field offsets - java.nio.Buffer and java.nio.DirectByteBufferImpl */ 297 //int offJavaNioBuffer_capacity; 298 //int offJavaNioDirectByteBufferImpl_pointer; 299 300 /* method pointers - java.security.AccessController */ 301 volatile int javaSecurityAccessControllerReady; 302 Method* methJavaSecurityAccessController_doPrivileged[4]; 303 304 /* constructor method pointers; no vtable involved, so use Method* */ 305 Method* methJavaLangStackTraceElement_init; 306 Method* methJavaLangExceptionInInitializerError_init; 307 Method* methJavaLangRefPhantomReference_init; 308 Method* methJavaLangReflectConstructor_init; 309 Method* methJavaLangReflectField_init; 310 Method* methJavaLangReflectMethod_init; 311 Method* methOrgApacheHarmonyLangAnnotationAnnotationMember_init; 312 313 /* static method pointers - android.lang.annotation.* */ 314 Method* 315 methOrgApacheHarmonyLangAnnotationAnnotationFactory_createAnnotation; 316 317 /* direct method pointers - java.lang.reflect.Proxy */ 318 Method* methJavaLangReflectProxy_constructorPrototype; 319 320 /* field offsets - java.lang.reflect.Proxy */ 321 int offJavaLangReflectProxy_h; 322 323 /* fake native entry point method */ 324 Method* methFakeNativeEntry; 325 326 /* assorted direct buffer helpers */ 327 Method* methJavaNioReadWriteDirectByteBuffer_init; 328 int offJavaNioBuffer_capacity; 329 int offJavaNioBuffer_effectiveDirectAddress; 330 331 /* 332 * VM-synthesized primitive classes, for arrays. 333 */ 334 ClassObject* volatile primitiveClass[PRIM_MAX]; 335 336 /* 337 * Thread list. This always has at least one element in it (main), 338 * and main is always the first entry. 339 * 340 * The threadListLock is used for several things, including the thread 341 * start condition variable. Generally speaking, you must hold the 342 * threadListLock when: 343 * - adding/removing items from the list 344 * - waiting on or signaling threadStartCond 345 * - examining the Thread struct for another thread (this is to avoid 346 * one thread freeing the Thread struct while another thread is 347 * perusing it) 348 */ 349 Thread* threadList; 350 pthread_mutex_t threadListLock; 351 352 pthread_cond_t threadStartCond; 353 354 /* 355 * The thread code grabs this before suspending all threads. There 356 * are a few things that can cause a "suspend all": 357 * (1) the GC is starting; 358 * (2) the debugger has sent a "suspend all" request; 359 * (3) a thread has hit a breakpoint or exception that the debugger 360 * has marked as a "suspend all" event; 361 * (4) the SignalCatcher caught a signal that requires suspension. 362 * (5) (if implemented) the JIT needs to perform a heavyweight 363 * rearrangement of the translation cache or JitTable. 364 * 365 * Because we use "safe point" self-suspension, it is never safe to 366 * do a blocking "lock" call on this mutex -- if it has been acquired, 367 * somebody is probably trying to put you to sleep. The leading '_' is 368 * intended as a reminder that this lock is special. 369 */ 370 pthread_mutex_t _threadSuspendLock; 371 372 /* 373 * Guards Thread->suspendCount for all threads, and provides the lock 374 * for the condition variable that all suspended threads sleep on 375 * (threadSuspendCountCond). 376 * 377 * This has to be separate from threadListLock because of the way 378 * threads put themselves to sleep. 379 */ 380 pthread_mutex_t threadSuspendCountLock; 381 382 /* 383 * Suspended threads sleep on this. They should sleep on the condition 384 * variable until their "suspend count" is zero. 385 * 386 * Paired with "threadSuspendCountLock". 387 */ 388 pthread_cond_t threadSuspendCountCond; 389 390 /* 391 * Sum of all threads' suspendCount fields. The JIT needs to know if any 392 * thread is suspended. Guarded by threadSuspendCountLock. 393 */ 394 int sumThreadSuspendCount; 395 396 /* 397 * MUTEX ORDERING: when locking multiple mutexes, always grab them in 398 * this order to avoid deadlock: 399 * 400 * (1) _threadSuspendLock (use lockThreadSuspend()) 401 * (2) threadListLock (use dvmLockThreadList()) 402 * (3) threadSuspendCountLock (use lockThreadSuspendCount()) 403 */ 404 405 406 /* 407 * Thread ID bitmap. We want threads to have small integer IDs so 408 * we can use them in "thin locks". 409 */ 410 BitVector* threadIdMap; 411 412 /* 413 * Manage exit conditions. The VM exits when all non-daemon threads 414 * have exited. If the main thread returns early, we need to sleep 415 * on a condition variable. 416 */ 417 int nonDaemonThreadCount; /* must hold threadListLock to access */ 418 //pthread_mutex_t vmExitLock; 419 pthread_cond_t vmExitCond; 420 421 /* 422 * The set of DEX files loaded by custom class loaders. 423 */ 424 HashTable* userDexFiles; 425 426 /* 427 * JNI global reference table. 428 */ 429#ifdef USE_INDIRECT_REF 430 IndirectRefTable jniGlobalRefTable; 431#else 432 ReferenceTable jniGlobalRefTable; 433#endif 434 pthread_mutex_t jniGlobalRefLock; 435 int jniGlobalRefHiMark; 436 int jniGlobalRefLoMark; 437 438 /* 439 * JNI pinned object table (used for primitive arrays). 440 */ 441 ReferenceTable jniPinRefTable; 442 pthread_mutex_t jniPinRefLock; 443 444 /* 445 * Native shared library table. 446 */ 447 HashTable* nativeLibs; 448 449 /* 450 * GC heap lock. Functions like gcMalloc() acquire this before making 451 * any changes to the heap. It is held throughout garbage collection. 452 */ 453 pthread_mutex_t gcHeapLock; 454 455 /* 456 * Condition variable to queue threads waiting to retry an 457 * allocation. Signaled after a concurrent GC is completed. 458 */ 459 pthread_cond_t gcHeapCond; 460 461 /* Opaque pointer representing the heap. */ 462 GcHeap* gcHeap; 463 464 /* The card table base, modified as needed for marking cards. */ 465 u1* biasedCardTableBase; 466 467 /* 468 * Pre-allocated throwables. 469 */ 470 Object* outOfMemoryObj; 471 Object* internalErrorObj; 472 Object* noClassDefFoundErrorObj; 473 474 /* Monitor list, so we can free them */ 475 /*volatile*/ Monitor* monitorList; 476 477 /* Monitor for Thread.sleep() implementation */ 478 Monitor* threadSleepMon; 479 480 /* set when we create a second heap inside the zygote */ 481 bool newZygoteHeapAllocated; 482 483 /* 484 * TLS keys. 485 */ 486 pthread_key_t pthreadKeySelf; /* Thread*, for dvmThreadSelf */ 487 488 /* 489 * JNI allows you to have multiple VMs, but we limit ourselves to 1, 490 * so "vmList" is really just a pointer to the one and only VM. 491 */ 492 JavaVM* vmList; 493 494 /* 495 * Cache results of "A instanceof B". 496 */ 497 AtomicCache* instanceofCache; 498 499 /* instruction width table, used for optimization and verification */ 500 InstructionWidth* instrWidth; 501 /* instruction flags table, used for verification */ 502 InstructionFlags* instrFlags; 503 /* instruction format table, used for verification */ 504 InstructionFormat* instrFormat; 505 506 /* inline substitution table, used during optimization */ 507 InlineSub* inlineSubs; 508 509 /* 510 * Bootstrap class loader linear allocator. 511 */ 512 LinearAllocHdr* pBootLoaderAlloc; 513 514 515 /* 516 * Heap worker thread. 517 */ 518 bool heapWorkerInitialized; 519 bool heapWorkerReady; 520 bool haltHeapWorker; 521 pthread_t heapWorkerHandle; 522 pthread_mutex_t heapWorkerLock; 523 pthread_cond_t heapWorkerCond; 524 pthread_cond_t heapWorkerIdleCond; 525 pthread_mutex_t heapWorkerListLock; 526 527 /* 528 * Compute some stats on loaded classes. 529 */ 530 int numLoadedClasses; 531 int numDeclaredMethods; 532 int numDeclaredInstFields; 533 int numDeclaredStaticFields; 534 535 /* when using a native debugger, set this to suppress watchdog timers */ 536 bool nativeDebuggerActive; 537 538 /* 539 * JDWP debugger support. 540 * 541 * Note "debuggerActive" is accessed from mterp, so its storage size and 542 * meaning must not be changed without updating the assembly sources. 543 */ 544 bool debuggerConnected; /* debugger or DDMS is connected */ 545 u1 debuggerActive; /* debugger is making requests */ 546 JdwpState* jdwpState; 547 548 /* 549 * Registry of objects known to the debugger. 550 */ 551 HashTable* dbgRegistry; 552 553 /* 554 * Debugger breakpoint table. 555 */ 556 BreakpointSet* breakpointSet; 557 558 /* 559 * Single-step control struct. We currently only allow one thread to 560 * be single-stepping at a time, which is all that really makes sense, 561 * but it's possible we may need to expand this to be per-thread. 562 */ 563 StepControl stepControl; 564 565 /* 566 * DDM features embedded in the VM. 567 */ 568 bool ddmThreadNotification; 569 570 /* 571 * Zygote (partially-started process) support 572 */ 573 bool zygote; 574 575 /* 576 * Used for tracking allocations that we report to DDMS. When the feature 577 * is enabled (through a DDMS request) the "allocRecords" pointer becomes 578 * non-NULL. 579 */ 580 pthread_mutex_t allocTrackerLock; 581 AllocRecord* allocRecords; 582 int allocRecordHead; /* most-recently-added entry */ 583 int allocRecordCount; /* #of valid entries */ 584 585#ifdef WITH_ALLOC_LIMITS 586 /* set on first use of an alloc limit, never cleared */ 587 bool checkAllocLimits; 588 /* allocation limit, for setGlobalAllocationLimit() regression testing */ 589 int allocationLimit; 590#endif 591 592#ifdef WITH_DEADLOCK_PREDICTION 593 /* global lock on history tree accesses */ 594 pthread_mutex_t deadlockHistoryLock; 595 596 enum { kDPOff=0, kDPWarn, kDPErr, kDPAbort } deadlockPredictMode; 597#endif 598 599 /* 600 * When a profiler is enabled, this is incremented. Distinct profilers 601 * include "dmtrace" method tracing, emulator method tracing, and 602 * possibly instruction counting. 603 * 604 * The purpose of this is to have a single value that the interpreter 605 * can check to see if any profiling activity is enabled. 606 */ 607 volatile int activeProfilers; 608 609 /* 610 * State for method-trace profiling. 611 */ 612 MethodTraceState methodTrace; 613 614 /* 615 * State for emulator tracing. 616 */ 617 void* emulatorTracePage; 618 int emulatorTraceEnableCount; 619 620 /* 621 * Global state for memory allocation profiling. 622 */ 623 AllocProfState allocProf; 624 625 /* 626 * Pointers to the original methods for things that have been inlined. 627 * This makes it easy for us to output method entry/exit records for 628 * the method calls we're not actually making. (Used by method 629 * profiling.) 630 */ 631 Method** inlinedMethods; 632 633 /* 634 * Dalvik instruction counts (256 entries). 635 */ 636 int* executedInstrCounts; 637 bool instructionCountEnableCount; 638 639 /* 640 * Signal catcher thread (for SIGQUIT). 641 */ 642 pthread_t signalCatcherHandle; 643 bool haltSignalCatcher; 644 645 /* 646 * Stdout/stderr conversion thread. 647 */ 648 bool haltStdioConverter; 649 bool stdioConverterReady; 650 pthread_t stdioConverterHandle; 651 pthread_mutex_t stdioConverterLock; 652 pthread_cond_t stdioConverterCond; 653 654 /* 655 * pid of the system_server process. We track it so that when system server 656 * crashes the Zygote process will be killed and restarted. 657 */ 658 pid_t systemServerPid; 659 660 int kernelGroupScheduling; 661 662//#define COUNT_PRECISE_METHODS 663#ifdef COUNT_PRECISE_METHODS 664 PointerSet* preciseMethods; 665#endif 666 667 /* some RegisterMap statistics, useful during development */ 668 void* registerMapStats; 669}; 670 671extern struct DvmGlobals gDvm; 672 673#if defined(WITH_JIT) 674 675/* 676 * Exiting the compiled code w/o chaining will incur overhead to look up the 677 * target in the code cache which is extra work only when JIT is enabled. So 678 * we want to monitor it closely to make sure we don't have performance bugs. 679 */ 680typedef enum NoChainExits { 681 kInlineCacheMiss = 0, 682 kCallsiteInterpreted, 683 kSwitchOverflow, 684 kHeavyweightMonitor, 685 kNoChainExitLast, 686} NoChainExits; 687 688/* 689 * JIT-specific global state 690 */ 691struct DvmJitGlobals { 692 /* 693 * Guards writes to Dalvik PC (dPC), translated code address (codeAddr) and 694 * chain fields within the JIT hash table. Note carefully the access 695 * mechanism. 696 * Only writes are guarded, and the guarded fields must be updated in a 697 * specific order using atomic operations. Further, once a field is 698 * written it cannot be changed without halting all threads. 699 * 700 * The write order is: 701 * 1) codeAddr 702 * 2) dPC 703 * 3) chain [if necessary] 704 * 705 * This mutex also guards both read and write of curJitTableEntries. 706 */ 707 pthread_mutex_t tableLock; 708 709 /* The JIT hash table. Note that for access speed, copies of this pointer 710 * are stored in each thread. */ 711 struct JitEntry *pJitEntryTable; 712 713 /* Array of profile threshold counters */ 714 unsigned char *pProfTable; 715 716 /* Copy of pProfTable used for temporarily disabling the Jit */ 717 unsigned char *pProfTableCopy; 718 719 /* Size of JIT hash table in entries. Must be a power of 2 */ 720 unsigned int jitTableSize; 721 722 /* Mask used in hash function for JitTable. Should be jitTableSize-1 */ 723 unsigned int jitTableMask; 724 725 /* How many entries in the JitEntryTable are in use */ 726 unsigned int jitTableEntriesUsed; 727 728 /* Bytes allocated for the code cache */ 729 unsigned int codeCacheSize; 730 731 /* Trigger for trace selection */ 732 unsigned short threshold; 733 734 /* JIT Compiler Control */ 735 bool haltCompilerThread; 736 bool blockingMode; 737 pthread_t compilerHandle; 738 pthread_mutex_t compilerLock; 739 pthread_mutex_t compilerICPatchLock; 740 pthread_cond_t compilerQueueActivity; 741 pthread_cond_t compilerQueueEmpty; 742 volatile int compilerQueueLength; 743 int compilerHighWater; 744 int compilerWorkEnqueueIndex; 745 int compilerWorkDequeueIndex; 746 int compilerICPatchIndex; 747 748 /* JIT internal stats */ 749 int compilerMaxQueued; 750 int translationChains; 751 752 /* Compiled code cache */ 753 void* codeCache; 754 755 /* Bytes used by the code templates */ 756 unsigned int templateSize; 757 758 /* Bytes already used in the code cache */ 759 unsigned int codeCacheByteUsed; 760 761 /* Number of installed compilations in the cache */ 762 unsigned int numCompilations; 763 764 /* Flag to indicate that the code cache is full */ 765 bool codeCacheFull; 766 767 /* Page size - 1 */ 768 unsigned int pageSizeMask; 769 770 /* Lock to change the protection type of the code cache */ 771 pthread_mutex_t codeCacheProtectionLock; 772 773 /* Number of times that the code cache has been reset */ 774 int numCodeCacheReset; 775 776 /* Number of times that the code cache reset request has been delayed */ 777 int numCodeCacheResetDelayed; 778 779 /* true/false: compile/reject opcodes specified in the -Xjitop list */ 780 bool includeSelectedOp; 781 782 /* true/false: compile/reject methods specified in the -Xjitmethod list */ 783 bool includeSelectedMethod; 784 785 /* Disable JIT for selected opcodes - one bit for each opcode */ 786 char opList[32]; 787 788 /* Disable JIT for selected methods */ 789 HashTable *methodTable; 790 791 /* Flag to dump all compiled code */ 792 bool printMe; 793 794 /* Flag to count trace execution */ 795 bool profile; 796 797 /* Vector to disable selected optimizations */ 798 int disableOpt; 799 800 /* Table to track the overall and trace statistics of hot methods */ 801 HashTable* methodStatsTable; 802 803 /* Filter method compilation blacklist with call-graph information */ 804 bool checkCallGraph; 805 806 /* New translation chain has been set up */ 807 volatile bool hasNewChain; 808 809#if defined(WITH_SELF_VERIFICATION) 810 /* Spin when error is detected, volatile so GDB can reset it */ 811 volatile bool selfVerificationSpin; 812#endif 813 814 /* Framework or stand-alone? */ 815 bool runningInAndroidFramework; 816 817 /* Framework callback happened? */ 818 bool alreadyEnabledViaFramework; 819 820 /* Framework requests to disable the JIT for good */ 821 bool disableJit; 822 823#if defined(SIGNATURE_BREAKPOINT) 824 /* Signature breakpoint */ 825 u4 signatureBreakpointSize; // # of words 826 u4 *signatureBreakpoint; // Signature content 827#endif 828 829#if defined(WITH_JIT_TUNING) 830 /* Performance tuning counters */ 831 int addrLookupsFound; 832 int addrLookupsNotFound; 833 int noChainExit[kNoChainExitLast]; 834 int normalExit; 835 int puntExit; 836 int invokeMonomorphic; 837 int invokePolymorphic; 838 int invokeNative; 839 int invokeMonoGetterInlined; 840 int invokeMonoSetterInlined; 841 int invokePolyGetterInlined; 842 int invokePolySetterInlined; 843 int returnOp; 844 int icPatchInit; 845 int icPatchLockFree; 846 int icPatchQueued; 847 int icPatchRejected; 848 int icPatchDropped; 849 u8 jitTime; 850 int codeCachePatches; 851#endif 852 853 /* Place arrays at the end to ease the display in gdb sessions */ 854 855 /* Work order queue for compilations */ 856 CompilerWorkOrder compilerWorkQueue[COMPILER_WORK_QUEUE_SIZE]; 857 858 /* Work order queue for predicted chain patching */ 859 ICPatchWorkOrder compilerICPatchQueue[COMPILER_IC_PATCH_QUEUE_SIZE]; 860}; 861 862extern struct DvmJitGlobals gDvmJit; 863 864#if defined(WITH_JIT_TUNING) 865extern int gDvmICHitCount; 866#endif 867 868#endif 869 870#endif /*_DALVIK_GLOBALS*/ 871