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