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.specialization; 014 015 import org.jikesrvm.classloader.NormalMethod; 016 import org.jikesrvm.compilers.common.CompiledMethod; 017 018 /** 019 * This is the top-level class to support specialized versions of Java methods 020 */ 021 public final class SpecializedMethod { 022 /** 023 * The method that was specialized 024 */ 025 final NormalMethod method; 026 027 /** 028 * Corresponding compiled method 029 */ 030 CompiledMethod compiledMethod; 031 032 /** 033 * Specialized Method index into the SpecializedMethods table 034 */ 035 final int smid; 036 037 /** 038 * Encodes the rules for generating the specialized code. 039 */ 040 final SpecializationContext context; 041 042 /** 043 * constructor for OPT compiler. 044 */ 045 SpecializedMethod(NormalMethod source, SpecializationContext context) { 046 this.method = source; 047 this.context = context; 048 this.smid = SpecializedMethodPool.createSpecializedMethodID(); 049 } 050 051 /** 052 * generate the specialized code for this method 053 */ 054 void compile() { 055 compiledMethod = context.specialCompile(method); 056 } 057 058 public NormalMethod getMethod() { 059 return method; 060 } 061 062 public SpecializationContext getSpecializationContext() { 063 return context; 064 } 065 066 public CompiledMethod getCompiledMethod() { 067 return compiledMethod; 068 } 069 070 public void setCompiledMethod(CompiledMethod cm) { 071 compiledMethod = cm; 072 } 073 074 public int getSpecializedMethodIndex() { 075 return smid; 076 } 077 078 @Override 079 public String toString() { 080 return "Specialized " + method + " (Context: " + context + ")"; 081 } 082 }