Change Dalvik interpreter to portable

547 views
Skip to first unread message

rgirme

unread,
Sep 6, 2010, 10:08:22 PM9/6/10
to android-platform
Hi guys,

I have downloaded the source code for android. I have been going
through the source code of the Dalvik interpreter -> /dalvik/vm/mterp.
I have been interested in how Dalvik handles synchronized statements.
I have been playing around with the source code. I modified the code
in /dalvik/vm/mterp/c/OP_MONITOR_ENTER.c by adding "
LOGV("MONITOR_ENTER") ".
I did ./rebuild.sh.
I also did a complete build of the source code after that.
To test the changes, I start the emulator in one terminal and " adb
logcat " in another. However I cannot see the statement that I added.
The apps like Calendar, Settings etc have synchronized statements,
hence MONITOR_ENTER should be called.
I think the portable interpreter is not the one being used by the
emulator.
What should I do to make my changes visible ?

Thanks,
Rohit

Chris Stratton

unread,
Sep 7, 2010, 4:04:22 AM9/7/10
to android-platform
I don't know the answer, but would be tempted to track how far your
change propogated by use of tools like diff, grep, and strings on the
built files and adb pulling libs out of the running emulator.

It could also be that verbose log messages aren't being displayed in
your configuration and you need to change that setting or use a more
serious message category.

You could always attempt to cause a segfault if the address of
interest is reached ;-)

A saner idea would be to add a few log messages in places you know
will be reached, perhaps using gcc's __DATE__ __TIME__ macros to
remove all doubt that the logging works and which build (of that
source file) you are actually running.

Anders Widebrant

unread,
Sep 7, 2010, 8:08:26 AM9/7/10
to android-...@googlegroups.com
Yes, I think the first thing I'd personally try is increase the
logging urgency to LOGI/LOGE. It's not hard to imagine that verbose
logs might be disabled per default in Dalvik for performance reason.

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

fadden

unread,
Sep 7, 2010, 6:47:36 PM9/7/10
to android-platform
On Sep 6, 7:08 pm, rgirme <rohitgirm...@gmail.com> wrote:
> I think the portable interpreter is not the one being used by the
> emulator.

By default, the "fast" interpreter is used, and (in >= froyo) the JIT
is enabled.

You can provide "-Xint:portable" on the command line, or "setprop
dalvik.vm.execution-mode int:portable" to change the way the
interpreter used by the Android app framework (the latter requires
root, and you must stop/start the framework after changing the
property).

You could also just modify dvmLockObject(), which is where most of the
interesting stuff happens, though that won't get called if the JIT is
inlining thin lock activity (in which case you still need to specify
the portable interpreter).

See also:
http://android.git.kernel.org/?p=platform/dalvik.git;a=blob_plain;f=docs/embedded-vm-control.html;hb=HEAD

rgirme

unread,
Sep 8, 2010, 9:38:07 PM9/8/10
to android-platform
Hi Guys,

Thank you for the info.
I tried LOGI/LOGE inside the opcode MONITOR_ENTER -> /dalvik/vm/mterp/
c/OP_MONITOR_ENTER.c
However that did not give me any output in logcat.
So I tried "adb shell setprop dalvik.vm.execution-mode int:portable",
followed by "adb shell stop" & "adb shell start".
The way I do it is.
- Compile android source.
- Start emulator from compiled source.
- In another terminal, send the adb commands.
- Start adb logcat.

I also tried LOGI inside dvmLockObject() which is the method that is
called from inside the above file. I could see the LOG output in
logcat because of this. However this worked even when I did not switch
to portable interpreter. ??? Why is that ?

Am I doing things right ?

Thanks,
Rohit
>  http://android.git.kernel.org/?p=platform/dalvik.git;a=blob_plain;f=d...

rgirme

unread,
Sep 11, 2010, 4:49:50 PM9/11/10
to android-platform
Hi,

Does the adb command mentioned apply to android running on the
emulator ? I am sorry if the question is very basic. I asked because
after reading "Controlling the embedded VM", I get the feeling its for
devices running android and the command is to be given from the root
of the device.

Thanks,
Rohit

Dianne Hackborn

unread,
Sep 11, 2010, 6:30:33 PM9/11/10
to android-...@googlegroups.com
Yes, the emulator emulates a running device, and you interact with it through adb just as with a device.

--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.




--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

rgirme

unread,
Sep 13, 2010, 3:24:24 PM9/13/10
to android-platform
Thanks
> > android-platfo...@googlegroups.com<android-platform%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/android-platform?hl=en.
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com
Reply all
Reply to author
Forward
0 new messages