001/* 002 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. 008 * 009 * This code is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 011 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 012 * version 2 for more details (a copy is included in the LICENSE file that 013 * accompanied this code). 014 * 015 * You should have received a copy of the GNU General Public License version 016 * 2 along with this work; if not, write to the Free Software Foundation, 017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 018 * 019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 020 * or visit www.oracle.com if you need additional information or have any 021 * questions. 022 */ 023package jdk.internal.jvmci.code; 024 025/** 026 * Represents a compiled instance of a method. It may have been invalidated or removed in the 027 * meantime. 028 */ 029public class InstalledCode { 030 031 /** 032 * Raw address of this code blob. 033 */ 034 private long address; 035 036 /** 037 * Counts how often the address field was reassigned. 038 */ 039 private long version; 040 041 protected final String name; 042 043 public InstalledCode(String name) { 044 this.name = name; 045 } 046 047 public final void setAddress(long address) { 048 this.address = address; 049 version++; 050 } 051 052 /** 053 * @return the address of this code blob 054 */ 055 public final long getAddress() { 056 return address; 057 } 058 059 /** 060 * @return the address of this code blob 061 */ 062 public final long getVersion() { 063 return version; 064 } 065 066 /** 067 * Returns the name of this code blob. 068 */ 069 public String getName() { 070 return name; 071 } 072 073 /** 074 * Returns the start address of this installed code if it is {@linkplain #isValid() valid}, 0 075 * otherwise. 076 */ 077 public long getStart() { 078 return 0; 079 } 080 081 /** 082 * Returns the number of instruction bytes for this code. 083 */ 084 public long getCodeSize() { 085 return 0; 086 } 087 088 /** 089 * Returns a copy of this installed code if it is {@linkplain #isValid() valid}, null otherwise. 090 */ 091 public byte[] getCode() { 092 return null; 093 } 094 095 /** 096 * @return true if the code represented by this object is still valid, false otherwise (may 097 * happen due to deopt, etc.) 098 */ 099 public boolean isValid() { 100 return address != 0; 101 } 102 103 /** 104 * Invalidates this installed code such that any subsequent invocation will throw an 105 * {@link InvalidInstalledCodeException}. 106 */ 107 public void invalidate() { 108 throw new UnsupportedOperationException(); 109 } 110 111 /** 112 * Executes the installed code with a variable number of arguments. 113 * 114 * @param args the array of object arguments 115 * @return the value returned by the executed code 116 */ 117 @SuppressWarnings("unused") 118 public Object executeVarargs(Object... args) throws InvalidInstalledCodeException { 119 throw new UnsupportedOperationException(); 120 } 121}