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