OSDN Git Service

Check monitors during bytecode verification
authorAndy McFadden <fadden@android.com>
Sat, 13 Nov 2010 00:55:21 +0000 (16:55 -0800)
committerAndy McFadden <fadden@android.com>
Tue, 23 Nov 2010 21:00:21 +0000 (13:00 -0800)
commit3f64a024dec2c080b9abde74502826b29263152a
treeed1f1c0a17a138c1d1c27f3fbd36deb97652cc59
parent5016966b91f1bc36b2bd52ec13ecfd8de1c68209
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
13 files changed:
docs/verifier.html
tests/088-monitor-verification/expected.txt [new file with mode: 0644]
tests/088-monitor-verification/info.txt [new file with mode: 0644]
tests/088-monitor-verification/src/Main.java [new file with mode: 0644]
tests/088-monitor-verification/src/MyException.java [new file with mode: 0644]
tests/088-monitor-verification/src/TooDeep.java [new file with mode: 0644]
vm/Globals.h
vm/Init.c
vm/analysis/CodeVerify.c
vm/analysis/CodeVerify.h
vm/analysis/DexPrepare.c
vm/analysis/DexVerify.c
vm/analysis/DexVerify.h