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.compilers.opt; 014 015 import org.jikesrvm.compilers.opt.ir.IR; 016 import org.jikesrvm.compilers.opt.ir.Instruction; 017 018 /** 019 * This interface defines the functionality necessary to be a 020 * InstrumentedEventCounterManager. The goal of this interface is 021 * to provide a mechanism for instrumentation phases to performing 022 * counting of events, but to keep the implementation of the counters 023 * completely hidden. 024 */ 025 public abstract class InstrumentedEventCounterManager { 026 static final boolean DEBUG = false; 027 028 /** 029 * This method is called to called to tell the counter manager to 030 * reserve the needed space. A handle is returned telling where 031 * the counter space begins. 032 * 033 * @param countersNeeded The number of counters being requested 034 * @return A "handle", or name for the counter space reserved. 035 */ 036 public abstract int registerCounterSpace(int countersNeeded); 037 038 /** 039 * This method is called to change the number of counters needed. 040 * 041 * @param handle The handle describing which the data to be resized 042 * @param countersNeeded The number of counters needed 043 */ 044 public abstract void resizeCounterSpace(int handle, int countersNeeded); 045 046 /** 047 * Get the value of a counter. 048 * 049 * @param handle The counter space to look in 050 * @param location The counter whose value to return 051 */ 052 public abstract double getCounter(int handle, int location); 053 054 /** 055 * Set the value of a counter. 056 * 057 * @param handle The counter space to look in 058 * @param location The counter whose value to return 059 * @param value The new value of the counter 060 */ 061 public abstract void setCounter(int handle, int location, double value); 062 063 /** 064 * Create a place holder instruction to represent the counted event. 065 * 066 * @param handle The counter space to look in 067 * @param location The counter whose value to return 068 * @param incrementValue The value to add to the counter 069 * @return The instruction to increment the given counter 070 */ 071 public abstract Instruction createEventCounterInstruction(int handle, int location, double incrementValue); 072 073 /** 074 * Take an event counter instruction and mutate it into IR instructions that 075 * will do the actual counting. 076 */ 077 public abstract void mutateOptEventCounterInstruction(Instruction i, IR ir); 078 079 /** 080 * Allow a counter to be inserted into a baseline compiled method. 081 * Still under construction. 082 */ 083 public abstract void insertBaselineCounter(); 084 }