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.utility.statistics.Timer; 016import org.mmtk.utility.Log; 017import org.mmtk.vm.VM; 018 019import org.vmmagic.pragma.*; 020 021/** 022 * Phases of a garbage collection.<p> 023 * 024 * A concurrent phase runs concurrently with mutator activity. 025 */ 026@Uninterruptible 027public final class ConcurrentPhase extends Phase { 028 029 /**************************************************************************** 030 * Instance fields 031 */ 032 033 /** 034 * The atomic scheduled phase to use when concurrent collection is not allowed 035 */ 036 private final int atomicScheduledPhase; 037 038 /** 039 * Construct a complex phase from an array of phase IDs. 040 * 041 * @param name The name of the phase. 042 * @param atomicScheduledPhase The atomic scheduled phase 043 */ 044 protected ConcurrentPhase(String name, int atomicScheduledPhase) { 045 super(name, null); 046 this.atomicScheduledPhase = atomicScheduledPhase; 047 if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(getSchedule(this.atomicScheduledPhase) != SCHEDULE_CONCURRENT); 048 } 049 050 /** 051 * Construct a complex phase from an array of phase IDs, but using 052 * the specified timer rather than creating one. 053 * 054 * @param name The name of the phase. 055 * @param timer The timer for this phase to contribute to. 056 * @param atomicScheduledPhase The atomic scheduled phase 057 */ 058 protected ConcurrentPhase(String name, Timer timer, int atomicScheduledPhase) { 059 super(name, timer); 060 if (VM.VERIFY_ASSERTIONS) { 061 /* Timers currently unsupported on concurrent phases */ 062 VM.assertions._assert(timer == null); 063 } 064 this.atomicScheduledPhase = atomicScheduledPhase; 065 if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(getSchedule(this.atomicScheduledPhase) != SCHEDULE_CONCURRENT); 066 } 067 068 @Override 069 protected void logPhase() { 070 Log.write("ConcurrentPhase("); 071 Log.write(name); 072 Log.write(")"); 073 } 074 075 /** 076 * Return the atomic schedule phase, to be used in place of this phase when 077 * concurrent collection is not available. 078 * 079 * @return The atomic scheduled phase. 080 */ 081 protected int getAtomicScheduledPhase() { 082 return this.atomicScheduledPhase; 083 } 084}