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