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.stickyms;
014
015 import org.mmtk.plan.TraceLocal;
016 import org.mmtk.plan.Trace;
017 import org.mmtk.policy.Space;
018 import org.mmtk.utility.HeaderByte;
019 import org.mmtk.utility.deque.ObjectReferenceDeque;
020 import org.mmtk.vm.VM;
021
022 import org.vmmagic.pragma.*;
023 import org.vmmagic.unboxed.*;
024
025 /**
026 * This class implements the thread-local functionality for a transitive
027 * closure over a mark-sweep space.
028 */
029 @Uninterruptible
030 public final class StickyMSNurseryTraceLocal extends TraceLocal {
031
032 /****************************************************************************
033 *
034 * Instance fields.
035 */
036
037 /**
038 *
039 */
040 private final ObjectReferenceDeque modBuffer;
041
042 /**
043 * Constructor
044 */
045 public StickyMSNurseryTraceLocal(Trace trace, ObjectReferenceDeque modBuffer) {
046 super(StickyMS.SCAN_NURSERY, trace);
047 this.modBuffer = modBuffer;
048 }
049
050 /****************************************************************************
051 *
052 * Externally visible Object processing and tracing
053 */
054
055 /**
056 * {@inheritDoc}
057 */
058 @Override
059 public boolean isLive(ObjectReference object) {
060 if (object.isNull()) return false;
061 if (Space.isInSpace(StickyMS.MARK_SWEEP, object))
062 return StickyMS.msSpace.isLive(object);
063 if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(super.isLive(object));
064 return true;
065 }
066
067 /**
068 * {@inheritDoc}<p>
069 *
070 * In this instance, we refer objects in the mark-sweep space to the
071 * msSpace for tracing, and defer to the superclass for all others.
072 *
073 * @param object The object to be traced.
074 * @return The new reference to the same object instance.
075 */
076 @Override
077 @Inline
078 public ObjectReference traceObject(ObjectReference object) {
079 if (object.isNull()) return object;
080 if (Space.isInSpace(StickyMS.MARK_SWEEP, object))
081 return StickyMS.msSpace.traceObject(this, object);
082 else
083 return object;
084 }
085
086 /**
087 * Process any remembered set entries. This means enumerating the
088 * mod buffer and for each entry, marking the object as unlogged
089 * and enqueing it for scanning.
090 */
091 @Override
092 protected void processRememberedSets() {
093 logMessage(2, "processing modBuffer");
094 while (!modBuffer.isEmpty()) {
095 ObjectReference src = modBuffer.pop();
096 HeaderByte.markAsUnlogged(src);
097 processNode(src);
098 }
099 }
100 }