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.controller;
014
015import org.jikesrvm.compilers.common.CompiledMethod;
016
017/**
018 * Event used by the basic recompilation organizer
019 * to notify the controller that a method is hot.
020 */
021public final class HotMethodRecompilationEvent extends HotMethodEvent implements ControllerInputEvent {
022
023  /**
024   * @param _cm the compiled method
025   * @param _numSamples the number of samples attributed to the method
026   */
027  public HotMethodRecompilationEvent(CompiledMethod _cm, double _numSamples) {
028    super(_cm, _numSamples);
029  }
030
031  /**
032   * @param _cm the compiled method
033   * @param _numSamples the number of samples attributed to the method
034   */
035  HotMethodRecompilationEvent(CompiledMethod _cm, int _numSamples) {
036    this(_cm, (double) _numSamples);
037  }
038
039  @Override
040  public String toString() {
041    return "HotMethodRecompilationEvent: " + super.toString();
042  }
043
044  /**
045   * {@inheritDoc}
046   * In this case, the method simply passes the event to the recompilation strategy.
047   */
048  @Override
049  public void process() {
050    ControllerPlan plan = Controller.recompilationStrategy.considerHotMethod(getCompiledMethod(), this);
051
052    ControllerMemory.incrementNumMethodsConsidered();
053
054    // If plan is still null we decided not to recompile.
055    if (plan != null) {
056      plan.execute();
057    }
058  }
059}