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; 014 015import org.mmtk.vm.VM; 016import org.vmmagic.pragma.*; 017 018/** 019 * This class (and its sub-classes) implement <i>per-collector thread</i> 020 * behavior and state.<p> 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. 026 * 027 * @see CollectorContext 028 */ 029@Uninterruptible 030public abstract class StopTheWorldCollector extends SimpleCollector { 031 032 /**************************************************************************** 033 * 034 * Collection. 035 */ 036 037 /** Perform garbage collection */ 038 @Override 039 public void collect() { 040 Phase.beginNewPhaseStack(Phase.scheduleComplex(global().collection)); 041 } 042 043 /** Perform some concurrent garbage collection */ 044 @Unpreemptible 045 public final void concurrentCollect() { 046 VM.assertions.fail("concurrentCollect called on StopTheWorld collector"); 047 } 048 049 /** 050 * Perform some concurrent collection work. 051 * 052 * @param phaseId The unique phase identifier 053 */ 054 public void concurrentCollectionPhase(short phaseId) { 055 VM.assertions.fail("concurrentCollectionPhase triggered on StopTheWorld collector"); 056 } 057 058 /**************************************************************************** 059 * 060 * Miscellaneous. 061 */ 062 063 /** @return The active global plan as a <code>StopTheWorld</code> instance. */ 064 @Inline 065 private static StopTheWorld global() { 066 return (StopTheWorld) VM.activePlan.global(); 067 } 068}