| //===------------------------- Scanning.java ------------------------------===// |
| // |
| // The VMKit project |
| // |
| // This file is distributed under the University of Illinois Open Source |
| // License. See LICENSE.TXT for details. |
| // |
| //===----------------------------------------------------------------------===// |
| |
| package org.j3.mmtk; |
| |
| import org.mmtk.plan.TraceLocal; |
| import org.mmtk.plan.TransitiveClosure; |
| |
| import org.vmmagic.unboxed.*; |
| import org.vmmagic.pragma.*; |
| |
| @Uninterruptible |
| public final class Scanning extends org.mmtk.vm.Scanning { |
| |
| @Inline |
| public native void scanObject(TransitiveClosure trace, ObjectReference object); |
| |
| /** |
| * Invoke a specialized scan method. Note that these methods must have been allocated |
| * explicitly through Plan and PlanConstraints. |
| * |
| * @param id The specialized method id |
| * @param trace The trace the method has been specialized for |
| * @param object The object to be scanned |
| */ |
| @Inline |
| public native void specializedScanObject(int id, TransitiveClosure trace, ObjectReference object); |
| |
| |
| /** |
| * Precopying of a object's fields, processing each pointer field encountered. |
| * |
| * @param trace The trace being used. |
| * @param object The object to be scanned. |
| */ |
| @Inline |
| public native void precopyChildren(TraceLocal trace, ObjectReference object); |
| |
| /** |
| * Prepares for using the <code>computeAllRoots</code> method. The |
| * thread counter allows multiple GC threads to co-operatively |
| * iterate through the thread data structure (if load balancing |
| * parallel GC threads were not important, the thread counter could |
| * simply be replaced by a for loop). |
| */ |
| public native void resetThreadCounter(); |
| |
| /** |
| * Pre-copy all potentially movable instances used in the course of |
| * GC. This includes the thread objects representing the GC threads |
| * themselves. It is crucial that these instances are forwarded |
| * <i>prior</i> to the GC proper. Since these instances <i>are |
| * not</i> enqueued for scanning, it is important that when roots |
| * are computed the same instances are explicitly scanned and |
| * included in the set of roots. The existence of this method |
| * allows the actions of calculating roots and forwarding GC |
| * instances to be decoupled. |
| * |
| * The thread table is scanned in parallel by each processor, by striding |
| * through the table at a gap of chunkSize*numProcs. Feel free to adjust |
| * chunkSize if you want to tune a parallel collector. |
| * |
| * Explicitly no-inlined to prevent over-inlining of collectionPhase. |
| * |
| * TODO Experiment with specialization to remove virtual dispatch ? |
| */ |
| @NoInline |
| public native void preCopyGCInstances(TraceLocal trace); |
| |
| /** |
| * Computes static roots. This method establishes all such roots for |
| * collection and places them in the root locations queue. This method |
| * should not have side effects (such as copying or forwarding of |
| * objects). There are a number of important preconditions: |
| * |
| * <ul> |
| * <li> All objects used in the course of GC (such as the GC thread |
| * objects) need to be "pre-copied" prior to calling this method. |
| * <li> The <code>threadCounter</code> must be reset so that load |
| * balancing parallel GC can share the work of scanning threads. |
| * </ul> |
| * |
| * @param trace The trace to use for computing roots. |
| */ |
| public native void computeStaticRoots(TraceLocal trace); |
| |
| /** |
| * Computes global roots. This method establishes all such roots for |
| * collection and places them in the root locations queue. This method |
| * should not have side effects (such as copying or forwarding of |
| * objects). There are a number of important preconditions: |
| * |
| * <ul> |
| * <li> All objects used in the course of GC (such as the GC thread |
| * objects) need to be "pre-copied" prior to calling this method. |
| * <li> The <code>threadCounter</code> must be reset so that load |
| * balancing parallel GC can share the work of scanning threads. |
| * </ul> |
| * |
| * @param trace The trace to use for computing roots. |
| */ |
| public native void computeGlobalRoots(TraceLocal trace); |
| |
| /** |
| * Computes roots pointed to by threads, their associated registers |
| * and stacks. This method places these roots in the root values, |
| * root locations and interior root locations queues. This method |
| * should not have side effects (such as copying or forwarding of |
| * objects). There are a number of important preconditions: |
| * |
| * <ul> |
| * <li> All objects used in the course of GC (such as the GC thread |
| * objects) need to be "pre-copied" prior to calling this method. |
| * <li> The <code>threadCounter</code> must be reset so that load |
| * balancing parallel GC can share the work of scanning threads. |
| * </ul> |
| * |
| * TODO rewrite to avoid the per-thread synchronization, like precopy. |
| * |
| * @param trace The trace to use for computing roots. |
| */ |
| public native void computeThreadRoots(TraceLocal trace); |
| |
| /** |
| * Compute all roots out of the VM's boot image (if any). This method is a no-op |
| * in the case where the VM does not maintain an MMTk-visible Java space. However, |
| * when the VM does maintain a space (such as a boot image) which is visible to MMTk, |
| * that space could either be scanned by MMTk as part of its transitive closure over |
| * the whole heap, or as a (considerable) performance optimization, MMTk could avoid |
| * scanning the space if it is aware of all pointers out of that space. This method |
| * is used to establish the root set out of the scannable space in the case where |
| * such a space exists. |
| * |
| * @param trace The trace object to use to report root locations. |
| */ |
| public void computeBootImageRoots(TraceLocal trace) { |
| } |
| } |
| |