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