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 @Override 053 public boolean isLive(ObjectReference object) { 054 return RCBase.isRCObject(object) && RCHeader.isLiveRC(object) || super.isLive(object); 055 } 056 057 /** 058 * When we trace a non-root object we do nothing. 059 * 060 * @param object The object to be traced. 061 * @return The new reference to the same object instance. 062 */ 063 @Override 064 @Inline 065 public ObjectReference traceObject(ObjectReference object) { 066 return object; 067 } 068 069 /** 070 * When we trace a root object we remember it. 071 * 072 * @param object The object to be traced. 073 * @return The new reference to the same object instance. 074 */ 075 @Override 076 @Inline 077 public ObjectReference traceObject(ObjectReference object, boolean root) { 078 if (root && RCBase.isRCObject(object)) { 079 rootBuffer.push(object); 080 } 081 return object; 082 } 083 }