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.TraceLocal; 016import org.mmtk.plan.Trace; 017import org.mmtk.plan.refcount.RCBase; 018import org.mmtk.plan.refcount.RCHeader; 019import org.mmtk.utility.deque.ObjectReferenceDeque; 020 021import org.vmmagic.pragma.*; 022import 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 029public final class RCFindRootSetTraceLocal extends TraceLocal { 030 031 private final ObjectReferenceDeque rootBuffer; 032 033 public RCFindRootSetTraceLocal(Trace trace, ObjectReferenceDeque rootBuffer) { 034 super(trace); 035 this.rootBuffer = rootBuffer; 036 } 037 038 /**************************************************************************** 039 * 040 * Externally visible Object processing and tracing 041 */ 042 043 /** 044 * Is the specified object reachable? 045 * 046 * @param object The object. 047 * @return <code>true</code> if the object is reachable. 048 */ 049 @Override 050 public boolean isLive(ObjectReference object) { 051 return RCBase.isRCObject(object) && RCHeader.isLiveRC(object) || super.isLive(object); 052 } 053 054 /** 055 * When we trace a non-root object we do nothing. 056 * 057 * @param object The object to be traced. 058 * @return The new reference to the same object instance. 059 */ 060 @Override 061 @Inline 062 public ObjectReference traceObject(ObjectReference object) { 063 return object; 064 } 065 066 /** 067 * When we trace a root object we remember it. 068 * 069 * @param object The object to be traced. 070 * @return The new reference to the same object instance. 071 */ 072 @Override 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}