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.vm;
014
015 import org.mmtk.plan.TraceLocal;
016 import org.mmtk.plan.TransitiveClosure;
017 import org.mmtk.utility.Constants;
018
019 import org.vmmagic.pragma.Uninterruptible;
020 import org.vmmagic.unboxed.*;
021
022 @Uninterruptible public abstract class Scanning implements Constants {
023 /**
024 * Delegated scanning of a object, processing each pointer field
025 * encountered.
026 *
027 * @param object The object to be scanned.
028 */
029 public abstract void scanObject(TransitiveClosure trace, ObjectReference object);
030
031 /**
032 * Invoke a specialized scan method. Note that these methods must have been allocated
033 * explicitly through Plan and PlanConstraints.
034 *
035 * @param id The specialized method id
036 * @param trace The trace the method has been specialized for
037 * @param object The object to be scanned
038 */
039 public abstract void specializedScanObject(int id, TransitiveClosure trace, ObjectReference object);
040
041 /**
042 * Prepares for using the <code>computeAllRoots</code> method. The
043 * thread counter allows multiple GC threads to co-operatively
044 * iterate through the thread data structure (if load balancing
045 * parallel GC threads were not important, the thread counter could
046 * simply be replaced by a for loop).
047 */
048 public abstract void resetThreadCounter();
049
050 /**
051 * Called the first time during a collection that thread's stacks
052 * have been scanned. This can be used (for example) to clean up
053 * obsolete compiled methods that are no longer being executed.
054 */
055 public abstract void notifyInitialThreadScanComplete();
056
057 /**
058 * Computes static roots. This method establishes all such roots for
059 * collection and places them in the root locations queue. This method
060 * should not have side effects (such as copying or forwarding of
061 * objects). There are a number of important preconditions:
062 *
063 * <ul>
064 * <li> All objects used in the course of GC (such as the GC thread
065 * objects) need to be "pre-copied" prior to calling this method.
066 * <li> The <code>threadCounter</code> must be reset so that load
067 * balancing parallel GC can share the work of scanning threads.
068 * </ul>
069 *
070 * @param trace The trace to use for computing roots.
071 */
072 public abstract void computeStaticRoots(TraceLocal trace);
073
074 /**
075 * Computes global roots. This method establishes all such roots for
076 * collection and places them in the root locations queue. This method
077 * should not have side effects (such as copying or forwarding of
078 * objects). There are a number of important preconditions:
079 *
080 * <ul>
081 * <li> All objects used in the course of GC (such as the GC thread
082 * objects) need to be "pre-copied" prior to calling this method.
083 * <li> The <code>threadCounter</code> must be reset so that load
084 * balancing parallel GC can share the work of scanning threads.
085 * </ul>
086 *
087 * @param trace The trace to use for computing roots.
088 */
089 public abstract void computeGlobalRoots(TraceLocal trace);
090
091 /**
092 * Computes roots pointed to by threads, their associated registers
093 * and stacks. This method places these roots in the root values,
094 * root locations and interior root locations queues. This method
095 * should not have side effects (such as copying or forwarding of
096 * objects). There are a number of important preconditions:
097 *
098 * <ul>
099 * <li> All objects used in the course of GC (such as the GC thread
100 * objects) need to be "pre-copied" prior to calling this method.
101 * <li> The <code>threadCounter</code> must be reset so that load
102 * balancing parallel GC can share the work of scanning threads.
103 * </ul>
104 *
105 * @param trace The trace to use for computing roots.
106 */
107 public abstract void computeThreadRoots(TraceLocal trace);
108
109 /**
110 * Compute all roots out of the VM's boot image (if any). This method is a no-op
111 * in the case where the VM does not maintain an MMTk-visible Java space. However,
112 * when the VM does maintain a space (such as a boot image) which is visible to MMTk,
113 * that space could either be scanned by MMTk as part of its transitive closure over
114 * the whole heap, or as a (considerable) performance optimization, MMTk could avoid
115 * scanning the space if it is aware of all pointers out of that space. This method
116 * is used to establish the root set out of the scannable space in the case where
117 * such a space exists.
118 *
119 * @param trace The trace object to use to report root locations.
120 */
121 public abstract void computeBootImageRoots(TraceLocal trace);
122 }