use of jdk.vm.ci.meta.ExceptionHandler in project graal by oracle.
the class BciBlockMapping method handleExceptions.
private ExceptionDispatchBlock handleExceptions(BciBlock[] blockMap, int bci) {
ExceptionDispatchBlock lastHandler = null;
for (int i = exceptionHandlers.length - 1; i >= 0; i--) {
ExceptionHandler h = exceptionHandlers[i];
if (h.getStartBCI() <= bci && bci < h.getEndBCI()) {
if (h.isCatchAll()) {
// Discard all information about succeeding exception handlers, since they can
// never be reached.
lastHandler = null;
}
// We do not reuse exception dispatch blocks, because nested exception handlers
// might have problems reasoning about the correct frame state.
ExceptionDispatchBlock curHandler = new ExceptionDispatchBlock();
blocksNotYetAssignedId++;
curHandler.startBci = -1;
curHandler.endBci = -1;
curHandler.deoptBci = bci;
curHandler.handler = h;
curHandler.addSuccessor(blockMap[h.getHandlerBCI()]);
if (lastHandler != null) {
curHandler.addSuccessor(lastHandler);
}
lastHandler = curHandler;
}
}
return lastHandler;
}
use of jdk.vm.ci.meta.ExceptionHandler in project graal by oracle.
the class BciBlockMapping method makeExceptionEntries.
private void makeExceptionEntries(BciBlock[] blockMap) {
// start basic blocks at all exception handler blocks and mark them as exception entries
for (ExceptionHandler h : this.exceptionHandlers) {
BciBlock xhandler = makeBlock(blockMap, h.getHandlerBCI());
xhandler.isExceptionEntry = true;
}
}
use of jdk.vm.ci.meta.ExceptionHandler in project graal by oracle.
the class ClassfileBytecode method getExceptionHandlers.
@Override
public ExceptionHandler[] getExceptionHandlers() {
if (exceptionTableBytes == null) {
return new ExceptionHandler[0];
}
final int exceptionTableLength = exceptionTableBytes.length / EXCEPTION_HANDLER_TABLE_SIZE_IN_BYTES;
ExceptionHandler[] handlers = new ExceptionHandler[exceptionTableLength];
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(exceptionTableBytes));
for (int i = 0; i < exceptionTableLength; i++) {
try {
final int startPc = stream.readUnsignedShort();
final int endPc = stream.readUnsignedShort();
final int handlerPc = stream.readUnsignedShort();
int catchTypeIndex = stream.readUnsignedShort();
JavaType catchType;
if (catchTypeIndex == 0) {
catchType = null;
} else {
// opcode is not used
final int opcode = -1;
catchType = constantPool.lookupType(catchTypeIndex, opcode);
// Check for Throwable which catches everything.
if (catchType.toJavaName().equals("java.lang.Throwable")) {
catchTypeIndex = 0;
catchType = null;
}
}
handlers[i] = new ExceptionHandler(startPc, endPc, handlerPc, catchTypeIndex, catchType);
} catch (IOException e) {
throw new GraalError(e);
}
}
return handlers;
}
use of jdk.vm.ci.meta.ExceptionHandler in project graal by oracle.
the class UniverseBuilder method makeMethod.
private void makeMethod(AnalysisMethod aMethod) {
HostedType holder;
holder = makeType(aMethod.getDeclaringClass());
Signature signature = makeSignature(aMethod.getSignature(), holder);
ConstantPool constantPool = makeConstantPool(aMethod.getConstantPool(), holder);
ExceptionHandler[] aHandlers = aMethod.getExceptionHandlers();
ExceptionHandler[] sHandlers = new ExceptionHandler[aHandlers.length];
for (int i = 0; i < aHandlers.length; i++) {
ExceptionHandler h = aHandlers[i];
ResolvedJavaType catchType = makeType((AnalysisType) h.getCatchType());
sHandlers[i] = new ExceptionHandler(h.getStartBCI(), h.getEndBCI(), h.getHandlerBCI(), h.catchTypeCPI(), catchType);
}
HostedMethod sMethod = new HostedMethod(hUniverse, aMethod, holder, signature, constantPool, sHandlers);
assert !hUniverse.methods.containsKey(aMethod);
hUniverse.methods.put(aMethod, sMethod);
if (aMethod.getAnnotation(CFunction.class) != null) {
if (!aMethod.isNative()) {
unsupportedFeatures.addMessage(aMethod.format("%H.%n(%p)"), aMethod, "Method annotated with @" + CFunction.class.getSimpleName() + " must be declared native");
}
} else if (aMethod.isNative() && !aMethod.isIntrinsicMethod() && aMethod.isImplementationInvoked() && !NativeImageOptions.ReportUnsupportedElementsAtRuntime.getValue()) {
unsupportedFeatures.addMessage(aMethod.format("%H.%n(%p)"), aMethod, AnnotationSubstitutionProcessor.deleteErrorMessage(aMethod, DeletedMethod.NATIVE_MESSAGE, true));
}
}
Aggregations