JIT and exact GC (or lack thereof)

83 views
Skip to first unread message

Tomei

unread,
Jan 17, 2010, 11:32:54 PM1/17/10
to android-platform
Hello,

Since the Dalvik GC is not exact, you will get some spurious
references when scanning the stack, causing otherwise gagbage to stay
alive.

With the introduction of the JIT, is this problem worsen by any rate?
Will the JIT cause more "might have pointers" areas to be scanned,
resulting in more spurious references?

Thanks!

Ben Cheng

unread,
Jan 18, 2010, 1:58:16 AM1/18/10
to android-platform
The current JIT implementation will make sure that all the values kept
in CPU registers are flushed to the Dalvik registers when safe points
are entered, so the GC will see exactly the same contents in root sets
and VM frames regardless whether JIT is enabled or not.

-Ben

Romain Guy

unread,
Jan 18, 2010, 2:14:11 AM1/18/10
to android-...@googlegroups.com
Didn't we introduce an exact GC in 2.0?

> --
> 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.
>
>
>
>

--
Romain Guy
Android framework engineer
roma...@android.com

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

Tomei

unread,
Jan 18, 2010, 1:29:23 PM1/18/10
to android-platform
Is it enabled by default?

Is it possible to switch back to 'non-exact' GC?

Thanks

On Jan 17, 11:14 pm, Romain Guy <romain...@android.com> wrote:
> Didn't we introduce an exact GC in 2.0?
>
>
>
> On Sun, Jan 17, 2010 at 10:58 PM, Ben Cheng <bcch...@android.com> wrote:
> > The current JIT implementation will make sure that all the values kept
> > in CPU registers are flushed to the Dalvik registers when safe points
> > are entered, so the GC will see exactly the same contents in root sets
> > and VM frames regardless whether JIT is enabled or not.
>
> > -Ben
>
> > On Jan 17, 8:32 pm, Tomei <tomei.ninge...@gmail.com> wrote:
> >> Hello,
>
> >> Since the Dalvik GC is not exact, you will get some spurious
> >> references when scanning the stack, causing otherwise gagbage to stay
> >> alive.
>
> >> With the introduction of the JIT, is this problem worsen by any rate?
> >> Will the JIT cause more "might have pointers" areas to be scanned,
> >> resulting in more spurious references?
>
> >> Thanks!
>
> > --
> > 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 athttp://groups.google.com/group/android-platform?hl=en.


>
> --
> Romain Guy
> Android framework engineer

> romain...@android.com

Tomei

unread,
Jan 18, 2010, 4:52:42 PM1/18/10
to android-platform
I found my own answer in the eclair source code

dalvik/vm/Thread.c:

pMap = dvmGetExpandedRegisterMap(nonConstMethod);
if (pMap != NULL) {
/* found map, get registers for this address */

This scans only registers that are known to be pointers.

Thanks to everyone who replied!

Dan Bornstein

unread,
Jan 19, 2010, 6:26:53 PM1/19/10
to android-...@googlegroups.com
On Mon, Jan 18, 2010 at 10:29 AM, Tomei <tomei.n...@gmail.com> wrote:
> Is [exact gc] enabled by default?

It's turned on for builds produced by (or made in close collaboration
with) the Android team for devices with a sufficiently large system
partition. In particular, it is enabled on all builds we've worked on
for the Droid and N1. Depending on vintage, it *might* be enabled in
builds made for the HTC Magic. And it is definitely *off* in builds
made for the Dream (aka the G1).

> Is it possible to switch back to 'non-exact' GC?

Yes. The vm has command-line switches "-Xgc:precise" or
"-Xgc:noprecise". I don't know off-hand how those end up getting
plumbed into the system, but as they say, grep is your friend.

-dan

fadden

unread,
Jan 21, 2010, 2:07:14 PM1/21/10
to android-platform
On Jan 18, 1:52 pm, Tomei <tomei.ninge...@gmail.com> wrote:
> This scans only registers that are known to be pointers.

FWIW, two additional notes:

(1) This is type-precise GC, not live-precise GC. Good enough to
avoid a conservative scan, but can still be improved.
(2) Register maps (the Dalvik equivalent of "stack maps") increase the
size of optimized DEX files by about 9% on average. Devices with very
tight storage constraints may not want to use them, so the GC still
needs to handle conservative roots.

Register maps are generated during verification. If we can't verify a
class ahead of time with dexopt, the map will be generated on first
use.

Tomei

unread,
Jan 21, 2010, 2:19:12 PM1/21/10
to android-platform
Thanks for the detailed answer.

switching topic slightly ...

Just out of curiosity -- what classes cannot be verified at dexopt
time? I see some verification messages at run time if I have a class
with linkage errors (calling methods that don't exist). Is this the
only case verification need to run at run-time?

Why can such linkage errors be marked "permanently bad" during dexopt
time (to avoid run-time verification)?

Thanks

Reply all
Reply to author
Forward
0 new messages