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.jikesrvm.adaptive.recompilation.instrumentation;
014
015import org.jikesrvm.adaptive.util.AOSOptions;
016import org.vmmagic.pragma.Uninterruptible;
017
018/**
019 *  Contains necessary infrastructure to perform counter-based
020 *  sampling used with the instrumentation sampling code (PLDI'01)
021 *  (see InstrumentationSamplingFramework)
022 * */
023@Uninterruptible
024public final class CounterBasedSampling {
025  static final boolean DEBUG = false;
026
027  /**
028   * Holds the value that is used to reset the global counter after
029   * a sample is taken.
030   */
031  static int resetValue = 100;
032
033  /**
034   *  The global counter.
035   */
036  static int globalCounter = resetValue;
037
038  /**
039   * Initializes counter based sampling. Called when the VM boots.
040   *
041   * @param options the options for the AOS (and therefore also
042   *  counter-based sampling)
043   */
044  public static void boot(AOSOptions options) {
045    // Initialize the counter values
046    resetValue = options.COUNTER_BASED_SAMPLE_INTERVAL - 1;
047    globalCounter = resetValue;
048
049  }
050}