13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 package jdk.vm.ci.hotspot; 24 25 import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; 26 import jdk.vm.ci.code.InstalledCode; 27 import jdk.vm.ci.code.InvalidInstalledCodeException; 28 import jdk.vm.ci.meta.JavaKind; 29 import jdk.vm.ci.meta.JavaType; 30 import jdk.vm.ci.meta.ResolvedJavaMethod; 31 32 /** 33 * Implementation of {@link InstalledCode} for code installed as an nmethod. The nmethod stores a 34 * weak reference to an instance of this class. This is necessary to keep the nmethod from being 35 * unloaded while the associated {@link HotSpotNmethod} instance is alive. 36 * <p> 37 * Note that there is no (current) way for the reference from an nmethod to a {@link HotSpotNmethod} 38 * instance to be anything but weak. This is due to the fact that HotSpot does not treat nmethods as 39 * strong GC roots. 40 */ 41 public class HotSpotNmethod extends HotSpotInstalledCode { 42 43 /** 44 * This (indirect) Method* reference is safe since class redefinition preserves all methods 45 * associated with nmethods in the code cache. 46 */ 47 private final HotSpotResolvedJavaMethod method; 48 49 private final boolean isDefault; 50 51 public HotSpotNmethod(HotSpotResolvedJavaMethod method, String name, boolean isDefault) { 52 super(name); 53 this.method = method; 54 this.isDefault = isDefault; 55 } 56 57 public boolean isDefault() { 58 return isDefault; 59 } 60 61 public ResolvedJavaMethod getMethod() { 62 return method; 63 } 64 65 @Override 66 public void invalidate() { 67 compilerToVM().invalidateInstalledCode(this); 68 } 69 70 @Override 71 public String toString() { 72 return String.format("InstalledNmethod[method=%s, codeBlob=0x%x, isDefault=%b, name=%s]", method, getAddress(), isDefault, name); 73 } 74 75 protected boolean checkThreeObjectArgs() { 76 assert method.getSignature().getParameterCount(!method.isStatic()) == 3; | 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 package jdk.vm.ci.hotspot; 24 25 import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; 26 import jdk.vm.ci.code.InstalledCode; 27 import jdk.vm.ci.code.InvalidInstalledCodeException; 28 import jdk.vm.ci.meta.JavaKind; 29 import jdk.vm.ci.meta.JavaType; 30 import jdk.vm.ci.meta.ResolvedJavaMethod; 31 32 /** 33 * Implementation of {@link InstalledCode} for code installed as an nmethod. 34 * 35 * When a {@link HotSpotNmethod} dies, it triggers unloading of the nmethod unless 36 * {@link #isDefault() == true}. 37 */ 38 public class HotSpotNmethod extends HotSpotInstalledCode { 39 40 /** 41 * This (indirect) Method* reference is safe since class redefinition preserves all methods 42 * associated with nmethods in the code cache. 43 */ 44 private final HotSpotResolvedJavaMethod method; 45 46 private final boolean isDefault; 47 48 public HotSpotNmethod(HotSpotResolvedJavaMethod method, String name, boolean isDefault) { 49 super(name); 50 this.method = method; 51 this.isDefault = isDefault; 52 } 53 54 /** 55 * Determines if the nmethod associated with this object is the compiled entry point for 56 * {@link #getMethod()}. If {@code false}, then the nmethod is unloaded when the VM determines 57 * this object has died. 58 */ 59 public boolean isDefault() { 60 return isDefault; 61 } 62 63 public ResolvedJavaMethod getMethod() { 64 return method; 65 } 66 67 @Override 68 public void invalidate() { 69 compilerToVM().invalidateInstalledCode(this); 70 } 71 72 @Override 73 public String toString() { 74 return String.format("InstalledNmethod[method=%s, codeBlob=0x%x, isDefault=%b, name=%s]", method, getAddress(), isDefault, name); 75 } 76 77 protected boolean checkThreeObjectArgs() { 78 assert method.getSignature().getParameterCount(!method.isStatic()) == 3; |