I'm not sure where I have to put this kind of question, so please let
me know if it should belong to somewhere else.
My question is how GC can tell if the register value is a reference to
an object or some primitive (int, float, etc.) value. By seeing the
code in dalvik/vm/Thread.c:gcScanInterpStackReferences() at line 3158,
int i;
for (i = method->registersSize - 1; i >= 0; i--) {
u4 rval = *framePtr++;
//TODO: wrap markifobject in a macro that does pointer checks
if (rval != 0 && (rval & 0x3) == 0) {
dvmMarkIfObject((Object *)rval);
}
}
I guess it tries to check some page boundary and if the address really
belongs to the heap. But isn't it possible to have a false positive? I
understand for GC, it is okay to have a false positive, since the only
bad thing is we don't reclaim that object. I just want to make sure if
I understand it correctly. Possibly, because DVM is a little bit
different from a conventional JVM, is it possible to get the exact
information without any false positive?
Thanks,
Sunghwan