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 */
013package org.mmtk.vm;
014
015import org.mmtk.plan.TraceLocal;
016import org.vmmagic.pragma.Uninterruptible;
017
018/**
019 * This class manages SoftReferences, WeakReferences, and
020 * PhantomReferences.
021 */
022@Uninterruptible
023public abstract class ReferenceProcessor {
024
025  public enum Semantics { SOFT, WEAK, PHANTOM }
026
027  /**
028   * Clear the contents of the table. This is called when reference types are
029   * disabled to make it easier for VMs to change this setting at runtime.
030   */
031  public abstract void clear();
032
033  /**
034   * Scan through the list of references.
035   *
036   * @param trace the thread local trace element.
037   * @param nursery {@code true} if it is safe to only scan new references.
038   * @param retain whether to retain those references whose referents are not
039   *  reachable
040   */
041  public abstract void scan(TraceLocal trace, boolean nursery, boolean retain);
042
043  /**
044   * Iterate over all references and forward.
045   *
046   * @param trace The MMTk trace to forward to
047   * @param nursery The nursery collection hint
048   */
049  public abstract void forward(TraceLocal trace, boolean nursery);
050
051  /**
052   * @return the number of references objects on the queue
053   */
054  public abstract int countWaitingReferences();
055}