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.measurements.instrumentation; 014 015import org.jikesrvm.VM; 016import org.jikesrvm.adaptive.measurements.Reportable; 017import org.jikesrvm.compilers.opt.InstrumentedEventCounterManager; 018 019/** 020 * An extension of StringEventCounterData so that the printing can 021 * be specialized for yieldpoints. Otherwise, the functionality is 022 * identical. 023 */ 024public final class YieldpointCounterData extends StringEventCounterData implements Reportable { 025 026 static final boolean DEBUG = false; 027 028 /** 029 * Constructor 030 * 031 * @param manager the manager that will provide the counter space 032 **/ 033 YieldpointCounterData(InstrumentedEventCounterManager manager) { 034 super(manager, "Yieldpoint Counter"); 035 036 automaticallyGrowCounters(true); 037 } 038 039 /** 040 * Called at end when data should dump its contents. 041 */ 042 @Override 043 public void report() { 044 // Turn off future instrumentation so that the data structures do 045 // not change while we are iterating over them 046 Instrumentation.disableInstrumentation(); 047 048 VM.sysWrite("Printing " + dataName + ":\n"); 049 VM.sysWrite("--------------------------------------------------\n"); 050 double total = 0; 051 double methodEntryTotal = 0; 052 double backedgeTotal = 0; 053 for (String stringName : stringToCounterMap.keySet()) { 054 Integer counterNum = stringToCounterMap.get(stringName); 055 double count = getCounter(counterNum); 056 057 VM.sysWrite(count + " " + stringName + "\n"); 058 total += count; 059 060 // If it's a method entry event 061 if (stringName.indexOf("METHOD ENTRY") != -1) { 062 methodEntryTotal += count; 063 } 064 065 if (stringName.indexOf("BACKEDGE") != -1) { 066 backedgeTotal += count; 067 } 068 069 } 070 VM.sysWrite("Total backedges: " + backedgeTotal + "\n"); 071 VM.sysWrite("Method Entry Total: " + methodEntryTotal + "\n"); 072 VM.sysWrite("Total Yieldpoints: " + total + "\n"); 073 } 074 075} 076 077