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