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.plan.nogc;
014
015import org.mmtk.plan.*;
016
017import org.mmtk.vm.VM;
018
019import org.vmmagic.pragma.*;
020
021/**
022 * This class implements <i>per-collector thread</i> behavior and state
023 * for the <i>NoGC</i> plan, which simply allocates (without ever collecting
024 * until the available space is exhausted.<p>
025 *
026 * Specifically, this class <i>would</i> define <i>NoGC</i> collection time semantics,
027 * however, since this plan never collects, this class consists only of stubs which
028 * may be useful as a template for implementing a basic collector.
029 *
030 * @see NoGC
031 * @see NoGCMutator
032 * @see CollectorContext
033 */
034@Uninterruptible
035public class NoGCCollector extends ParallelCollector {
036
037  /************************************************************************
038   * Instance fields
039   */
040
041  /**
042   *
043   */
044  private final NoGCTraceLocal trace = new NoGCTraceLocal(global().trace);
045  protected final TraceLocal currentTrace = trace;
046
047
048  /****************************************************************************
049   * Collection
050   */
051
052  /**
053   * Perform a garbage collection
054   */
055  @Override
056  public final void collect() {
057    VM.assertions.fail("GC Triggered in NoGC Plan. Is -X:gc:ignoreSystemGC=true ?");
058  }
059
060  @Inline
061  @Override
062  public final void collectionPhase(short phaseId, boolean primary) {
063    VM.assertions.fail("GC Triggered in NoGC Plan.");
064    /*
065    if (phaseId == NoGC.PREPARE) {
066    }
067
068    if (phaseId == NoGC.CLOSURE) {
069    }
070
071    if (phaseId == NoGC.RELEASE) {
072    }
073
074    super.collectionPhase(phaseId, primary);
075    */
076  }
077
078  /****************************************************************************
079   * Miscellaneous
080   */
081
082  /** @return The active global plan as a <code>NoGC</code> instance. */
083  @Inline
084  private static NoGC global() {
085    return (NoGC) VM.activePlan.global();
086  }
087
088  @Override
089  public final TraceLocal getCurrentTrace() {
090    return currentTrace;
091  }
092}