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.marksweep;
014
015 import org.mmtk.plan.generational.GenCollector;
016 import org.mmtk.plan.generational.GenMatureTraceLocal;
017 import org.mmtk.plan.Trace;
018 import org.mmtk.policy.Space;
019
020 import org.vmmagic.unboxed.*;
021 import org.vmmagic.pragma.*;
022
023 /**
024 * This class implments the core functionality for a transitive
025 * closure over the heap graph, specifically in a Generational Mark-Sweep
026 * collector.
027 */
028 @Uninterruptible
029 public final class GenMSMatureTraceLocal extends GenMatureTraceLocal{
030
031 /**
032 * Constructor
033 */
034 public GenMSMatureTraceLocal(Trace global, GenCollector plan) {
035 super(global, plan);
036 }
037
038 /**
039 * This method is the core method during the trace of the object graph.
040 * The role of this method is to:
041 *
042 * 1. Ensure the traced object is not collected.
043 * 2. If this is the first visit to the object enqueue it to be scanned.
044 * 3. Return the forwarded reference to the object.
045 *
046 * @param object The object to be traced.
047 * @return The new reference to the same object instance.
048 */
049 @Inline
050 public ObjectReference traceObject(ObjectReference object) {
051 if (object.isNull()) return object;
052
053 if (Space.isInSpace(GenMS.MS, object)) {
054 return GenMS.msSpace.traceObject(this, object);
055 }
056 return super.traceObject(object);
057 }
058
059 /**
060 * Is the specified object live?
061 *
062 * @param object The object.
063 * @return True if the object is live.
064 */
065 public boolean isLive(ObjectReference object) {
066 if (object.isNull()) return false;
067 if (Space.isInSpace(GenMS.MS, object)) {
068 return GenMS.msSpace.isLive(object);
069 }
070 return super.isLive(object);
071 }
072
073 /**
074 * Return true if this object is guaranteed not to move during this
075 * collection (i.e. this object is defintely not an unforwarded
076 * object).
077 *
078 * @param object
079 * @return True if this object is guaranteed not to move during this
080 * collection.
081 */
082 public boolean willNotMoveInCurrentCollection(ObjectReference object) {
083 if (Space.isInSpace(GenMS.MS, object)) {
084 return true;
085 }
086 return super.willNotMoveInCurrentCollection(object);
087 }
088 }