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.fullheap;
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 import org.mmtk.utility.deque.ObjectReferenceDeque;
020
021 import org.vmmagic.pragma.*;
022 import org.vmmagic.unboxed.*;
023
024 /**
025 * This class implements the thread-local core functionality for a transitive
026 * closure over the heap graph.
027 */
028 @Uninterruptible
029 public final class RCFindRootSetTraceLocal extends TraceLocal {
030
031 private final ObjectReferenceDeque rootBuffer;
032
033 /**
034 * Constructor
035 */
036 public RCFindRootSetTraceLocal(Trace trace, ObjectReferenceDeque rootBuffer) {
037 super(trace);
038 this.rootBuffer = rootBuffer;
039 }
040
041 /****************************************************************************
042 *
043 * Externally visible Object processing and tracing
044 */
045
046 /**
047 * Is the specified object reachable?
048 *
049 * @param object The object.
050 * @return <code>true</code> if the object is reachable.
051 */
052 public boolean isLive(ObjectReference object) {
053 return RCBase.isRCObject(object) && RCHeader.isLiveRC(object) || super.isLive(object);
054 }
055
056 /**
057 * When we trace a non-root object we do nothing.
058 *
059 * @param object The object to be traced.
060 * @return The new reference to the same object instance.
061 */
062 @Inline
063 public ObjectReference traceObject(ObjectReference object) {
064 return object;
065 }
066
067 /**
068 * When we trace a root object we remember it.
069 *
070 * @param object The object to be traced.
071 * @return The new reference to the same object instance.
072 */
073 @Inline
074 public ObjectReference traceObject(ObjectReference object, boolean root) {
075 if (root && RCBase.isRCObject(object)) {
076 rootBuffer.push(object);
077 }
078 return object;
079 }
080 }