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     */
013    package org.mmtk.plan.refcount.backuptrace;
014    
015    import org.mmtk.plan.TraceLocal;
016    import org.mmtk.plan.Trace;
017    import org.mmtk.plan.refcount.RCBase;
018    import org.mmtk.plan.refcount.RCHeader;
019    
020    import org.vmmagic.pragma.*;
021    import org.vmmagic.unboxed.*;
022    
023    /**
024     * This class implements the thread-local core functionality for a transitive
025     * closure over the heap graph.
026     */
027    @Uninterruptible
028    public final class BTTraceLocal extends TraceLocal {
029      /**
030       * Constructor
031       */
032      public BTTraceLocal(Trace trace) {
033        super(trace);
034      }
035    
036      /****************************************************************************
037       *
038       * Externally visible Object processing and tracing
039       */
040    
041      /**
042       * Is the specified object reachable?
043       *
044       * @param object The object.
045       * @return <code>true</code> if the object is reachable.
046       */
047      public boolean isLive(ObjectReference object) {
048        return !RCBase.isRCObject(object) || RCHeader.isMarked(object);
049      }
050    
051      /**
052       * When we trace a non-root object we do nothing.
053       *
054       * @param object The object to be traced.
055       * @return The new reference to the same object instance.
056       */
057      @Inline
058      public ObjectReference traceObject(ObjectReference object) {
059        if (RCBase.isRCObject(object)) {
060          if (RCHeader.testAndMark(object)) {
061            processNode(object);
062          }
063        }
064        return object;
065      }
066    }