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.utility.sanitychecker;
014
015 import org.mmtk.plan.TraceLocal;
016 import org.mmtk.plan.Trace;
017 import org.mmtk.vm.VM;
018
019 import org.vmmagic.pragma.*;
020 import org.vmmagic.unboxed.*;
021
022 /**
023 * This class implements the parallel root-gathering part of a sanity check.
024 */
025 @Uninterruptible
026 public final class SanityRootTraceLocal extends TraceLocal {
027
028 /**
029 * Constructor
030 */
031 public SanityRootTraceLocal(Trace trace) {
032 super(trace);
033 }
034
035 /****************************************************************************
036 *
037 * Object processing and tracing
038 */
039
040 /**
041 * Copy root values across to the 'real' single-threaded trace that will do
042 * the sanity checking.
043 */
044 @Inline
045 public void copyRootValuesTo(TraceLocal trace) {
046 while (!rootLocations.isEmpty()) {
047 ObjectReference object = rootLocations.pop().loadObjectReference();
048 if (!object.isNull()) {
049 trace.traceObject(object, true);
050 }
051 }
052 while (!values.isEmpty()) {
053 trace.traceObject(values.pop(), true);
054 }
055 }
056
057 /**
058 * Process delayed roots. This does not make sense for SanityRootTraceLocal.
059 * are empty.
060 */
061 @Override
062 @Inline
063 public void processRoots() {
064 VM.assertions.fail("SanityRootTraceLocal.processRoots called.");
065 }
066
067 /**
068 * Finishing processing all GC work. This does not make sense for SanityRootTraceLocal.
069 */
070 @Override
071 @Inline
072 public void completeTrace() {
073 VM.assertions.fail("SanityRootTraceLocal.completeTrace called.");
074 }
075
076 /**
077 * Trace a root object, i.e. root must be <code>true</code>.
078 */
079 @Override
080 @Inline
081 public ObjectReference traceObject(ObjectReference object, boolean root) {
082 if (!root) VM.assertions.fail("SanityRootTraceLocal.traceObject called for non-root object.");
083 if (!object.isNull()) {
084 values.push(object);
085 }
086 return object;
087 }
088
089 /**
090 * Will this object move from this point on, during the current trace ?
091 *
092 * @param object The object to query.
093 * @return {@code true} if the object will not move.
094 */
095 @Override
096 public boolean willNotMoveInCurrentCollection(ObjectReference object) {
097 // We never move objects!
098 return true;
099 }
100 }