public boolean accept(ObjectVisitor visitor, VmHeapManager heapManager) {
// For now do it stupid, but safe, just scan the whole stack.
final int stackSize = getStackSize();
final Object stack = getStack();
if (stack != null) {
final Address stackBottom = ObjectReference.fromObject(stack).toAddress();
final Address stackTop = stackBottom.add(stackSize);
final Address stackEnd;
if (this == currentThread()) {
stackEnd = stackBottom;
} else {
stackEnd = esp;
}
Address ptr = stackTop;
final int slotSize = getReferenceSize();
while (ptr.GE(stackEnd)) {
final Address child = ptr.loadAddress();
if (child != null) {
if (heapManager.isObject(child)) {
if (!visitor.visit(child)) {
return false;
}
}
}
ptr = ptr.sub(slotSize);
}
}
// Scan registers
Address addr = eax.toAddress();
if (heapManager.isObject(addr)) {
if (!visitor.visit(addr)) {
return false;
}
}