37 import com.oracle.graal.bytecode.*; 38 import com.oracle.graal.hotspot.*; 39 import com.oracle.graal.hotspot.debug.*; 40 import com.oracle.graal.phases.*; 41 42 /** 43 * Implementation of {@link JavaMethod} for resolved HotSpot methods. 44 */ 45 public final class HotSpotResolvedJavaMethod extends HotSpotMethod implements ResolvedJavaMethod { 46 47 private static final long serialVersionUID = -5486975070147586588L; 48 49 /** 50 * Reference to metaspace Method object. 51 */ 52 final long metaspaceMethod; 53 54 private final HotSpotResolvedObjectType holder; 55 private/* final */int codeSize; 56 private/* final */int exceptionHandlerCount; 57 private HotSpotSignature signature; 58 private Boolean hasBalancedMonitors; 59 private Map<Object, Object> compilerStorage; 60 private HotSpotMethodData methodData; 61 private byte[] code; 62 private int compilationComplexity; 63 private CompilationTask currentTask; 64 private SpeculationLog speculationLog; 65 66 HotSpotResolvedJavaMethod(HotSpotResolvedObjectType holder, long metaspaceMethod) { 67 this.metaspaceMethod = metaspaceMethod; 68 this.holder = holder; 69 HotSpotGraalRuntime.getInstance().getCompilerToVM().initializeMethod(metaspaceMethod, this); 70 } 71 72 @Override 73 public ResolvedJavaType getDeclaringClass() { 74 return holder; 75 } 76 109 return code; 110 } 111 112 @Override 113 public int getCodeSize() { 114 return codeSize; 115 } 116 117 @Override 118 public ExceptionHandler[] getExceptionHandlers() { 119 if (exceptionHandlerCount == 0) { 120 return new ExceptionHandler[0]; 121 } 122 ExceptionHandler[] handlers = new ExceptionHandler[exceptionHandlerCount]; 123 for (int i = 0; i < exceptionHandlerCount; i++) { 124 handlers[i] = new ExceptionHandler(-1, -1, -1, -1, null); 125 } 126 return HotSpotGraalRuntime.getInstance().getCompilerToVM().initializeExceptionHandlers(metaspaceMethod, handlers); 127 } 128 129 public boolean hasBalancedMonitors() { 130 if (hasBalancedMonitors == null) { 131 hasBalancedMonitors = HotSpotGraalRuntime.getInstance().getCompilerToVM().hasBalancedMonitors(metaspaceMethod); 132 } 133 return hasBalancedMonitors; 134 } 135 136 @Override 137 public boolean isClassInitializer() { 138 return "<clinit>".equals(name) && Modifier.isStatic(getModifiers()); 139 } 140 141 @Override 142 public boolean isConstructor() { 143 return "<init>".equals(name) && !Modifier.isStatic(getModifiers()); 144 } 145 146 @Override 147 public int getMaxLocals() { 148 HotSpotVMConfig config = HotSpotGraalRuntime.getInstance().getConfig(); | 37 import com.oracle.graal.bytecode.*; 38 import com.oracle.graal.hotspot.*; 39 import com.oracle.graal.hotspot.debug.*; 40 import com.oracle.graal.phases.*; 41 42 /** 43 * Implementation of {@link JavaMethod} for resolved HotSpot methods. 44 */ 45 public final class HotSpotResolvedJavaMethod extends HotSpotMethod implements ResolvedJavaMethod { 46 47 private static final long serialVersionUID = -5486975070147586588L; 48 49 /** 50 * Reference to metaspace Method object. 51 */ 52 final long metaspaceMethod; 53 54 private final HotSpotResolvedObjectType holder; 55 private/* final */int codeSize; 56 private/* final */int exceptionHandlerCount; 57 private boolean callerSensitive; 58 private boolean forceInline; 59 private boolean dontInline; 60 private boolean ignoredBySecurityStackWalk; 61 private HotSpotSignature signature; 62 private Boolean hasBalancedMonitors; 63 private Map<Object, Object> compilerStorage; 64 private HotSpotMethodData methodData; 65 private byte[] code; 66 private int compilationComplexity; 67 private CompilationTask currentTask; 68 private SpeculationLog speculationLog; 69 70 HotSpotResolvedJavaMethod(HotSpotResolvedObjectType holder, long metaspaceMethod) { 71 this.metaspaceMethod = metaspaceMethod; 72 this.holder = holder; 73 HotSpotGraalRuntime.getInstance().getCompilerToVM().initializeMethod(metaspaceMethod, this); 74 } 75 76 @Override 77 public ResolvedJavaType getDeclaringClass() { 78 return holder; 79 } 80 113 return code; 114 } 115 116 @Override 117 public int getCodeSize() { 118 return codeSize; 119 } 120 121 @Override 122 public ExceptionHandler[] getExceptionHandlers() { 123 if (exceptionHandlerCount == 0) { 124 return new ExceptionHandler[0]; 125 } 126 ExceptionHandler[] handlers = new ExceptionHandler[exceptionHandlerCount]; 127 for (int i = 0; i < exceptionHandlerCount; i++) { 128 handlers[i] = new ExceptionHandler(-1, -1, -1, -1, null); 129 } 130 return HotSpotGraalRuntime.getInstance().getCompilerToVM().initializeExceptionHandlers(metaspaceMethod, handlers); 131 } 132 133 /** 134 * Returns true if this method has a CallerSensitive annotation. 135 * 136 * @return true if CallerSensitive annotation present, false otherwise 137 */ 138 public boolean isCallerSensitive() { 139 return callerSensitive; 140 } 141 142 /** 143 * Returns true if this method has a ForceInline annotation. 144 * 145 * @return true if ForceInline annotation present, false otherwise 146 */ 147 public boolean isForceInline() { 148 return forceInline; 149 } 150 151 /** 152 * Returns true if this method has a DontInline annotation. 153 * 154 * @return true if DontInline annotation present, false otherwise 155 */ 156 public boolean isDontInline() { 157 return dontInline; 158 } 159 160 /** 161 * Returns true if this method is one of the special methods that is ignored by security stack 162 * walks. 163 * 164 * @return true if special method ignored by security stack walks, false otherwise 165 */ 166 public boolean ignoredBySecurityStackWalk() { 167 return ignoredBySecurityStackWalk; 168 } 169 170 public boolean hasBalancedMonitors() { 171 if (hasBalancedMonitors == null) { 172 hasBalancedMonitors = HotSpotGraalRuntime.getInstance().getCompilerToVM().hasBalancedMonitors(metaspaceMethod); 173 } 174 return hasBalancedMonitors; 175 } 176 177 @Override 178 public boolean isClassInitializer() { 179 return "<clinit>".equals(name) && Modifier.isStatic(getModifiers()); 180 } 181 182 @Override 183 public boolean isConstructor() { 184 return "<init>".equals(name) && !Modifier.isStatic(getModifiers()); 185 } 186 187 @Override 188 public int getMaxLocals() { 189 HotSpotVMConfig config = HotSpotGraalRuntime.getInstance().getConfig(); |