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.options; 014 015 import org.vmmagic.pragma.*; 016 017 /** 018 * The granularity of the trace being produced. 019 */ 020 public final class TraceRate extends org.vmutil.options.IntOption 021 implements org.mmtk.utility.Constants { 022 /** 023 * Create the option. 024 */ 025 public TraceRate() { 026 super(Options.set, "Trace Rate", 027 "The granularity of the trace being produced. By default, the trace has the maximum possible granularity.", 028 Integer.MAX_VALUE); 029 } 030 031 /** 032 * Return the appropriate value. 033 * 034 * @return the trace rate. 035 */ 036 @Override 037 @Uninterruptible 038 public int getValue() { 039 return (this.value < BYTES_IN_ADDRESS) ? 1 : (this.value >> LOG_BYTES_IN_ADDRESS); 040 } 041 042 /** 043 * Trace rate must be positive. 044 */ 045 @Override 046 protected void validate() { 047 failIf(value <= 0, "Can not have a negative trace rate"); 048 } 049 }