001/*
002 *  This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 *  This file is licensed to You under the Eclipse Public License (EPL);
005 *  You may not use this file except in compliance with the License. You
006 *  may obtain a copy of the License at
007 *
008 *      http://www.opensource.org/licenses/eclipse-1.0.php
009 *
010 *  See the COPYRIGHT.txt file distributed with this work for information
011 *  regarding copyright ownership.
012 */
013package org.mmtk.plan.refcount.fullheap;
014
015import org.mmtk.plan.TransitiveClosure;
016import org.mmtk.plan.refcount.RCBase;
017import org.mmtk.plan.refcount.RCHeader;
018
019import org.vmmagic.pragma.*;
020import org.vmmagic.unboxed.*;
021
022/**
023 * This class is the fundamental mechanism for performing a
024 * transitive closure over an object graph.
025 *
026 * @see org.mmtk.plan.TraceLocal
027 */
028@Uninterruptible
029public final class RCModifiedProcessor extends TransitiveClosure {
030
031  private final RCCollector collector;
032
033  public RCModifiedProcessor(RCCollector ctor) {
034    this.collector = ctor;
035  }
036
037  @Override
038  @Inline
039  public void processEdge(ObjectReference source, Address slot) {
040    ObjectReference object = slot.loadObjectReference();
041    if (RCBase.isRCObject(object)) {
042      if (RCBase.CC_BACKUP_TRACE && RCBase.performCycleCollection) {
043        if (RCHeader.remainRC(object) == RCHeader.INC_NEW) {
044          collector.getModBuffer().push(object);
045        }
046      } else {
047        if (RCHeader.incRC(object) == RCHeader.INC_NEW) {
048          collector.getModBuffer().push(object);
049        }
050      }
051    }
052  }
053}