summaryrefslogtreecommitdiffstats
path: root/libdex/InstrUtils.c
diff options
context:
space:
mode:
authorAndy McFadden <fadden@android.com>2009-10-28 17:39:02 -0700
committerAndy McFadden <fadden@android.com>2009-11-16 12:37:25 -0800
commit96516932f1557d8f48a8b2dbbb885af01a11ef6e (patch)
treea4bac9fd87ab5e88dfaaa92c84d99b6195fdc0fe /libdex/InstrUtils.c
parent62beb8b347e9e578de1844d56ce08f1d536e9c28 (diff)
downloadandroid_dalvik-96516932f1557d8f48a8b2dbbb885af01a11ef6e.tar.gz
android_dalvik-96516932f1557d8f48a8b2dbbb885af01a11ef6e.tar.bz2
android_dalvik-96516932f1557d8f48a8b2dbbb885af01a11ef6e.zip
Change the way breakpoints work.
This replaces the breakpoint mechanism with a more efficient approach. We now insert breakpoint instructions into the bytecode stream instead of maintaining a table. This requires mapping DEX files as private instead of shared, which allows copy-on-write to work. mprotect() is used to guard the pages against inadvertent writes. Unused opcode EC is now OP_BREAKPOINT. It's not recognized by dexdump or any interpreter except portdbg, but it can be encountered by the bytecode verifier (the debugger can request breakpoints in unverified code). Breakpoint changes are blocked while the verifier runs to avoid races. This eliminates method->debugBreakpointCount, which is no longer needed. (Also, it clashed with LinearAlloc's read-only mode.) The deferred verification error mechanism was using a code-copying approach to modify the bytecode stream. That has been changed to use the same copy-on-write modification mechanism. Also, normalized all PAGE_SIZE/PAGESIZE references to a single SYSTEM_PAGE_SIZE define. Simple Fibonacci computation test times (opal-eng): JIT, no debugger: 10.6ms Fast interp, no debugger: 36ms Portable interp, no debugger: 43.8ms ORIG debug interp, no breakpoints set: 458ms ORIG debug interp, breakpoint set nearby: 697ms NEW debug interp, no breakpoints set: 341ms NEW debug interp, breakpoints set nearby: 341ms Where "nearby" means there's a breakpoint in the method doing the computation that isn't actually hit -- the VM had an optimization where it flagged methods with breakpoints and skipped some of the processing when possible. The bottom line is that code should run noticeably faster while a debugger is attached.
Diffstat (limited to 'libdex/InstrUtils.c')
-rw-r--r--libdex/InstrUtils.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/libdex/InstrUtils.c b/libdex/InstrUtils.c
index 93e1f004a..06e26bce4 100644
--- a/libdex/InstrUtils.c
+++ b/libdex/InstrUtils.c
@@ -306,7 +306,7 @@ InstructionWidth* dexCreateInstrWidthTable(void)
width = -3;
break;
- /* these should never appear */
+ /* these should never appear when scanning bytecode */
case OP_UNUSED_3E:
case OP_UNUSED_3F:
case OP_UNUSED_40:
@@ -325,7 +325,7 @@ InstructionWidth* dexCreateInstrWidthTable(void)
case OP_UNUSED_E9:
case OP_UNUSED_EA:
case OP_UNUSED_EB:
- case OP_UNUSED_EC:
+ case OP_BREAKPOINT:
case OP_UNUSED_EF:
case OP_UNUSED_F1:
case OP_UNUSED_FC:
@@ -635,7 +635,7 @@ InstructionFlags* dexCreateInstrFlagsTable(void)
flags = kInstrCanContinue | kInstrCanThrow | kInstrInvoke;
break;
- /* these should never appear */
+ /* these should never appear when scanning code */
case OP_UNUSED_3E:
case OP_UNUSED_3F:
case OP_UNUSED_40:
@@ -654,7 +654,7 @@ InstructionFlags* dexCreateInstrFlagsTable(void)
case OP_UNUSED_E9:
case OP_UNUSED_EA:
case OP_UNUSED_EB:
- case OP_UNUSED_EC:
+ case OP_BREAKPOINT:
case OP_UNUSED_EF:
case OP_UNUSED_F1:
case OP_UNUSED_FC:
@@ -989,7 +989,7 @@ InstructionFormat* dexCreateInstrFormatTable(void)
fmt = kFmt35c;
break;
- /* these should never appear */
+ /* these should never appear when scanning code */
case OP_UNUSED_3E:
case OP_UNUSED_3F:
case OP_UNUSED_40:
@@ -1008,7 +1008,7 @@ InstructionFormat* dexCreateInstrFormatTable(void)
case OP_UNUSED_E9:
case OP_UNUSED_EA:
case OP_UNUSED_EB:
- case OP_UNUSED_EC:
+ case OP_BREAKPOINT:
case OP_UNUSED_EF:
case OP_UNUSED_F1:
case OP_UNUSED_FC: