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.markcompact;
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-compact space during the initial marking phase.
025 */
026@Uninterruptible
027public final class MCMarkTraceLocal extends TraceLocal {
028
029  /**
030   * @param trace the associated global trace
031   */
032  public MCMarkTraceLocal(Trace trace) {
033    super(MC.SCAN_MARK, trace);
034  }
035
036  /****************************************************************************
037   *
038   * Externally visible Object processing and tracing
039   */
040
041  /**
042   * {@inheritDoc}
043   */
044  @Override
045  public boolean isLive(ObjectReference object) {
046    if (object.isNull()) return false;
047    if (Space.isInSpace(MC.MARK_COMPACT, object)) {
048      return MC.mcSpace.isLive(object);
049    }
050    return super.isLive(object);
051  }
052
053  /**
054   * {@inheritDoc}<p>
055   *
056   * In this instance, we refer objects in the mark-sweep space to the
057   * msSpace for tracing, and defer to the superclass for all others.
058   *
059   * @param object The object to be traced.
060   * @return The new reference to the same object instance.
061   */
062  @Override
063  @Inline
064  public ObjectReference traceObject(ObjectReference object) {
065    if (object.isNull()) return object;
066    if (Space.isInSpace(MC.MARK_COMPACT, object))
067      return MC.mcSpace.traceMarkObject(this, object);
068    return super.traceObject(object);
069  }
070
071  /**
072   * Will this object move from this point on, during the current trace ?
073   *
074   * @param object The object to query.
075   * @return <code>true</code> if the object will not move.
076   */
077  @Override
078  public boolean willNotMoveInCurrentCollection(ObjectReference object) {
079    // All objects in the MC space may move
080    return !Space.isInSpace(MC.MARK_COMPACT, object);
081  }
082
083}