Globals.h revision 675b642510ed79e8a7a3f23126dfac7679fd65b9
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 /* method offsets - ClassLoader */ 279 int voffJavaLangClassLoader_loadClass; 280 281 /* field offsets - java.lang.reflect.* */ 282 int offJavaLangReflectAccessibleObject_flag; 283 int offJavaLangReflectConstructor_slot; 284 int offJavaLangReflectConstructor_declClass; 285 int offJavaLangReflectField_slot; 286 int offJavaLangReflectField_declClass; 287 int offJavaLangReflectMethod_slot; 288 int offJavaLangReflectMethod_declClass; 289 290 /* field offsets - java.lang.ref.Reference */ 291 int offJavaLangRefReference_referent; 292 int offJavaLangRefReference_queue; 293 int offJavaLangRefReference_queueNext; 294 int offJavaLangRefReference_pendingNext; 295 296 /* method pointers - java.lang.ref.Reference */ 297 Method* methJavaLangRefReference_enqueueInternal; 298 299 /* method pointers - java.security.AccessController */ 300 volatile int javaSecurityAccessControllerReady; 301 Method* methJavaSecurityAccessController_doPrivileged[4]; 302 303 /* constructor method pointers; no vtable involved, so use Method* */ 304 Method* methJavaLangStackTraceElement_init; 305 Method* methJavaLangExceptionInInitializerError_init; 306 Method* methJavaLangRefPhantomReference_init; 307 Method* methJavaLangReflectConstructor_init; 308 Method* methJavaLangReflectField_init; 309 Method* methJavaLangReflectMethod_init; 310 Method* methOrgApacheHarmonyLangAnnotationAnnotationMember_init; 311 312 /* static method pointers - android.lang.annotation.* */ 313 Method* 314 methOrgApacheHarmonyLangAnnotationAnnotationFactory_createAnnotation; 315 316 /* direct method pointers - java.lang.reflect.Proxy */ 317 Method* methJavaLangReflectProxy_constructorPrototype; 318 319 /* field offsets - java.lang.reflect.Proxy */ 320 int offJavaLangReflectProxy_h; 321 322 /* fake native entry point method */ 323 Method* methFakeNativeEntry; 324 325 /* assorted direct buffer helpers */ 326 Method* methJavaNioReadWriteDirectByteBuffer_init; 327 int offJavaNioBuffer_capacity; 328 int offJavaNioBuffer_effectiveDirectAddress; 329 330 /* 331 * VM-synthesized primitive classes, for arrays. 332 */ 333 ClassObject* volatile primitiveClass[PRIM_MAX]; 334 335 /* 336 * Thread list. This always has at least one element in it (main), 337 * and main is always the first entry. 338 * 339 * The threadListLock is used for several things, including the thread 340 * start condition variable. Generally speaking, you must hold the 341 * threadListLock when: 342 * - adding/removing items from the list 343 * - waiting on or signaling threadStartCond 344 * - examining the Thread struct for another thread (this is to avoid 345 * one thread freeing the Thread struct while another thread is 346 * perusing it) 347 */ 348 Thread* threadList; 349 pthread_mutex_t threadListLock; 350 351 pthread_cond_t threadStartCond; 352 353 /* 354 * The thread code grabs this before suspending all threads. There 355 * are a few things that can cause a "suspend all": 356 * (1) the GC is starting; 357 * (2) the debugger has sent a "suspend all" request; 358 * (3) a thread has hit a breakpoint or exception that the debugger 359 * has marked as a "suspend all" event; 360 * (4) the SignalCatcher caught a signal that requires suspension. 361 * (5) (if implemented) the JIT needs to perform a heavyweight 362 * rearrangement of the translation cache or JitTable. 363 * 364 * Because we use "safe point" self-suspension, it is never safe to 365 * do a blocking "lock" call on this mutex -- if it has been acquired, 366 * somebody is probably trying to put you to sleep. The leading '_' is 367 * intended as a reminder that this lock is special. 368 */ 369 pthread_mutex_t _threadSuspendLock; 370 371 /* 372 * Guards Thread->suspendCount for all threads, and provides the lock 373 * for the condition variable that all suspended threads sleep on 374 * (threadSuspendCountCond). 375 * 376 * This has to be separate from threadListLock because of the way 377 * threads put themselves to sleep. 378 */ 379 pthread_mutex_t threadSuspendCountLock; 380 381 /* 382 * Suspended threads sleep on this. They should sleep on the condition 383 * variable until their "suspend count" is zero. 384 * 385 * Paired with "threadSuspendCountLock". 386 */ 387 pthread_cond_t threadSuspendCountCond; 388 389 /* 390 * Sum of all threads' suspendCount fields. The JIT needs to know if any 391 * thread is suspended. Guarded by threadSuspendCountLock. 392 */ 393 int sumThreadSuspendCount; 394 395 /* 396 * MUTEX ORDERING: when locking multiple mutexes, always grab them in 397 * this order to avoid deadlock: 398 * 399 * (1) _threadSuspendLock (use lockThreadSuspend()) 400 * (2) threadListLock (use dvmLockThreadList()) 401 * (3) threadSuspendCountLock (use lockThreadSuspendCount()) 402 */ 403 404 405 /* 406 * Thread ID bitmap. We want threads to have small integer IDs so 407 * we can use them in "thin locks". 408 */ 409 BitVector* threadIdMap; 410 411 /* 412 * Manage exit conditions. The VM exits when all non-daemon threads 413 * have exited. If the main thread returns early, we need to sleep 414 * on a condition variable. 415 */ 416 int nonDaemonThreadCount; /* must hold threadListLock to access */ 417 //pthread_mutex_t vmExitLock; 418 pthread_cond_t vmExitCond; 419 420 /* 421 * The set of DEX files loaded by custom class loaders. 422 */ 423 HashTable* userDexFiles; 424 425 /* 426 * JNI global reference table. 427 */ 428#ifdef USE_INDIRECT_REF 429 IndirectRefTable jniGlobalRefTable; 430#else 431 ReferenceTable jniGlobalRefTable; 432#endif 433 pthread_mutex_t jniGlobalRefLock; 434 int jniGlobalRefHiMark; 435 int jniGlobalRefLoMark; 436 437 /* 438 * JNI pinned object table (used for primitive arrays). 439 */ 440 ReferenceTable jniPinRefTable; 441 pthread_mutex_t jniPinRefLock; 442 443 /* 444 * Native shared library table. 445 */ 446 HashTable* nativeLibs; 447 448 /* 449 * GC heap lock. Functions like gcMalloc() acquire this before making 450 * any changes to the heap. It is held throughout garbage collection. 451 */ 452 pthread_mutex_t gcHeapLock; 453 454 /* 455 * Condition variable to queue threads waiting to retry an 456 * allocation. Signaled after a concurrent GC is completed. 457 */ 458 pthread_cond_t gcHeapCond; 459 460 /* Opaque pointer representing the heap. */ 461 GcHeap* gcHeap; 462 463 /* The card table base, modified as needed for marking cards. */ 464 u1* biasedCardTableBase; 465 466 /* 467 * Pre-allocated throwables. 468 */ 469 Object* outOfMemoryObj; 470 Object* internalErrorObj; 471 Object* noClassDefFoundErrorObj; 472 473 /* Monitor list, so we can free them */ 474 /*volatile*/ Monitor* monitorList; 475 476 /* Monitor for Thread.sleep() implementation */ 477 Monitor* threadSleepMon; 478 479 /* set when we create a second heap inside the zygote */ 480 bool newZygoteHeapAllocated; 481 482 /* 483 * TLS keys. 484 */ 485 pthread_key_t pthreadKeySelf; /* Thread*, for dvmThreadSelf */ 486 487 /* 488 * JNI allows you to have multiple VMs, but we limit ourselves to 1, 489 * so "vmList" is really just a pointer to the one and only VM. 490 */ 491 JavaVM* vmList; 492 493 /* 494 * Cache results of "A instanceof B". 495 */ 496 AtomicCache* instanceofCache; 497 498 /* inline substitution table, used during optimization */ 499 InlineSub* inlineSubs; 500 501 /* 502 * Bootstrap class loader linear allocator. 503 */ 504 LinearAllocHdr* pBootLoaderAlloc; 505 506 507 /* 508 * Heap worker thread. 509 */ 510 bool heapWorkerInitialized; 511 bool heapWorkerReady; 512 bool haltHeapWorker; 513 pthread_t heapWorkerHandle; 514 pthread_mutex_t heapWorkerLock; 515 pthread_cond_t heapWorkerCond; 516 pthread_cond_t heapWorkerIdleCond; 517 pthread_mutex_t heapWorkerListLock; 518 519 /* 520 * Compute some stats on loaded classes. 521 */ 522 int numLoadedClasses; 523 int numDeclaredMethods; 524 int numDeclaredInstFields; 525 int numDeclaredStaticFields; 526 527 /* when using a native debugger, set this to suppress watchdog timers */ 528 bool nativeDebuggerActive; 529 530 /* 531 * JDWP debugger support. 532 * 533 * Note "debuggerActive" is accessed from mterp, so its storage size and 534 * meaning must not be changed without updating the assembly sources. 535 */ 536 bool debuggerConnected; /* debugger or DDMS is connected */ 537 u1 debuggerActive; /* debugger is making requests */ 538 JdwpState* jdwpState; 539 540 /* 541 * Registry of objects known to the debugger. 542 */ 543 HashTable* dbgRegistry; 544 545 /* 546 * Debugger breakpoint table. 547 */ 548 BreakpointSet* breakpointSet; 549 550 /* 551 * Single-step control struct. We currently only allow one thread to 552 * be single-stepping at a time, which is all that really makes sense, 553 * but it's possible we may need to expand this to be per-thread. 554 */ 555 StepControl stepControl; 556 557 /* 558 * DDM features embedded in the VM. 559 */ 560 bool ddmThreadNotification; 561 562 /* 563 * Zygote (partially-started process) support 564 */ 565 bool zygote; 566 567 /* 568 * Used for tracking allocations that we report to DDMS. When the feature 569 * is enabled (through a DDMS request) the "allocRecords" pointer becomes 570 * non-NULL. 571 */ 572 pthread_mutex_t allocTrackerLock; 573 AllocRecord* allocRecords; 574 int allocRecordHead; /* most-recently-added entry */ 575 int allocRecordCount; /* #of valid entries */ 576 577#ifdef WITH_DEADLOCK_PREDICTION 578 /* global lock on history tree accesses */ 579 pthread_mutex_t deadlockHistoryLock; 580 581 enum { kDPOff=0, kDPWarn, kDPErr, kDPAbort } deadlockPredictMode; 582#endif 583 584 /* 585 * When a profiler is enabled, this is incremented. Distinct profilers 586 * include "dmtrace" method tracing, emulator method tracing, and 587 * possibly instruction counting. 588 * 589 * The purpose of this is to have a single value that the interpreter 590 * can check to see if any profiling activity is enabled. 591 */ 592 volatile int activeProfilers; 593 594 /* 595 * State for method-trace profiling. 596 */ 597 MethodTraceState methodTrace; 598 599 /* 600 * State for emulator tracing. 601 */ 602 void* emulatorTracePage; 603 int emulatorTraceEnableCount; 604 605 /* 606 * Global state for memory allocation profiling. 607 */ 608 AllocProfState allocProf; 609 610 /* 611 * Pointers to the original methods for things that have been inlined. 612 * This makes it easy for us to output method entry/exit records for 613 * the method calls we're not actually making. (Used by method 614 * profiling.) 615 */ 616 Method** inlinedMethods; 617 618 /* 619 * Dalvik instruction counts (kNumDalvikInstructions entries). 620 */ 621 int* executedInstrCounts; 622 int instructionCountEnableCount; 623 624 /* 625 * Signal catcher thread (for SIGQUIT). 626 */ 627 pthread_t signalCatcherHandle; 628 bool haltSignalCatcher; 629 630 /* 631 * Stdout/stderr conversion thread. 632 */ 633 bool haltStdioConverter; 634 bool stdioConverterReady; 635 pthread_t stdioConverterHandle; 636 pthread_mutex_t stdioConverterLock; 637 pthread_cond_t stdioConverterCond; 638 639 /* 640 * pid of the system_server process. We track it so that when system server 641 * crashes the Zygote process will be killed and restarted. 642 */ 643 pid_t systemServerPid; 644 645 int kernelGroupScheduling; 646 647//#define COUNT_PRECISE_METHODS 648#ifdef COUNT_PRECISE_METHODS 649 PointerSet* preciseMethods; 650#endif 651 652 /* some RegisterMap statistics, useful during development */ 653 void* registerMapStats; 654 655#ifdef VERIFIER_STATS 656 VerifierStats verifierStats; 657#endif 658}; 659 660extern struct DvmGlobals gDvm; 661 662#if defined(WITH_JIT) 663 664/* 665 * Exiting the compiled code w/o chaining will incur overhead to look up the 666 * target in the code cache which is extra work only when JIT is enabled. So 667 * we want to monitor it closely to make sure we don't have performance bugs. 668 */ 669typedef enum NoChainExits { 670 kInlineCacheMiss = 0, 671 kCallsiteInterpreted, 672 kSwitchOverflow, 673 kHeavyweightMonitor, 674 kNoChainExitLast, 675} NoChainExits; 676 677/* 678 * JIT-specific global state 679 */ 680struct DvmJitGlobals { 681 /* 682 * Guards writes to Dalvik PC (dPC), translated code address (codeAddr) and 683 * chain fields within the JIT hash table. Note carefully the access 684 * mechanism. 685 * Only writes are guarded, and the guarded fields must be updated in a 686 * specific order using atomic operations. Further, once a field is 687 * written it cannot be changed without halting all threads. 688 * 689 * The write order is: 690 * 1) codeAddr 691 * 2) dPC 692 * 3) chain [if necessary] 693 * 694 * This mutex also guards both read and write of curJitTableEntries. 695 */ 696 pthread_mutex_t tableLock; 697 698 /* The JIT hash table. Note that for access speed, copies of this pointer 699 * are stored in each thread. */ 700 struct JitEntry *pJitEntryTable; 701 702 /* Array of profile threshold counters */ 703 unsigned char *pProfTable; 704 705 /* Copy of pProfTable used for temporarily disabling the Jit */ 706 unsigned char *pProfTableCopy; 707 708 /* Size of JIT hash table in entries. Must be a power of 2 */ 709 unsigned int jitTableSize; 710 711 /* Mask used in hash function for JitTable. Should be jitTableSize-1 */ 712 unsigned int jitTableMask; 713 714 /* How many entries in the JitEntryTable are in use */ 715 unsigned int jitTableEntriesUsed; 716 717 /* Bytes allocated for the code cache */ 718 unsigned int codeCacheSize; 719 720 /* Trigger for trace selection */ 721 unsigned short threshold; 722 723 /* JIT Compiler Control */ 724 bool haltCompilerThread; 725 bool blockingMode; 726 pthread_t compilerHandle; 727 pthread_mutex_t compilerLock; 728 pthread_mutex_t compilerICPatchLock; 729 pthread_cond_t compilerQueueActivity; 730 pthread_cond_t compilerQueueEmpty; 731 volatile int compilerQueueLength; 732 int compilerHighWater; 733 int compilerWorkEnqueueIndex; 734 int compilerWorkDequeueIndex; 735 int compilerICPatchIndex; 736 737 /* JIT internal stats */ 738 int compilerMaxQueued; 739 int translationChains; 740 741 /* Compiled code cache */ 742 void* codeCache; 743 744 /* Bytes used by the code templates */ 745 unsigned int templateSize; 746 747 /* Bytes already used in the code cache */ 748 unsigned int codeCacheByteUsed; 749 750 /* Number of installed compilations in the cache */ 751 unsigned int numCompilations; 752 753 /* Flag to indicate that the code cache is full */ 754 bool codeCacheFull; 755 756 /* Page size - 1 */ 757 unsigned int pageSizeMask; 758 759 /* Lock to change the protection type of the code cache */ 760 pthread_mutex_t codeCacheProtectionLock; 761 762 /* Number of times that the code cache has been reset */ 763 int numCodeCacheReset; 764 765 /* Number of times that the code cache reset request has been delayed */ 766 int numCodeCacheResetDelayed; 767 768 /* true/false: compile/reject opcodes specified in the -Xjitop list */ 769 bool includeSelectedOp; 770 771 /* true/false: compile/reject methods specified in the -Xjitmethod list */ 772 bool includeSelectedMethod; 773 774 /* Disable JIT for selected opcodes - one bit for each opcode */ 775 char opList[32]; 776 777 /* Disable JIT for selected methods */ 778 HashTable *methodTable; 779 780 /* Flag to dump all compiled code */ 781 bool printMe; 782 783 /* Flag to count trace execution */ 784 bool profile; 785 786 /* Vector to disable selected optimizations */ 787 int disableOpt; 788 789 /* Table to track the overall and trace statistics of hot methods */ 790 HashTable* methodStatsTable; 791 792 /* Filter method compilation blacklist with call-graph information */ 793 bool checkCallGraph; 794 795 /* New translation chain has been set up */ 796 volatile bool hasNewChain; 797 798#if defined(WITH_SELF_VERIFICATION) 799 /* Spin when error is detected, volatile so GDB can reset it */ 800 volatile bool selfVerificationSpin; 801#endif 802 803 /* Framework or stand-alone? */ 804 bool runningInAndroidFramework; 805 806 /* Framework callback happened? */ 807 bool alreadyEnabledViaFramework; 808 809 /* Framework requests to disable the JIT for good */ 810 bool disableJit; 811 812#if defined(SIGNATURE_BREAKPOINT) 813 /* Signature breakpoint */ 814 u4 signatureBreakpointSize; // # of words 815 u4 *signatureBreakpoint; // Signature content 816#endif 817 818#if defined(WITH_JIT_TUNING) 819 /* Performance tuning counters */ 820 int addrLookupsFound; 821 int addrLookupsNotFound; 822 int noChainExit[kNoChainExitLast]; 823 int normalExit; 824 int puntExit; 825 int invokeMonomorphic; 826 int invokePolymorphic; 827 int invokeNative; 828 int invokeMonoGetterInlined; 829 int invokeMonoSetterInlined; 830 int invokePolyGetterInlined; 831 int invokePolySetterInlined; 832 int returnOp; 833 int icPatchInit; 834 int icPatchLockFree; 835 int icPatchQueued; 836 int icPatchRejected; 837 int icPatchDropped; 838 u8 jitTime; 839 int codeCachePatches; 840#endif 841 842 /* Place arrays at the end to ease the display in gdb sessions */ 843 844 /* Work order queue for compilations */ 845 CompilerWorkOrder compilerWorkQueue[COMPILER_WORK_QUEUE_SIZE]; 846 847 /* Work order queue for predicted chain patching */ 848 ICPatchWorkOrder compilerICPatchQueue[COMPILER_IC_PATCH_QUEUE_SIZE]; 849}; 850 851extern struct DvmJitGlobals gDvmJit; 852 853#if defined(WITH_JIT_TUNING) 854extern int gDvmICHitCount; 855#endif 856 857#endif 858 859#endif /*_DALVIK_GLOBALS*/ 860