Re: Dalvik Interpreter mterp

93 views
Skip to first unread message

rachelqually

unread,
May 23, 2013, 9:26:27 AM5/23/13
to android-...@googlegroups.com
Phehchcghhvtg
Fggrhh

Rahul ramesh

unread,
May 21, 2013, 10:02:29 AM5/21/13
to android-...@googlegroups.com
Hi,

Just looking in the code in /dalvik/vm/mterp/x86/entry.S for x86
I found that there are two macros at the end of function dvmMterpStdRun

FETCH_INST
GOTO_NEXT

All is see that FETCH_INST fetches the instruction to the register.
But its unclear as to who interprets the instruction from here onwards.
Can somebody point me to the files where code is interpreted.

I'm trying to understand the interpreter so it will be great if some one from the dalvik team can respond .

Regards,
Rahul R

rasputin

unread,
May 21, 2013, 10:30:08 AM5/21/13
to android-platform
.macro GOTO_NEXT
215 movzx rINSTbl,%eax
216 movzbl rINSTbh,rINST
217 jmp *(rIBASE,%eax,4)
218.endm
at xref: /dalvik/vm/mterp/x86/header.S


On May 21, 5:02 pm, Rahul ramesh <rahulkalpsts...@gmail.com> wrote:
> Hi,
>
> Just looking in the code in /dalvik<http://androidxref.com/4.1.2/xref/dalvik/>
> /vm <http://androidxref.com/4.1.2/xref/dalvik/vm/>/mterp<http://androidxref.com/4.1.2/xref/dalvik/vm/mterp/>
> /x86 <http://androidxref.com/4.1.2/xref/dalvik/vm/mterp/x86/>/entry.S<http://androidxref.com/4.1.2/xref/dalvik/vm/mterp/x86/entry.S> for
> x86
> I found that there are two macros at the end of function dvmMterpStdRun<http://androidxref.com/4.1.2/s?refs=dvmMterpStdRun&project=dalvik>
>
> FETCH_INST <http://androidxref.com/4.1.2/s?defs=FETCH_INST&project=dalvik>GOTO_NEXT <http://androidxref.com/4.1.2/s?defs=GOTO_NEXT&project=dalvik>

Kristopher Micinski

unread,
May 21, 2013, 10:30:23 AM5/21/13
to android-...@googlegroups.com
The interpreter is written in such a way that it jumps from stub to
stub, so there's not really an interpretation "loop" per se. The next
instruction is interpreted by the code which handles the next
instruction:

http://androidxref.com/4.1.2/xref/dalvik/vm/mterp/x86/

See all of those OP_* files. Those handle the next instruction :-)

Kris
> --
> You received this message because you are subscribed to the Google Groups
> "android-platform" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to android-platfo...@googlegroups.com.
> To post to this group, send email to android-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/android-platform?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Kristopher Micinski

unread,
May 21, 2013, 10:34:00 AM5/21/13
to android-...@googlegroups.com
Yes, that's a good point, the computation of which stub to go to is
computed: which can be done because all of the stubs fit within a set
space (you can jump if necessary).

Kris

Rahul ramesh

unread,
May 23, 2013, 7:59:18 AM5/23/13
to android-...@googlegroups.com

So rlBASE points to ?

Regards,
Rahul R

Rahul ramesh

unread,
May 23, 2013, 8:01:20 AM5/23/13
to android-...@googlegroups.com
Thank you for your reply.
So the dex files are optimized and put into shared memory .
And then who starts the parsing this memory and invoking the execution engine (The assembly code )
And and at what point are the offsets of instructions calculated ?

Regards,
Rahul R

Kristopher Micinski

unread,
May 23, 2013, 8:40:38 AM5/23/13
to android-...@googlegroups.com
Line 217 that you just posted jumps in a way such that the correct
instruction's stub is the target :-)

The instructions are organized into a jump table:

http://en.wikipedia.org/wiki/Branch_table

Again, the video I pointed to on Dalvik internals gives a pretty good
coverage of this from Dan Bornstein.

Kris

Rahul ramesh

unread,
May 23, 2013, 9:49:37 AM5/23/13
to android-...@googlegroups.com
Thanks Kristopher 

Regards,
Rahul R
Reply all
Reply to author
Forward
0 new messages