blob: 0b4db59f825c5217f924452c3a432e50be6155a9 [file] [log] [blame]
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08001/*
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
Elliott Hughes0fbb7032011-06-07 10:07:11 -070032#include <string>
33#include <vector>
34
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080035#include <stdarg.h>
36#include <pthread.h>
37
Andy McFadden96516932009-10-28 17:39:02 -070038/* private structures */
Carl Shapirod862faa2011-04-27 23:00:01 -070039struct GcHeap;
40struct BreakpointSet;
41struct InlineSub;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080042
43/*
44 * One of these for each -ea/-da/-esa/-dsa on the command line.
45 */
Carl Shapirod862faa2011-04-27 23:00:01 -070046struct AssertionControl {
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080047 char* pkgOrClass; /* package/class string, or NULL for esa/dsa */
48 int pkgOrClassLen; /* string length, for quick compare */
49 bool enable; /* enable or disable */
50 bool isPackage; /* string ended with "..."? */
Carl Shapirod862faa2011-04-27 23:00:01 -070051};
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080052
53/*
Andy McFadden701d2722010-12-01 16:18:19 -080054 * Register map generation mode. Only applicable when generateRegisterMaps
55 * is enabled. (The "disabled" state is not folded into this because
56 * there are callers like dexopt that want to enable/disable without
57 * specifying the configuration details.)
58 *
59 * "TypePrecise" is slower and requires additional storage for the register
60 * maps, but allows type-precise GC. "LivePrecise" is even slower and
61 * requires additional heap during processing, but allows live-precise GC.
62 */
Carl Shapirod862faa2011-04-27 23:00:01 -070063enum RegisterMapMode {
Andy McFadden701d2722010-12-01 16:18:19 -080064 kRegisterMapModeUnknown = 0,
65 kRegisterMapModeTypePrecise,
66 kRegisterMapModeLivePrecise
Carl Shapirod862faa2011-04-27 23:00:01 -070067};
Andy McFadden701d2722010-12-01 16:18:19 -080068
69/*
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080070 * All fields are initialized to zero.
71 *
Elliott Hughes689cc332011-06-07 17:38:12 -070072 * Storage allocated here must be freed by a subsystem shutdown function.
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080073 */
74struct DvmGlobals {
75 /*
76 * Some options from the command line or environment.
77 */
78 char* bootClassPathStr;
79 char* classPathStr;
80
Carl Shapirodf9f08b2011-01-18 17:59:30 -080081 size_t heapStartingSize;
82 size_t heapMaximumSize;
83 size_t heapGrowthLimit;
84 size_t stackSize;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080085
86 bool verboseGc;
87 bool verboseJni;
88 bool verboseClass;
Andy McFadden43eb5012010-02-01 16:56:53 -080089 bool verboseShutdown;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080090
91 bool jdwpAllowed; // debugging allowed for this process?
92 bool jdwpConfigured; // has debugging info been provided?
Carl Shapirod5c36b92011-04-15 18:38:06 -070093 JdwpTransportType jdwpTransport;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080094 bool jdwpServer;
95 char* jdwpHost;
96 int jdwpPort;
97 bool jdwpSuspend;
98
Andy McFaddenea414342010-08-25 12:05:44 -070099 /* use wall clock as method profiler clock source? */
100 bool profilerWallClock;
101
Carl Shapirob8fcf572010-04-16 17:33:15 -0700102 /*
103 * Lock profiling threshold value in milliseconds. Acquires that
104 * exceed threshold are logged. Acquires within the threshold are
105 * logged with a probability of $\frac{time}{threshold}$ . If the
106 * threshold is unset no additional logging occurs.
107 */
Carl Shapirof0c514c2010-04-09 15:03:33 -0700108 u4 lockProfThreshold;
Carl Shapirof0c514c2010-04-09 15:03:33 -0700109
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800110 int (*vfprintfHook)(FILE*, const char*, va_list);
111 void (*exitHook)(int);
112 void (*abortHook)(void);
Brad Fitzpatrick3b556752010-12-13 16:53:28 -0800113 bool (*isSensitiveThreadHook)(void);
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800114
115 int jniGrefLimit; // 0 means no limit
Elliott Hughes8afa9df2010-07-07 14:47:25 -0700116 char* jniTrace;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800117 bool reduceSignals;
118 bool noQuitHandler;
119 bool verifyDexChecksum;
120 char* stackTraceFile; // for SIGQUIT-inspired output
121
122 bool logStdio;
123
124 DexOptimizerMode dexOptMode;
125 DexClassVerifyMode classVerifyMode;
Barry Hayes5cbb2302010-02-02 14:07:37 -0800126
Andy McFadden701d2722010-12-01 16:18:19 -0800127 bool generateRegisterMaps;
128 RegisterMapMode registerMapMode;
129
Andy McFadden3f64a022010-11-12 16:55:21 -0800130 bool monitorVerification;
131
Andy McFaddenc58b9ef2010-09-09 12:54:43 -0700132 bool dexOptForSmp;
133
Barry Hayes962adba2010-03-17 12:12:39 -0700134 /*
135 * GC option flags.
136 */
The Android Open Source Project99409882009-03-18 22:20:24 -0700137 bool preciseGc;
Barry Hayes962adba2010-03-17 12:12:39 -0700138 bool preVerify;
139 bool postVerify;
Carl Shapiroec805ea2010-06-28 16:28:26 -0700140 bool concurrentMarkSweep;
Barry Hayes6e5cf602010-06-22 12:32:59 -0700141 bool verifyCardTable;
Carl Shapiro821fd062011-01-19 12:56:14 -0800142 bool disableExplicitGc;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800143
144 int assertionCtrlCount;
145 AssertionControl* assertionCtrl;
146
147 ExecutionMode executionMode;
148
149 /*
150 * VM init management.
151 */
152 bool initializing;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800153 bool optimizing;
154
155 /*
Elliott Hughes49dc0602011-02-10 12:03:34 -0800156 * java.lang.System properties set from the command line with -D.
157 * This is effectively a set, where later entries override earlier
158 * ones.
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800159 */
Elliott Hughes689cc332011-06-07 17:38:12 -0700160 std::vector<std::string>* properties;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800161
162 /*
163 * Where the VM goes to find system classes.
164 */
165 ClassPathEntry* bootClassPath;
166 /* used by the DEX optimizer to load classes from an unfinished DEX */
167 DvmDex* bootClassPathOptExtra;
168 bool optimizingBootstrapClass;
169
170 /*
171 * Loaded classes, hashed by class name. Each entry is a ClassObject*,
172 * allocated in GC space.
173 */
174 HashTable* loadedClasses;
175
176 /*
177 * Value for the next class serial number to be assigned. This is
178 * incremented as we load classes. Failed loads and races may result
179 * in some numbers being skipped, and the serial number is not
180 * guaranteed to start at 1, so the current value should not be used
181 * as a count of loaded classes.
182 */
183 volatile int classSerialNumber;
184
185 /*
Barry Hayes2c987472009-04-06 10:03:48 -0700186 * Classes with a low classSerialNumber are probably in the zygote, and
187 * their InitiatingLoaderList is not used, to promote sharing. The list is
188 * kept here instead.
189 */
190 InitiatingLoaderList* initiatingLoaderList;
191
192 /*
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800193 * Interned strings.
194 */
Carl Shapirobb1e0e92010-07-21 14:49:25 -0700195
196 /* A mutex that guards access to the interned string tables. */
197 pthread_mutex_t internLock;
198
199 /* Hash table of strings interned by the user. */
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800200 HashTable* internedStrings;
201
Carl Shapirobb1e0e92010-07-21 14:49:25 -0700202 /* Hash table of strings interned by the class loader. */
203 HashTable* literalStrings;
204
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800205 /*
Dan Bornstein318839c2011-03-14 11:00:35 -0700206 * Classes constructed directly by the vm.
207 */
208
209 /* the class Class */
210 ClassObject* classJavaLangClass;
211
212 /* synthetic classes representing primitive types */
213 ClassObject* typeVoid;
214 ClassObject* typeBoolean;
215 ClassObject* typeByte;
216 ClassObject* typeShort;
217 ClassObject* typeChar;
218 ClassObject* typeInt;
219 ClassObject* typeLong;
220 ClassObject* typeFloat;
221 ClassObject* typeDouble;
222
223 /* synthetic classes for arrays of primitives */
224 ClassObject* classArrayBoolean;
225 ClassObject* classArrayByte;
226 ClassObject* classArrayShort;
227 ClassObject* classArrayChar;
228 ClassObject* classArrayInt;
229 ClassObject* classArrayLong;
230 ClassObject* classArrayFloat;
231 ClassObject* classArrayDouble;
232
233 /*
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800234 * Quick lookups for popular classes used internally.
235 */
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800236 ClassObject* classJavaLangClassArray;
Andy McFadden09709762011-03-18 14:27:06 -0700237 ClassObject* classJavaLangClassLoader;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800238 ClassObject* classJavaLangObject;
239 ClassObject* classJavaLangObjectArray;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800240 ClassObject* classJavaLangString;
241 ClassObject* classJavaLangThread;
242 ClassObject* classJavaLangVMThread;
243 ClassObject* classJavaLangThreadGroup;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800244 ClassObject* classJavaLangStackTraceElement;
245 ClassObject* classJavaLangStackTraceElementArray;
246 ClassObject* classJavaLangAnnotationAnnotationArray;
247 ClassObject* classJavaLangAnnotationAnnotationArrayArray;
248 ClassObject* classJavaLangReflectAccessibleObject;
249 ClassObject* classJavaLangReflectConstructor;
250 ClassObject* classJavaLangReflectConstructorArray;
251 ClassObject* classJavaLangReflectField;
252 ClassObject* classJavaLangReflectFieldArray;
253 ClassObject* classJavaLangReflectMethod;
254 ClassObject* classJavaLangReflectMethodArray;
255 ClassObject* classJavaLangReflectProxy;
Andy McFadden8e5c7842009-07-23 17:47:18 -0700256 ClassObject* classJavaNioReadWriteDirectByteBuffer;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800257 ClassObject* classOrgApacheHarmonyLangAnnotationAnnotationFactory;
258 ClassObject* classOrgApacheHarmonyLangAnnotationAnnotationMember;
259 ClassObject* classOrgApacheHarmonyLangAnnotationAnnotationMemberArray;
Andy McFadden4b17a1d2011-03-29 09:58:27 -0700260 ClassObject* classOrgApacheHarmonyDalvikDdmcChunk;
261 ClassObject* classOrgApacheHarmonyDalvikDdmcDdmServer;
Carl Shapiro3475f9c2011-03-21 13:35:24 -0700262 ClassObject* classJavaLangRefFinalizerReference;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800263
Dan Bornstein32bb3da2011-02-24 15:47:20 -0800264 /*
265 * classes representing exception types. The names here don't include
266 * packages, just to keep the use sites a bit less verbose. All are
267 * in java.lang, except where noted.
268 */
Dan Bornstein85ba81d2011-03-03 13:10:04 -0800269 ClassObject* exAbstractMethodError;
Dan Bornstein6d167a42011-02-25 13:31:45 -0800270 ClassObject* exArithmeticException;
271 ClassObject* exArrayIndexOutOfBoundsException;
272 ClassObject* exArrayStoreException;
273 ClassObject* exClassCastException;
Dan Bornstein85ba81d2011-03-03 13:10:04 -0800274 ClassObject* exClassCircularityError;
Dan Bornstein2c8e25b2011-02-25 15:49:29 -0800275 ClassObject* exClassFormatError;
Dan Bornstein9b598e32011-03-01 10:28:42 -0800276 ClassObject* exClassNotFoundException;
Dan Bornstein32bb3da2011-02-24 15:47:20 -0800277 ClassObject* exError;
278 ClassObject* exExceptionInInitializerError;
Dan Bornstein2c8e25b2011-02-25 15:49:29 -0800279 ClassObject* exFileNotFoundException; /* in java.io */
280 ClassObject* exIOException; /* in java.io */
Dan Bornstein537e29e2011-03-02 16:28:04 -0800281 ClassObject* exIllegalAccessError;
Dan Bornstein9b598e32011-03-01 10:28:42 -0800282 ClassObject* exIllegalAccessException;
Dan Bornsteinbc606f52011-03-01 13:22:13 -0800283 ClassObject* exIllegalArgumentException;
284 ClassObject* exIllegalMonitorStateException;
285 ClassObject* exIllegalStateException;
286 ClassObject* exIllegalThreadStateException;
Dan Bornstein537e29e2011-03-02 16:28:04 -0800287 ClassObject* exIncompatibleClassChangeError;
Dan Bornsteina3b35122011-03-03 16:17:37 -0800288 ClassObject* exInstantiationError;
Dan Bornsteinbc606f52011-03-01 13:22:13 -0800289 ClassObject* exInstantiationException;
Dan Bornstein85213112011-03-01 16:16:12 -0800290 ClassObject* exInternalError;
Dan Bornstein9b598e32011-03-01 10:28:42 -0800291 ClassObject* exInterruptedException;
Dan Bornstein537e29e2011-03-02 16:28:04 -0800292 ClassObject* exLinkageError;
Dan Bornstein2c8e25b2011-02-25 15:49:29 -0800293 ClassObject* exNegativeArraySizeException;
Dan Bornstein85213112011-03-01 16:16:12 -0800294 ClassObject* exNoClassDefFoundError;
Dan Bornstein537e29e2011-03-02 16:28:04 -0800295 ClassObject* exNoSuchFieldError;
Dan Bornstein9b598e32011-03-01 10:28:42 -0800296 ClassObject* exNoSuchFieldException;
Dan Bornstein537e29e2011-03-02 16:28:04 -0800297 ClassObject* exNoSuchMethodError;
Dan Bornstein2c8e25b2011-02-25 15:49:29 -0800298 ClassObject* exNullPointerException;
Dan Bornstein85ba81d2011-03-03 13:10:04 -0800299 ClassObject* exOutOfMemoryError;
Dan Bornstein32bb3da2011-02-24 15:47:20 -0800300 ClassObject* exRuntimeException;
301 ClassObject* exStackOverflowError;
Dan Bornstein9b598e32011-03-01 10:28:42 -0800302 ClassObject* exStaleDexCacheError; /* in dalvik.system */
Dan Bornstein7a86c442011-02-28 11:23:26 -0800303 ClassObject* exStringIndexOutOfBoundsException;
Dan Bornstein32bb3da2011-02-24 15:47:20 -0800304 ClassObject* exThrowable;
Dan Bornstein85ba81d2011-03-03 13:10:04 -0800305 ClassObject* exTypeNotPresentException;
Dan Bornstein85213112011-03-01 16:16:12 -0800306 ClassObject* exUnsatisfiedLinkError;
Dan Bornstein7a86c442011-02-28 11:23:26 -0800307 ClassObject* exUnsupportedOperationException;
Dan Bornstein85ba81d2011-03-03 13:10:04 -0800308 ClassObject* exVerifyError;
Dan Bornstein7a86c442011-02-28 11:23:26 -0800309 ClassObject* exVirtualMachineError;
Dan Bornstein32bb3da2011-02-24 15:47:20 -0800310
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800311 /* method offsets - Object */
312 int voffJavaLangObject_equals;
313 int voffJavaLangObject_hashCode;
314 int voffJavaLangObject_toString;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800315
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800316 /* field offsets - String */
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800317 int offJavaLangString_value;
318 int offJavaLangString_count;
319 int offJavaLangString_offset;
320 int offJavaLangString_hashCode;
321
322 /* field offsets - Thread */
323 int offJavaLangThread_vmThread;
324 int offJavaLangThread_group;
325 int offJavaLangThread_daemon;
326 int offJavaLangThread_name;
327 int offJavaLangThread_priority;
Andy McFadden19cd2fc2011-03-24 13:45:14 -0700328 int offJavaLangThread_uncaughtHandler;
Andy McFaddenf5e6de92011-03-25 07:37:31 -0700329 int offJavaLangThread_contextClassLoader;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800330
331 /* method offsets - Thread */
332 int voffJavaLangThread_run;
333
Andy McFadden86c95932011-03-23 16:15:36 -0700334 /* field offsets - ThreadGroup */
335 int offJavaLangThreadGroup_name;
336 int offJavaLangThreadGroup_parent;
337
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800338 /* field offsets - VMThread */
339 int offJavaLangVMThread_thread;
340 int offJavaLangVMThread_vmData;
341
342 /* method offsets - ThreadGroup */
343 int voffJavaLangThreadGroup_removeThread;
344
345 /* field offsets - Throwable */
346 int offJavaLangThrowable_stackState;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800347 int offJavaLangThrowable_cause;
348
Andy McFadden04771392010-10-07 15:12:14 -0700349 /* method offsets - ClassLoader */
350 int voffJavaLangClassLoader_loadClass;
351
Andy McFaddenf5e6de92011-03-25 07:37:31 -0700352 /* direct method pointers - ClassLoader */
353 Method* methJavaLangClassLoader_getSystemClassLoader;
354
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800355 /* field offsets - java.lang.reflect.* */
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800356 int offJavaLangReflectConstructor_slot;
357 int offJavaLangReflectConstructor_declClass;
358 int offJavaLangReflectField_slot;
359 int offJavaLangReflectField_declClass;
360 int offJavaLangReflectMethod_slot;
361 int offJavaLangReflectMethod_declClass;
362
363 /* field offsets - java.lang.ref.Reference */
364 int offJavaLangRefReference_referent;
365 int offJavaLangRefReference_queue;
366 int offJavaLangRefReference_queueNext;
Carl Shapiro2a6f4842010-07-09 16:50:54 -0700367 int offJavaLangRefReference_pendingNext;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800368
Carl Shapiroce87bfe2011-03-30 19:35:34 -0700369 /* field offsets - java.lang.ref.FinalizerReference */
370 int offJavaLangRefFinalizerReference_zombie;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800371
Carl Shapiroce87bfe2011-03-30 19:35:34 -0700372 /* method pointers - java.lang.ref.ReferenceQueue */
373 Method* methJavaLangRefReferenceQueueAdd;
374
375 /* method pointers - java.lang.ref.FinalizerReference */
376 Method* methJavaLangRefFinalizerReferenceAdd;
Carl Shapiro3475f9c2011-03-21 13:35:24 -0700377
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800378 /* constructor method pointers; no vtable involved, so use Method* */
379 Method* methJavaLangStackTraceElement_init;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800380 Method* methJavaLangReflectConstructor_init;
381 Method* methJavaLangReflectField_init;
382 Method* methJavaLangReflectMethod_init;
383 Method* methOrgApacheHarmonyLangAnnotationAnnotationMember_init;
384
385 /* static method pointers - android.lang.annotation.* */
386 Method*
387 methOrgApacheHarmonyLangAnnotationAnnotationFactory_createAnnotation;
388
389 /* direct method pointers - java.lang.reflect.Proxy */
390 Method* methJavaLangReflectProxy_constructorPrototype;
391
392 /* field offsets - java.lang.reflect.Proxy */
393 int offJavaLangReflectProxy_h;
394
Andy McFadden19cd2fc2011-03-24 13:45:14 -0700395 /* field offsets - java.io.FileDescriptor */
396 int offJavaIoFileDescriptor_descriptor;
397
Andy McFaddenf5e6de92011-03-25 07:37:31 -0700398 /* direct method pointers - dalvik.system.NativeStart */
399 Method* methDalvikSystemNativeStart_main;
400 Method* methDalvikSystemNativeStart_run;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800401
Andy McFadden8e5c7842009-07-23 17:47:18 -0700402 /* assorted direct buffer helpers */
403 Method* methJavaNioReadWriteDirectByteBuffer_init;
Andy McFadden8e5c7842009-07-23 17:47:18 -0700404 int offJavaNioBuffer_capacity;
Andy McFadden8e696dc2009-07-24 15:28:16 -0700405 int offJavaNioBuffer_effectiveDirectAddress;
Andy McFadden5f612b82009-07-22 15:07:27 -0700406
Andy McFaddence1762c2011-03-28 15:03:21 -0700407 /* direct method pointers - org.apache.harmony.dalvik.ddmc.DdmServer */
408 Method* methDalvikDdmcServer_dispatch;
409 Method* methDalvikDdmcServer_broadcast;
410
411 /* field offsets - org.apache.harmony.dalvik.ddmc.Chunk */
412 int offDalvikDdmcChunk_type;
413 int offDalvikDdmcChunk_data;
414 int offDalvikDdmcChunk_offset;
415 int offDalvikDdmcChunk_length;
416
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800417 /*
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800418 * Thread list. This always has at least one element in it (main),
419 * and main is always the first entry.
420 *
421 * The threadListLock is used for several things, including the thread
422 * start condition variable. Generally speaking, you must hold the
423 * threadListLock when:
424 * - adding/removing items from the list
425 * - waiting on or signaling threadStartCond
426 * - examining the Thread struct for another thread (this is to avoid
427 * one thread freeing the Thread struct while another thread is
428 * perusing it)
429 */
430 Thread* threadList;
431 pthread_mutex_t threadListLock;
432
433 pthread_cond_t threadStartCond;
434
435 /*
436 * The thread code grabs this before suspending all threads. There
Andy McFadden2aa43612009-06-17 16:29:30 -0700437 * are a few things that can cause a "suspend all":
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800438 * (1) the GC is starting;
439 * (2) the debugger has sent a "suspend all" request;
440 * (3) a thread has hit a breakpoint or exception that the debugger
441 * has marked as a "suspend all" event;
442 * (4) the SignalCatcher caught a signal that requires suspension.
Ben Chengba4fc8b2009-06-01 13:00:29 -0700443 * (5) (if implemented) the JIT needs to perform a heavyweight
444 * rearrangement of the translation cache or JitTable.
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800445 *
446 * Because we use "safe point" self-suspension, it is never safe to
447 * do a blocking "lock" call on this mutex -- if it has been acquired,
448 * somebody is probably trying to put you to sleep. The leading '_' is
449 * intended as a reminder that this lock is special.
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800450 */
451 pthread_mutex_t _threadSuspendLock;
452
453 /*
buzbee389e2582011-04-22 15:12:40 -0700454 * Guards Thread->suspendCount for all threads, and
buzbee9a3147c2011-03-02 15:43:48 -0800455 * provides the lock for the condition variable that all suspended threads
456 * sleep on (threadSuspendCountCond).
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800457 *
458 * This has to be separate from threadListLock because of the way
459 * threads put themselves to sleep.
460 */
461 pthread_mutex_t threadSuspendCountLock;
462
463 /*
464 * Suspended threads sleep on this. They should sleep on the condition
465 * variable until their "suspend count" is zero.
466 *
467 * Paired with "threadSuspendCountLock".
468 */
469 pthread_cond_t threadSuspendCountCond;
470
471 /*
buzbeecb3081f2011-01-14 13:37:31 -0800472 * Sum of all threads' suspendCount fields. Guarded by
473 * threadSuspendCountLock.
Bill Buzbee46cd5b62009-06-05 15:36:06 -0700474 */
475 int sumThreadSuspendCount;
476
477 /*
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800478 * MUTEX ORDERING: when locking multiple mutexes, always grab them in
479 * this order to avoid deadlock:
480 *
481 * (1) _threadSuspendLock (use lockThreadSuspend())
482 * (2) threadListLock (use dvmLockThreadList())
483 * (3) threadSuspendCountLock (use lockThreadSuspendCount())
484 */
485
486
487 /*
488 * Thread ID bitmap. We want threads to have small integer IDs so
489 * we can use them in "thin locks".
490 */
491 BitVector* threadIdMap;
492
493 /*
494 * Manage exit conditions. The VM exits when all non-daemon threads
495 * have exited. If the main thread returns early, we need to sleep
496 * on a condition variable.
497 */
498 int nonDaemonThreadCount; /* must hold threadListLock to access */
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800499 pthread_cond_t vmExitCond;
500
501 /*
502 * The set of DEX files loaded by custom class loaders.
503 */
504 HashTable* userDexFiles;
505
506 /*
507 * JNI global reference table.
508 */
Andy McFaddend5ab7262009-08-25 07:19:34 -0700509 IndirectRefTable jniGlobalRefTable;
Carl Shapiroe4c3b5e2011-03-08 13:44:51 -0800510 IndirectRefTable jniWeakGlobalRefTable;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800511 pthread_mutex_t jniGlobalRefLock;
Carl Shapiroe4c3b5e2011-03-08 13:44:51 -0800512 pthread_mutex_t jniWeakGlobalRefLock;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800513 int jniGlobalRefHiMark;
514 int jniGlobalRefLoMark;
515
516 /*
Andy McFaddenc26bb632009-08-21 12:01:31 -0700517 * JNI pinned object table (used for primitive arrays).
518 */
519 ReferenceTable jniPinRefTable;
520 pthread_mutex_t jniPinRefLock;
521
522 /*
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800523 * Native shared library table.
524 */
525 HashTable* nativeLibs;
526
527 /*
528 * GC heap lock. Functions like gcMalloc() acquire this before making
529 * any changes to the heap. It is held throughout garbage collection.
530 */
531 pthread_mutex_t gcHeapLock;
532
Carl Shapiroec47e2e2010-07-01 17:44:46 -0700533 /*
534 * Condition variable to queue threads waiting to retry an
535 * allocation. Signaled after a concurrent GC is completed.
536 */
537 pthread_cond_t gcHeapCond;
538
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800539 /* Opaque pointer representing the heap. */
540 GcHeap* gcHeap;
541
Barry Hayes4496ed92010-07-12 09:52:20 -0700542 /* The card table base, modified as needed for marking cards. */
543 u1* biasedCardTableBase;
544
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800545 /*
Andy McFadden7fc3ce82009-07-14 15:57:23 -0700546 * Pre-allocated throwables.
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800547 */
548 Object* outOfMemoryObj;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800549 Object* internalErrorObj;
Andy McFadden7fc3ce82009-07-14 15:57:23 -0700550 Object* noClassDefFoundErrorObj;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800551
552 /* Monitor list, so we can free them */
553 /*volatile*/ Monitor* monitorList;
554
555 /* Monitor for Thread.sleep() implementation */
556 Monitor* threadSleepMon;
557
558 /* set when we create a second heap inside the zygote */
559 bool newZygoteHeapAllocated;
560
561 /*
562 * TLS keys.
563 */
564 pthread_key_t pthreadKeySelf; /* Thread*, for dvmThreadSelf */
565
566 /*
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800567 * Cache results of "A instanceof B".
568 */
569 AtomicCache* instanceofCache;
570
Andy McFaddencb3c5422010-04-07 15:56:16 -0700571 /* inline substitution table, used during optimization */
572 InlineSub* inlineSubs;
573
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800574 /*
575 * Bootstrap class loader linear allocator.
576 */
577 LinearAllocHdr* pBootLoaderAlloc;
578
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800579 /*
580 * Compute some stats on loaded classes.
581 */
The Android Open Source Project99409882009-03-18 22:20:24 -0700582 int numLoadedClasses;
583 int numDeclaredMethods;
584 int numDeclaredInstFields;
585 int numDeclaredStaticFields;
586
587 /* when using a native debugger, set this to suppress watchdog timers */
588 bool nativeDebuggerActive;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800589
590 /*
591 * JDWP debugger support.
buzbee9a3147c2011-03-02 15:43:48 -0800592 *
593 * Note: Each thread will normally determine whether the debugger is active
594 * for it by referring to its subMode flags. "debuggerActive" here should be
595 * seen as "debugger is making requests of 1 or more threads".
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800596 */
597 bool debuggerConnected; /* debugger or DDMS is connected */
buzbee9a3147c2011-03-02 15:43:48 -0800598 bool debuggerActive; /* debugger is making requests */
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800599 JdwpState* jdwpState;
600
601 /*
602 * Registry of objects known to the debugger.
603 */
604 HashTable* dbgRegistry;
605
606 /*
Andy McFadden96516932009-10-28 17:39:02 -0700607 * Debugger breakpoint table.
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800608 */
Andy McFadden96516932009-10-28 17:39:02 -0700609 BreakpointSet* breakpointSet;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800610
611 /*
612 * Single-step control struct. We currently only allow one thread to
613 * be single-stepping at a time, which is all that really makes sense,
614 * but it's possible we may need to expand this to be per-thread.
615 */
616 StepControl stepControl;
617
618 /*
619 * DDM features embedded in the VM.
620 */
621 bool ddmThreadNotification;
622
623 /*
624 * Zygote (partially-started process) support
625 */
626 bool zygote;
627
628 /*
629 * Used for tracking allocations that we report to DDMS. When the feature
630 * is enabled (through a DDMS request) the "allocRecords" pointer becomes
631 * non-NULL.
632 */
633 pthread_mutex_t allocTrackerLock;
634 AllocRecord* allocRecords;
635 int allocRecordHead; /* most-recently-added entry */
636 int allocRecordCount; /* #of valid entries */
637
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800638 /*
buzbee9a3147c2011-03-02 15:43:48 -0800639 * When a profiler is enabled, this is incremented. Distinct profilers
640 * include "dmtrace" method tracing, emulator method tracing, and
641 * possibly instruction counting.
642 *
643 * The purpose of this is to have a single value that shows whether any
644 * profiling is going on. Individual thread will normally check their
645 * thread-private subMode flags to take any profiling action.
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800646 */
buzbee9a3147c2011-03-02 15:43:48 -0800647 volatile int activeProfilers;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800648
649 /*
650 * State for method-trace profiling.
651 */
652 MethodTraceState methodTrace;
Andy McFadden2ff04ab2011-03-08 15:22:14 -0800653 Method* methodTraceGcMethod;
654 Method* methodTraceClassPrepMethod;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800655
656 /*
657 * State for emulator tracing.
658 */
659 void* emulatorTracePage;
660 int emulatorTraceEnableCount;
661
662 /*
663 * Global state for memory allocation profiling.
664 */
665 AllocProfState allocProf;
666
667 /*
668 * Pointers to the original methods for things that have been inlined.
669 * This makes it easy for us to output method entry/exit records for
Andy McFadden0d615c32010-08-18 12:19:51 -0700670 * the method calls we're not actually making. (Used by method
671 * profiling.)
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800672 */
673 Method** inlinedMethods;
674
675 /*
Dan Bornsteinccaab182010-12-03 15:32:40 -0800676 * Dalvik instruction counts (kNumPackedOpcodes entries).
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800677 */
678 int* executedInstrCounts;
Andy McFadden5183a192010-10-22 15:26:07 -0700679 int instructionCountEnableCount;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800680
681 /*
682 * Signal catcher thread (for SIGQUIT).
683 */
684 pthread_t signalCatcherHandle;
685 bool haltSignalCatcher;
686
687 /*
688 * Stdout/stderr conversion thread.
689 */
690 bool haltStdioConverter;
691 bool stdioConverterReady;
692 pthread_t stdioConverterHandle;
693 pthread_mutex_t stdioConverterLock;
694 pthread_cond_t stdioConverterCond;
695
696 /*
697 * pid of the system_server process. We track it so that when system server
698 * crashes the Zygote process will be killed and restarted.
699 */
700 pid_t systemServerPid;
701
San Mehat894dd462009-09-08 20:29:15 -0700702 int kernelGroupScheduling;
703
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800704//#define COUNT_PRECISE_METHODS
705#ifdef COUNT_PRECISE_METHODS
706 PointerSet* preciseMethods;
707#endif
The Android Open Source Project99409882009-03-18 22:20:24 -0700708
709 /* some RegisterMap statistics, useful during development */
710 void* registerMapStats;
Andy McFadden470cbbb2010-11-04 16:31:37 -0700711
712#ifdef VERIFIER_STATS
713 VerifierStats verifierStats;
714#endif
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800715};
716
717extern struct DvmGlobals gDvm;
718
Ben Chengba4fc8b2009-06-01 13:00:29 -0700719#if defined(WITH_JIT)
Ben Cheng38329f52009-07-07 14:19:20 -0700720
buzbee2e152ba2010-12-15 16:32:35 -0800721/* Trace profiling modes. Ordering matters - off states before on states */
Carl Shapirod862faa2011-04-27 23:00:01 -0700722enum TraceProfilingModes {
buzbee2e152ba2010-12-15 16:32:35 -0800723 kTraceProfilingDisabled = 0, // Not profiling
724 kTraceProfilingPeriodicOff = 1, // Periodic profiling, off phase
725 kTraceProfilingContinuous = 2, // Always profiling
726 kTraceProfilingPeriodicOn = 3 // Periodic profiling, on phase
Carl Shapirod862faa2011-04-27 23:00:01 -0700727};
buzbee2e152ba2010-12-15 16:32:35 -0800728
Ben Chengba4fc8b2009-06-01 13:00:29 -0700729/*
Ben Cheng6c10a972009-10-29 14:39:18 -0700730 * Exiting the compiled code w/o chaining will incur overhead to look up the
731 * target in the code cache which is extra work only when JIT is enabled. So
732 * we want to monitor it closely to make sure we don't have performance bugs.
733 */
Carl Shapirod862faa2011-04-27 23:00:01 -0700734enum NoChainExits {
Ben Cheng6c10a972009-10-29 14:39:18 -0700735 kInlineCacheMiss = 0,
736 kCallsiteInterpreted,
737 kSwitchOverflow,
Bill Buzbeefccb31d2010-02-04 16:09:55 -0800738 kHeavyweightMonitor,
Ben Cheng6c10a972009-10-29 14:39:18 -0700739 kNoChainExitLast,
Carl Shapirod862faa2011-04-27 23:00:01 -0700740};
Ben Cheng6c10a972009-10-29 14:39:18 -0700741
742/*
Ben Chengba4fc8b2009-06-01 13:00:29 -0700743 * JIT-specific global state
744 */
745struct DvmJitGlobals {
746 /*
747 * Guards writes to Dalvik PC (dPC), translated code address (codeAddr) and
748 * chain fields within the JIT hash table. Note carefully the access
749 * mechanism.
750 * Only writes are guarded, and the guarded fields must be updated in a
751 * specific order using atomic operations. Further, once a field is
752 * written it cannot be changed without halting all threads.
753 *
754 * The write order is:
755 * 1) codeAddr
756 * 2) dPC
757 * 3) chain [if necessary]
758 *
759 * This mutex also guards both read and write of curJitTableEntries.
760 */
761 pthread_mutex_t tableLock;
762
763 /* The JIT hash table. Note that for access speed, copies of this pointer
764 * are stored in each thread. */
765 struct JitEntry *pJitEntryTable;
766
buzbee2e152ba2010-12-15 16:32:35 -0800767 /* Array of compilation trigger threshold counters */
Ben Chengba4fc8b2009-06-01 13:00:29 -0700768 unsigned char *pProfTable;
Ben Chengba4fc8b2009-06-01 13:00:29 -0700769
buzbee2e152ba2010-12-15 16:32:35 -0800770 /* Trace profiling counters */
771 struct JitTraceProfCounters *pJitTraceProfCounters;
772
Bill Buzbee06bb8392010-01-31 18:53:15 -0800773 /* Copy of pProfTable used for temporarily disabling the Jit */
774 unsigned char *pProfTableCopy;
775
Ben Chengba4fc8b2009-06-01 13:00:29 -0700776 /* Size of JIT hash table in entries. Must be a power of 2 */
Bill Buzbee27176222009-06-09 09:20:16 -0700777 unsigned int jitTableSize;
778
779 /* Mask used in hash function for JitTable. Should be jitTableSize-1 */
780 unsigned int jitTableMask;
781
782 /* How many entries in the JitEntryTable are in use */
783 unsigned int jitTableEntriesUsed;
Ben Chengba4fc8b2009-06-01 13:00:29 -0700784
Ben Cheng94e79eb2010-02-04 16:15:59 -0800785 /* Bytes allocated for the code cache */
786 unsigned int codeCacheSize;
787
Ben Chengba4fc8b2009-06-01 13:00:29 -0700788 /* Trigger for trace selection */
789 unsigned short threshold;
790
791 /* JIT Compiler Control */
792 bool haltCompilerThread;
793 bool blockingMode;
buzbee18fba342011-01-19 15:31:15 -0800794 bool methodTraceSupport;
Ben Cheng7ab74e12011-02-03 14:02:06 -0800795 bool genSuspendPoll;
Ben Cheng385828e2011-03-04 16:48:33 -0800796 Thread* compilerThread;
Ben Chengba4fc8b2009-06-01 13:00:29 -0700797 pthread_t compilerHandle;
798 pthread_mutex_t compilerLock;
Ben Chengc3b92b22010-01-26 16:46:15 -0800799 pthread_mutex_t compilerICPatchLock;
Ben Chengba4fc8b2009-06-01 13:00:29 -0700800 pthread_cond_t compilerQueueActivity;
801 pthread_cond_t compilerQueueEmpty;
Ben Cheng88a0f972010-02-24 15:00:40 -0800802 volatile int compilerQueueLength;
Ben Chengba4fc8b2009-06-01 13:00:29 -0700803 int compilerHighWater;
804 int compilerWorkEnqueueIndex;
805 int compilerWorkDequeueIndex;
Ben Chengc3b92b22010-01-26 16:46:15 -0800806 int compilerICPatchIndex;
Ben Chengba4fc8b2009-06-01 13:00:29 -0700807
808 /* JIT internal stats */
809 int compilerMaxQueued;
Ben Chengba4fc8b2009-06-01 13:00:29 -0700810 int translationChains;
Ben Chengba4fc8b2009-06-01 13:00:29 -0700811
812 /* Compiled code cache */
813 void* codeCache;
814
Ben Cheng385828e2011-03-04 16:48:33 -0800815 /*
816 * This is used to store the base address of an in-flight compilation whose
817 * class object pointers have been calculated to populate literal pool.
818 * Once the compiler thread has changed its status to VM_WAIT, we cannot
819 * guarantee whether GC has happened before the code address has been
820 * installed to the JIT table. Because of that, this field can only
821 * been cleared/overwritten by the compiler thread if it is in the
822 * THREAD_RUNNING state or in a safe point.
823 */
824 void *inflightBaseAddr;
825
buzbee18fba342011-01-19 15:31:15 -0800826 /* Translation cache version (protected by compilerLock */
827 int cacheVersion;
828
Ben Cheng8b258bf2009-06-24 17:27:07 -0700829 /* Bytes used by the code templates */
830 unsigned int templateSize;
831
Ben Chengba4fc8b2009-06-01 13:00:29 -0700832 /* Bytes already used in the code cache */
833 unsigned int codeCacheByteUsed;
834
835 /* Number of installed compilations in the cache */
836 unsigned int numCompilations;
837
838 /* Flag to indicate that the code cache is full */
839 bool codeCacheFull;
840
Ben Chengb88ec3c2010-05-17 12:50:33 -0700841 /* Page size - 1 */
842 unsigned int pageSizeMask;
843
844 /* Lock to change the protection type of the code cache */
845 pthread_mutex_t codeCacheProtectionLock;
846
Ben Cheng7a0bcd02010-01-22 16:45:45 -0800847 /* Number of times that the code cache has been reset */
848 int numCodeCacheReset;
849
Ben Chengc3b92b22010-01-26 16:46:15 -0800850 /* Number of times that the code cache reset request has been delayed */
851 int numCodeCacheResetDelayed;
852
Ben Chengba4fc8b2009-06-01 13:00:29 -0700853 /* true/false: compile/reject opcodes specified in the -Xjitop list */
854 bool includeSelectedOp;
855
856 /* true/false: compile/reject methods specified in the -Xjitmethod list */
857 bool includeSelectedMethod;
858
859 /* Disable JIT for selected opcodes - one bit for each opcode */
Ben Chenge346f7d2011-05-09 16:34:45 -0700860 char opList[(kNumPackedOpcodes+7)/8];
Ben Chengba4fc8b2009-06-01 13:00:29 -0700861
862 /* Disable JIT for selected methods */
863 HashTable *methodTable;
864
Ben Chengba4fc8b2009-06-01 13:00:29 -0700865 /* Flag to dump all compiled code */
866 bool printMe;
Bill Buzbee6e963e12009-06-17 16:56:19 -0700867
Ben Cheng46cd4fb2011-03-16 17:19:06 -0700868 /* Per-process debug flag toggled when receiving a SIGUSR2 */
869 bool receivedSIGUSR2;
870
buzbee2e152ba2010-12-15 16:32:35 -0800871 /* Trace profiling mode */
872 TraceProfilingModes profileMode;
873
874 /* Periodic trace profiling countdown timer */
875 int profileCountdown;
Ben Cheng8b258bf2009-06-24 17:27:07 -0700876
Ben Chengdcf3e5d2009-09-11 13:42:05 -0700877 /* Vector to disable selected optimizations */
878 int disableOpt;
879
Ben Cheng8b258bf2009-06-24 17:27:07 -0700880 /* Table to track the overall and trace statistics of hot methods */
881 HashTable* methodStatsTable;
Ben Chengbcdc1de2009-08-21 16:18:46 -0700882
Ben Cheng33672452010-01-12 14:59:30 -0800883 /* Filter method compilation blacklist with call-graph information */
884 bool checkCallGraph;
885
Ben Chengc3b92b22010-01-26 16:46:15 -0800886 /* New translation chain has been set up */
887 volatile bool hasNewChain;
888
Ben Chengbcdc1de2009-08-21 16:18:46 -0700889#if defined(WITH_SELF_VERIFICATION)
890 /* Spin when error is detected, volatile so GDB can reset it */
891 volatile bool selfVerificationSpin;
892#endif
Ben Chengc3b92b22010-01-26 16:46:15 -0800893
Bill Buzbeefccb31d2010-02-04 16:09:55 -0800894 /* Framework or stand-alone? */
895 bool runningInAndroidFramework;
896
Ben Chengc5285b32010-02-14 16:17:36 -0800897 /* Framework callback happened? */
898 bool alreadyEnabledViaFramework;
899
900 /* Framework requests to disable the JIT for good */
901 bool disableJit;
902
Ben Chengdca71432010-03-16 16:04:11 -0700903#if defined(SIGNATURE_BREAKPOINT)
904 /* Signature breakpoint */
905 u4 signatureBreakpointSize; // # of words
906 u4 *signatureBreakpoint; // Signature content
907#endif
908
Ben Cheng978738d2010-05-13 13:45:57 -0700909#if defined(WITH_JIT_TUNING)
910 /* Performance tuning counters */
911 int addrLookupsFound;
912 int addrLookupsNotFound;
913 int noChainExit[kNoChainExitLast];
914 int normalExit;
915 int puntExit;
916 int invokeMonomorphic;
917 int invokePolymorphic;
918 int invokeNative;
Ben Cheng7a2697d2010-06-07 13:44:23 -0700919 int invokeMonoGetterInlined;
920 int invokeMonoSetterInlined;
921 int invokePolyGetterInlined;
922 int invokePolySetterInlined;
Ben Cheng978738d2010-05-13 13:45:57 -0700923 int returnOp;
Ben Chengb88ec3c2010-05-17 12:50:33 -0700924 int icPatchInit;
925 int icPatchLockFree;
Ben Cheng978738d2010-05-13 13:45:57 -0700926 int icPatchQueued;
Ben Chengb88ec3c2010-05-17 12:50:33 -0700927 int icPatchRejected;
Ben Cheng978738d2010-05-13 13:45:57 -0700928 int icPatchDropped;
Ben Cheng978738d2010-05-13 13:45:57 -0700929 int codeCachePatches;
Ben Cheng385828e2011-03-04 16:48:33 -0800930 int numCompilerThreadBlockGC;
931 u8 jitTime;
932 u8 compilerThreadBlockGCStart;
933 u8 compilerThreadBlockGCTime;
934 u8 maxCompilerThreadBlockGCTime;
Ben Cheng978738d2010-05-13 13:45:57 -0700935#endif
936
Ben Chengc3b92b22010-01-26 16:46:15 -0800937 /* Place arrays at the end to ease the display in gdb sessions */
938
939 /* Work order queue for compilations */
940 CompilerWorkOrder compilerWorkQueue[COMPILER_WORK_QUEUE_SIZE];
941
942 /* Work order queue for predicted chain patching */
943 ICPatchWorkOrder compilerICPatchQueue[COMPILER_IC_PATCH_QUEUE_SIZE];
Ben Chengba4fc8b2009-06-01 13:00:29 -0700944};
945
946extern struct DvmJitGlobals gDvmJit;
947
Ben Cheng978738d2010-05-13 13:45:57 -0700948#if defined(WITH_JIT_TUNING)
949extern int gDvmICHitCount;
950#endif
951
Ben Chengba4fc8b2009-06-01 13:00:29 -0700952#endif
953
Elliott Hughesa5f3ed82011-04-26 18:32:17 -0700954struct DvmJniGlobals {
955 bool useCheckJni;
956 bool warnOnly;
Elliott Hughesd5c80e02011-04-27 12:23:43 -0700957 bool forceCopy;
958
959 /**
960 * The JNI JavaVM object. Dalvik only supports a single VM per process.
961 */
962 JavaVM* jniVm;
Elliott Hughesa5f3ed82011-04-26 18:32:17 -0700963};
964
965extern struct DvmJniGlobals gDvmJni;
966
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800967#endif /*_DALVIK_GLOBALS*/