Interpreter restructuring
This is a restructuring of the Dalvik ARM and x86 interpreters:
o Combine the old portstd and portdbg interpreters into a single
portable interpreter.
o Add debug/profiling support to the fast (mterp) interpreters.
o Delete old mechansim of switching between interpreters. Now, once
you choose an interpreter at startup, you stick with it.
o Allow JIT to co-exist with profiling & debugging (necessary for
first-class support of debugging with the JIT active).
o Adds single-step capability to the fast assembly interpreters without
slowing them down (and, in fact, measurably improves their performance).
o Remove old "polling for safe point" mechanism. Breakouts now achieved
via modifying base of interpreter handler table.
o Simplify interpeter control mechanism.
o Allow thread-granularity control for profiling & debugging
The primary motivation behind this change was to improve the responsiveness
of debugging and profiling and to make it easier to add new debugging and
profiling capabilities in the future. Instead of always bailing out to the
slow debug portable interpreter, we can now stay in the fast interpreter.
A nice side effect of the change is that the fast interpreters
got a healthy speed boost because we were able to replace the
polling safepoint check that involved a dozen or so instructions
with a single table-base reload. When combined with the two earlier CLs
related to this restructuring, we show a 5.6% performance improvement
using libdvm_interp.so on the Checkers benchmark relative to Honeycomb.
Change-Id: I8d37e866b3618def4e582fc73f1cf69ffe428f3c
diff --git a/vm/interp/Interp.h b/vm/interp/Interp.h
index 098429c..9e059f9 100644
--- a/vm/interp/Interp.h
+++ b/vm/interp/Interp.h
@@ -21,6 +21,20 @@
#define _DALVIK_INTERP_INTERP
/*
+ * Stash the dalvik PC in the frame. Called during interpretation.
+ */
+INLINE void dvmExportPC(const u2* pc, const u4* fp)
+{
+ SAVEAREA_FROM_FP(fp)->xtra.currentPc = pc;
+}
+
+/*
+ * Extract the Dalvik opcode
+ */
+#define GET_OPCODE(_inst) (((_inst & 0xff) == OP_DISPATCH_FF) ? \
+ (0x100 + ((_inst >> 8) & 0xff)) : (_inst & 0xff))
+
+/*
* Interpreter entry point. Call here after setting up the interpreted
* stack (most code will want to get here via dvmCallMethod().)
*/
@@ -61,9 +75,31 @@
void dvmFlushBreakpoints(ClassObject* clazz);
/*
+ * Debugger support
+ */
+void dvmUpdateDebugger(const Method* method, const u2* pc, const u4* fp,
+ bool methodEntry, Thread* self);
+void dvmCheckBefore(const u2 *dPC, const u4 *fp, Thread* self);
+void dvmReportExceptionThrow(Thread* self, const Method* curMethod,
+ const u2* pc, void* fp);
+void dvmReportPreNativeInvoke(const u2* pc, Thread* self,
+ const Method* methodToCall);
+void dvmReportPostNativeInvoke(const u2* pc, Thread* self,
+ const Method* methodToCall);
+void dvmReportInvoke(Thread* self, const Method* methodToCall);
+void dvmReportReturn(Thread* self, const u2* pc, const u4* prevFP);
+
+/*
* Update interpBreak
*/
-void dvmUpdateInterpBreak(int newMode, bool enable);
+void dvmUpdateInterpBreak(Thread* thread, int newBreak, int newMode,
+ bool enable);
+void dvmAddToSuspendCounts(Thread* thread, int delta, int dbgDelta);
+
+/*
+ * Update interpBreak for all threads
+ */
+void dvmUpdateAllInterpBreak(int newBreak, int newMode, bool enable);
#ifndef DVM_NO_ASM_INTERP
extern void* dvmAsmInstructionStart[];