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.generational.copying;
014    
015    import org.mmtk.plan.generational.Gen;
016    import org.mmtk.plan.generational.GenCollector;
017    import org.mmtk.plan.generational.GenMatureTraceLocal;
018    import org.mmtk.plan.Trace;
019    import org.mmtk.policy.Space;
020    
021    import org.mmtk.vm.VM;
022    
023    import org.vmmagic.pragma.*;
024    import org.vmmagic.unboxed.*;
025    
026    /**
027     * This class implements the core functionality for a transitive
028     * closure over the heap graph, specifically in a Generational copying
029     * collector.
030     */
031    @Uninterruptible
032    public final class GenCopyMatureTraceLocal extends GenMatureTraceLocal {
033    
034      /**
035       * Constructor
036       */
037      public GenCopyMatureTraceLocal(Trace global, GenCollector plan) {
038        super(global, plan);
039      }
040    
041      private static GenCopy global() {
042        return (GenCopy) VM.activePlan.global();
043      }
044    
045      /**
046       * Trace a reference into the mature space during GC. This involves
047       * determining whether the instance is in from space, and if so,
048       * calling the <code>traceObject</code> method of the Copy
049       * collector.
050       *
051       * @param object The object reference to be traced.  This is <i>NOT</i> an
052       * interior pointer.
053       * @return The possibly moved reference.
054       */
055      @Override
056      public ObjectReference traceObject(ObjectReference object) {
057        if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(global().traceFullHeap());
058        if (object.isNull()) return object;
059    
060        if (Space.isInSpace(GenCopy.MS0, object))
061          return GenCopy.matureSpace0.traceObject(this, object, Gen.ALLOC_MATURE_MAJORGC);
062        if (Space.isInSpace(GenCopy.MS1, object))
063          return GenCopy.matureSpace1.traceObject(this, object, Gen.ALLOC_MATURE_MAJORGC);
064        return super.traceObject(object);
065      }
066    
067      @Override
068      public boolean isLive(ObjectReference object) {
069        if (object.isNull()) return false;
070        if (Space.isInSpace(GenCopy.MS0, object))
071          return GenCopy.hi ? GenCopy.matureSpace0.isLive(object) : true;
072        if (Space.isInSpace(GenCopy.MS1, object))
073          return GenCopy.hi ? true : GenCopy.matureSpace1.isLive(object);
074        return super.isLive(object);
075      }
076    
077      /****************************************************************************
078       *
079       * Object processing and tracing
080       */
081    
082    
083      /**
084       * {@inheritDoc}
085       */
086      @Override
087      public boolean willNotMoveInCurrentCollection(ObjectReference object) {
088        if (Space.isInSpace(GenCopy.toSpaceDesc(), object)) {
089          return true;
090        }
091        if (Space.isInSpace(GenCopy.fromSpaceDesc(), object)) {
092          return false;
093        }
094        return super.willNotMoveInCurrentCollection(object);
095      }
096    }