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