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.compilers.common.CompiledMethod;
016    
017    /**
018     * Event used by the basic recompilation organizer
019     * to notify the controller that a method is hot.
020     */
021    public 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      public String toString() {
040        return "HotMethodRecompilationEvent: " + super.toString();
041      }
042    
043      /**
044       * This function defines how the controller handles a
045       * HotMethodRecompilationEvent.  Simply passes the event to the
046       * recompilation strategy.
047       */
048      public void process() {
049        ControllerPlan plan = Controller.recompilationStrategy.considerHotMethod(getCompiledMethod(), this);
050    
051        ControllerMemory.incrementNumMethodsConsidered();
052    
053        // If plan is still null we decided not to recompile.
054        if (plan != null) {
055          plan.execute();
056        }
057      }
058    }