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