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.concurrent.marksweep;
014
015import org.mmtk.plan.TraceLocal;
016import org.mmtk.plan.Trace;
017import org.mmtk.policy.Space;
018
019import org.vmmagic.pragma.*;
020import org.vmmagic.unboxed.*;
021
022/**
023 * This class implements the thread-local functionality for a transitive
024 * closure over a mark-sweep space.
025 */
026@Uninterruptible
027public final class CMSTraceLocal extends TraceLocal {
028
029
030  /**
031   * @param trace the global trace class to use
032   */
033  public CMSTraceLocal(Trace trace) {
034    super(trace);
035  }
036
037  /****************************************************************************
038   *
039   * Externally visible Object processing and tracing
040   */
041
042  /**
043   * {@inheritDoc}
044   */
045  @Override
046  protected boolean overwriteReferenceDuringTrace() {
047    return false;
048  }
049
050  @Override
051  public boolean isLive(ObjectReference object) {
052    if (object.isNull()) return false;
053    if (Space.isInSpace(CMS.MARK_SWEEP, object)) {
054      return CMS.msSpace.isLive(object);
055    }
056    return super.isLive(object);
057  }
058
059  /**
060   * {@inheritDoc}<p>
061   *
062   * In this instance, we refer objects in the mark-sweep space to the
063   * msSpace for tracing, and defer to the superclass for all others.
064   */
065  @Override
066  @Inline
067  public ObjectReference traceObject(ObjectReference object) {
068    if (object.isNull()) return object;
069    if (Space.isInSpace(CMS.MARK_SWEEP, object))
070      return CMS.msSpace.traceObject(this, object);
071    return super.traceObject(object);
072  }
073}