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.semispace;
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 core functionality for a transitive
024 * closure over the heap graph.
025 */
026 @Uninterruptible
027 public class SSTraceLocal extends TraceLocal {
028 /**
029 * Constructor
030 */
031 public SSTraceLocal(Trace trace, boolean specialized) {
032 super(specialized ? SS.SCAN_SS : -1, trace);
033 }
034
035 /**
036 * Constructor
037 */
038 public SSTraceLocal(Trace trace) {
039 this(trace, true);
040 }
041
042 /****************************************************************************
043 *
044 * Externally visible Object processing and tracing
045 */
046
047 /**
048 * {@inheritDoc}
049 */
050 @Override
051 public boolean isLive(ObjectReference object) {
052 if (object.isNull()) return false;
053 if (Space.isInSpace(SS.SS0, object))
054 return SS.hi ? SS.copySpace0.isLive(object) : true;
055 if (Space.isInSpace(SS.SS1, object))
056 return SS.hi ? true : SS.copySpace1.isLive(object);
057 return super.isLive(object);
058 }
059
060
061 @Override
062 @Inline
063 public ObjectReference traceObject(ObjectReference object) {
064 if (object.isNull()) return object;
065 if (Space.isInSpace(SS.SS0, object))
066 return SS.copySpace0.traceObject(this, object, SS.ALLOC_SS);
067 if (Space.isInSpace(SS.SS1, object))
068 return SS.copySpace1.traceObject(this, object, SS.ALLOC_SS);
069 return super.traceObject(object);
070 }
071
072 /**
073 * Will this object move from this point on, during the current trace ?
074 *
075 * @param object The object to query.
076 * @return True if the object will not move.
077 */
078 @Override
079 public boolean willNotMoveInCurrentCollection(ObjectReference object) {
080 return (SS.hi && !Space.isInSpace(SS.SS0, object)) ||
081 (!SS.hi && !Space.isInSpace(SS.SS1, object));
082 }
083 }