From 6e2af6d21076023f141a482d49b607407b2bc2c1 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Mon, 14 Feb 2011 14:04:42 -0800 Subject: [PATCH] Fix "all stubs" interpreter The "all stubs" interpreter is the recommended starting point for anyone creating a "fast" interpreter on a new CPU. This cleans up some minor bit rot in the code and documentation. Bug 3452689 Change-Id: I6bc3b0b5da11955d842d5fc5f16cb1a2209d4a89 --- docs/porting-guide.html | 7 +++++-- vm/mterp/cstubs/entry.c | 4 ++-- vm/mterp/out/InterpAsm-x86-atom.S | 1 + vm/mterp/out/InterpC-allstubs.c | 5 +++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/porting-guide.html b/docs/porting-guide.html index 9b02d176d..d1a1ea38d 100644 --- a/docs/porting-guide.html +++ b/docs/porting-guide.html @@ -164,6 +164,9 @@ source files.
  • Make sure dalvik/vm/Android.mk will find the files for your architecture. If $(TARGET_ARCH) is configured this will happen automatically. +
  • Disable the Dalvik JIT. You can do this in the general device +configuration, or by editing the initialization of WITH_JIT in +dalvik/vm/Dvm.mk to always be false.

    You now have the basic framework in place. Whenever you make a change, you @@ -177,7 +180,7 @@ of the files in dalvik/vm/mterp/out by executing in assembly.

  • In the dalvik directory, regenerate the libdvm.so library with mm. You can also use -make libdvm from the top of the tree. +mmm dalvik/vm from the top of the tree.

    This will leave you with an updated libdvm.so, which can be pushed out to @@ -241,7 +244,7 @@ for examples.

    Replacing Stubs

    -There are roughly 230 Dalvik opcodes, including some that are inserted by +There are roughly 250 Dalvik opcodes, including some that are inserted by dexopt and aren't described in the Dalvik bytecode documentation. Each one must perform the appropriate actions, fetch the next opcode, and diff --git a/vm/mterp/cstubs/entry.c b/vm/mterp/cstubs/entry.c index af31a3da7..4fe0d2cad 100644 --- a/vm/mterp/cstubs/entry.c +++ b/vm/mterp/cstubs/entry.c @@ -30,9 +30,8 @@ bool dvmMterpStdRun(MterpGlue* glue) */ changeInterp = setjmp(jmpBuf) -1; if (changeInterp >= 0) { - Thread* threadSelf = dvmThreadSelf(); LOGVV("mterp threadid=%d returning %d\n", - threadSelf->threadId, changeInterp); + dvmThreadSelf()->threadId, changeInterp); return changeInterp; } @@ -64,6 +63,7 @@ bool dvmMterpStdRun(MterpGlue* glue) u2 inst = /*glue->*/pc[0]; Handler handler = (Handler) gDvmMterpHandlers[inst & 0xff]; + (void) gDvmMterpHandlerNames; /* avoid gcc "defined but not used" */ LOGVV("handler %p %s\n", handler, (const char*) gDvmMterpHandlerNames[inst & 0xff]); (*handler)(glue); diff --git a/vm/mterp/out/InterpAsm-x86-atom.S b/vm/mterp/out/InterpAsm-x86-atom.S index 136e2f293..d4dd70504 100644 --- a/vm/mterp/out/InterpAsm-x86-atom.S +++ b/vm/mterp/out/InterpAsm-x86-atom.S @@ -477,6 +477,7 @@ .LintMax: .long 0x7FFFFFFF + .global dvmAsmInstructionStart .type dvmAsmInstructionStart, %function dvmAsmInstructionStart = .L_OP_NOP diff --git a/vm/mterp/out/InterpC-allstubs.c b/vm/mterp/out/InterpC-allstubs.c index 5d8e3d66e..fb72f261a 100644 --- a/vm/mterp/out/InterpC-allstubs.c +++ b/vm/mterp/out/InterpC-allstubs.c @@ -3079,9 +3079,8 @@ bool dvmMterpStdRun(MterpGlue* glue) */ changeInterp = setjmp(jmpBuf) -1; if (changeInterp >= 0) { - Thread* threadSelf = dvmThreadSelf(); LOGVV("mterp threadid=%d returning %d\n", - threadSelf->threadId, changeInterp); + dvmThreadSelf()->threadId, changeInterp); return changeInterp; } @@ -3113,12 +3112,14 @@ bool dvmMterpStdRun(MterpGlue* glue) u2 inst = /*glue->*/pc[0]; Handler handler = (Handler) gDvmMterpHandlers[inst & 0xff]; + (void) gDvmMterpHandlerNames; /* avoid gcc "defined but not used" */ LOGVV("handler %p %s\n", handler, (const char*) gDvmMterpHandlerNames[inst & 0xff]); (*handler)(glue); } } + /* * C mterp exit point. Call here to bail out of the interpreter. */ -- 2.11.0