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.controller; 014 015 import org.jikesrvm.adaptive.database.callgraph.PartialCallGraph; 016 import org.jikesrvm.adaptive.measurements.RuntimeMeasurements; 017 import org.jikesrvm.adaptive.measurements.listeners.CallDensityListener; 018 import org.jikesrvm.adaptive.util.AOSOptions; 019 020 /** 021 * Collection of static methods to assist with adaptive inlining. 022 */ 023 public class AdaptiveInlining { 024 025 /** 026 * A listener that tracks and can report the call density 027 * of the program (fraction of yieldpoints that are taken 028 * at prologue/epilogues). 029 */ 030 private static final CallDensityListener callDensityListener = new CallDensityListener(); 031 032 /** 033 * Set parameters. 034 * Must be called after parsing command-line. 035 */ 036 static void boot(AOSOptions options) { 037 // create and register the dcg as a decayable object 038 // Give it an initial seed weight that approximates the old step 039 // function for edge hotness. The intent is that early on 040 // (until decay decreases this initial weight), we are conservative in 041 // marking an edge as hot. 042 Controller.dcg = new PartialCallGraph(options.INLINE_AI_SEED_MULTIPLIER * (1 / options.INLINE_AI_HOT_CALLSITE_THRESHOLD)); 043 RuntimeMeasurements.registerDecayableObject(Controller.dcg); 044 045 // Track call density: fraction of timer interrupts taken in prologue/epilogue 046 RuntimeMeasurements.installTimerNullListener(callDensityListener); 047 callDensityListener.activate(); 048 049 if (options.GATHER_PROFILE_DATA) { 050 RuntimeMeasurements.registerReportableObject(Controller.dcg); 051 } 052 } 053 054 public static double adjustedWeight(double weight) { 055 return weight / (Controller.dcg.getTotalEdgeWeights()) * callDensityListener.callDensity(); 056 } 057 }