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.utility.sanitychecker; 014 015 import org.mmtk.plan.Plan; 016 import org.mmtk.plan.Simple; 017 import org.mmtk.utility.Constants; 018 019 import org.mmtk.vm.VM; 020 021 import org.vmmagic.pragma.*; 022 023 /** 024 * This class performs sanity checks for Simple collectors. 025 */ 026 @Uninterruptible 027 public final class SanityCheckerLocal implements Constants { 028 029 /** Trace */ 030 final SanityRootTraceLocal rootTraceLocal; 031 032 /**************************************************************************** 033 * Constants 034 */ 035 public SanityCheckerLocal() { 036 rootTraceLocal = new SanityRootTraceLocal(Plan.sanityChecker.rootTrace); 037 } 038 039 /** 040 * Perform any sanity checking collection phases. 041 * 042 * @param phaseId The id to process 043 * @param primary Perform local single threaded actions on this thread 044 * @return True if the phase was handled. 045 */ 046 @NoInline 047 public boolean collectionPhase(int phaseId, boolean primary) { 048 if (phaseId == Simple.SANITY_PREPARE) { 049 rootTraceLocal.prepare(); 050 return true; 051 } 052 053 if (phaseId == Simple.SANITY_ROOTS) { 054 VM.scanning.computeGlobalRoots(rootTraceLocal); 055 VM.scanning.computeThreadRoots(rootTraceLocal); 056 VM.scanning.computeStaticRoots(rootTraceLocal); 057 if (Plan.SCAN_BOOT_IMAGE) { 058 VM.scanning.computeBootImageRoots(rootTraceLocal); 059 } 060 rootTraceLocal.flush(); 061 return true; 062 } 063 064 if (phaseId == Simple.SANITY_COPY_ROOTS) { 065 if (primary) { 066 rootTraceLocal.copyRootValuesTo(Plan.sanityChecker.checkTraceLocal); 067 } 068 return true; 069 } 070 071 if (phaseId == Simple.SANITY_RELEASE) { 072 rootTraceLocal.release(); 073 return true; 074 } 075 076 return false; 077 } 078 }