public int trace(GcIntList roots) { this.flag = flag_provider.incrementAndGet(); int sum = 0; for (int i = 0; i < roots.size(); i++) { sum += this.trace(roots.get(i)); } return sum; }
public void copyCollect(GcIntList roots, GcHeap sourceHeap, GcHeap targetHeap) { if (sourceHeap.heapIndex == 0 || sourceHeap.isEmpty()) { throw new IllegalStateException("invalid source heap #" + sourceHeap.heapIndex); } if (targetHeap.heapIndex == 0 || !targetHeap.isEmpty()) { throw new IllegalStateException("invalid target heap #" + targetHeap.heapIndex); } this.sourceHeap = sourceHeap; this.targetHeap = targetHeap; this.flag = flag_provider.incrementAndGet(); for (int i = 0; i < roots.size(); i++) { int newRoot = this.traceAndMarkAndRewritePointers(roots.get(i)); if (newRoot > 0) { roots.set(i, newRoot); } } sourceHeap.free(); }