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