diff options
author | Andy McFadden <fadden@android.com> | 2010-11-12 16:55:21 -0800 |
---|---|---|
committer | Andy McFadden <fadden@android.com> | 2010-11-23 13:00:21 -0800 |
commit | 3f64a024dec2c080b9abde74502826b29263152a (patch) | |
tree | ed1f1c0a17a138c1d1c27f3fbd36deb97652cc59 /vm/Init.c | |
parent | 5016966b91f1bc36b2bd52ec13ecfd8de1c68209 (diff) | |
download | android_dalvik-3f64a024dec2c080b9abde74502826b29263152a.tar.gz android_dalvik-3f64a024dec2c080b9abde74502826b29263152a.tar.bz2 android_dalvik-3f64a024dec2c080b9abde74502826b29263152a.zip |
Check monitors during bytecode verification
This adds tracking of monitor-enter and monitor-exit instructions
to the bytecode verifier. The idea is to guarantee that all lock
operations in a method are paired with unlock operations, whether
the method completes normally or abnormally.
Because of an issue in "dx", the code only verifies that the operation
stack has the right size at all times. We do not yet confirm that
the correct monitor is being unlocked by monitor-exit (the code is
present but ifdefed out). Also, when monitor verification is enabled,
we do not add the "can throw" path from monitor-exit to the work list,
potentially causing some "dead code" warnings. (Not coincidentally,
"dead code" checking is now only enabled in libdvm_assert.so.)
Overall increase in bootstrap verification time is about 9%, dropping
to 6% when the new checks are disabled.
The feature is currently disabled by default. -Xverifyopt:checkmon
enables it.
Bug 2534655
Change-Id: I0eac54ce2623fb1d48cc80889fcdb4fd69de3231
Diffstat (limited to 'vm/Init.c')
-rw-r--r-- | vm/Init.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -120,6 +120,7 @@ static void dvmUsage(const char* progName) dvmFprintf(stderr, " -Xgc:[no]concurrent\n"); dvmFprintf(stderr, " -Xgc:[no]verifycardtable\n"); dvmFprintf(stderr, " -Xgenregmap\n"); + dvmFprintf(stderr, " -Xverifyopt:[no]checkmon\n"); dvmFprintf(stderr, " -Xcheckdexsum\n"); #if defined(WITH_JIT) dvmFprintf(stderr, " -Xincludeselectedop\n"); @@ -139,16 +140,16 @@ static void dvmUsage(const char* progName) dvmFprintf(stderr, "Configured with:" " debugger" " profiler" + " hprof" +#ifdef WITH_HPROF_STACK + " hprof_stack" +#endif #ifdef WITH_MONITOR_TRACKING " monitor_tracking" #endif #ifdef WITH_DEADLOCK_PREDICTION " deadlock_prediction" #endif - " hprof" -#ifdef WITH_HPROF_STACK - " hprof_stack" -#endif #ifdef WITH_TRACKREF_CHECKS " trackref_checks" #endif @@ -984,6 +985,11 @@ static int dvmProcessOptions(int argc, const char* const argv[], gDvm.generateRegisterMaps = true; LOGV("Register maps will be generated during verification\n"); + } else if (strcmp(argv[i], "Xverifyopt:checkmon") == 0) { + gDvm.monitorVerification = true; + } else if (strcmp(argv[i], "Xverifyopt:nocheckmon") == 0) { + gDvm.monitorVerification = false; + } else if (strncmp(argv[i], "-Xgc:", 5) == 0) { if (strcmp(argv[i] + 5, "precise") == 0) gDvm.preciseGc = true; @@ -1076,6 +1082,7 @@ static void setCommandLineDefaults() /* default verification and optimization modes */ gDvm.classVerifyMode = VERIFY_MODE_ALL; gDvm.dexOptMode = OPTIMIZE_MODE_VERIFIED; + gDvm.monitorVerification = false; /* * Default execution mode. |