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;
014
015 import org.mmtk.vm.VM;
016 import org.vmmagic.pragma.*;
017
018 /**
019 * This class (and its sub-classes) implement <i>per-collector thread</i>
020 * behavior and state.
021 *
022 * MMTk assumes that the VM instantiates instances of CollectorContext
023 * in thread local storage (TLS) for each thread participating in
024 * collection. Accesses to this state are therefore assumed to be
025 * low-cost during mutator time.<p>
026 *
027 * @see CollectorContext
028 */
029 @Uninterruptible
030 public abstract class StopTheWorldCollector extends SimpleCollector {
031
032 /****************************************************************************
033 *
034 * Collection.
035 */
036
037 /** Perform garbage collection */
038 public void collect() {
039 Phase.beginNewPhaseStack(Phase.scheduleComplex(global().collection));
040 }
041
042 /** Perform some concurrent garbage collection */
043 public final void concurrentCollect() {
044 VM.assertions.fail("concurrentCollect called on StopTheWorld collector");
045 }
046
047 /**
048 * Perform some concurrent collection work.
049 *
050 * @param phaseId The unique phase identifier
051 */
052 public void concurrentCollectionPhase(short phaseId) {
053 VM.assertions.fail("concurrentCollectionPhase triggered on StopTheWorld collector");
054 }
055
056 /****************************************************************************
057 *
058 * Miscellaneous.
059 */
060
061 /** @return The active global plan as a <code>StopTheWorld</code> instance. */
062 @Inline
063 private static StopTheWorld global() {
064 return (StopTheWorld) VM.activePlan.global();
065 }
066 }