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