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 @Override 048 public boolean isLive(ObjectReference object) { 049 return !RCBase.isRCObject(object) || RCHeader.isMarked(object); 050 } 051 052 /** 053 * When we trace a non-root object we do nothing. 054 * 055 * @param object The object to be traced. 056 * @return The new reference to the same object instance. 057 */ 058 @Override 059 @Inline 060 public ObjectReference traceObject(ObjectReference object) { 061 if (RCBase.isRCObject(object)) { 062 if (RCHeader.testAndMark(object)) { 063 RCHeader.initRC(object); 064 processNode(object); 065 } else { 066 RCHeader.incRC(object); 067 } 068 } 069 return object; 070 } 071 }