use of org.graalvm.compiler.debug.GraalError in project graal by oracle.
the class GraalOSRTestBase method compile.
protected static void compile(DebugContext debug, ResolvedJavaMethod method, int bci) {
HotSpotJVMCIRuntimeProvider runtime = HotSpotJVMCIRuntime.runtime();
long jvmciEnv = 0L;
HotSpotCompilationRequest request = new HotSpotCompilationRequest((HotSpotResolvedJavaMethod) method, bci, jvmciEnv);
HotSpotGraalCompiler compiler = (HotSpotGraalCompiler) runtime.getCompiler();
CompilationTask task = new CompilationTask(runtime, compiler, request, true, true, debug.getOptions());
if (method instanceof HotSpotResolvedJavaMethod) {
HotSpotGraalRuntimeProvider graalRuntime = compiler.getGraalRuntime();
GraalHotSpotVMConfig config = graalRuntime.getVMConfig();
if (((HotSpotResolvedJavaMethod) method).hasCodeAtLevel(bci, config.compilationLevelFullOptimization)) {
return;
}
}
HotSpotCompilationRequestResult result = task.runCompilation(debug);
if (result.getFailure() != null) {
throw new GraalError(result.getFailureMessage());
}
}
use of org.graalvm.compiler.debug.GraalError 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 org.graalvm.compiler.debug.GraalError in project graal by oracle.
the class ClassfileBytecode method getLineNumberTable.
@Override
public LineNumberTable getLineNumberTable() {
if (lineNumberTableBytes == null) {
return null;
}
final int lineNumberTableLength = lineNumberTableBytes.length / LINE_NUMBER_TABLE_ENTRY_SIZE_IN_BYTES;
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(lineNumberTableBytes));
int[] bci = new int[lineNumberTableLength];
int[] line = new int[lineNumberTableLength];
for (int i = 0; i < lineNumberTableLength; i++) {
try {
bci[i] = stream.readUnsignedShort();
line[i] = stream.readUnsignedShort();
} catch (IOException e) {
throw new GraalError(e);
}
}
return new LineNumberTable(line, bci);
}
use of org.graalvm.compiler.debug.GraalError in project graal by oracle.
the class ClassfileBytecode method getLocalVariableTable.
@Override
public LocalVariableTable getLocalVariableTable() {
if (localVariableTableBytes == null) {
return null;
}
final int localVariableTableLength = localVariableTableBytes.length / LOCAL_VARIABLE_TABLE_SIZE_IN_BYTES;
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(localVariableTableBytes));
Local[] locals = new Local[localVariableTableLength];
for (int i = 0; i < localVariableTableLength; i++) {
try {
final int startBci = stream.readUnsignedShort();
final int endBci = startBci + stream.readUnsignedShort();
final int nameCpIndex = stream.readUnsignedShort();
final int typeCpIndex = stream.readUnsignedShort();
final int slot = stream.readUnsignedShort();
String localName = constantPool.lookupUtf8(nameCpIndex);
String localType = constantPool.lookupUtf8(typeCpIndex);
ClassfileBytecodeProvider context = constantPool.context;
Class<?> c = context.resolveToClass(localType);
locals[i] = new Local(localName, context.metaAccess.lookupJavaType(c), startBci, endBci, slot);
} catch (IOException e) {
throw new GraalError(e);
}
}
return new LocalVariableTable(locals);
}
use of org.graalvm.compiler.debug.GraalError in project graal by oracle.
the class AbstractKnownTruffleTypes method findField.
protected ResolvedJavaField findField(ResolvedJavaType declaringClass, String name) {
FieldsCache fc = fieldsCache;
if (fc == null || !fc.declaringClass.equals(declaringClass)) {
fc = new FieldsCache(declaringClass, declaringClass.getInstanceFields(false));
fieldsCache = fc;
}
for (ResolvedJavaField f : fc.fields) {
if (f.getName().equals(name)) {
return f;
}
}
throw new GraalError("Could not find required field %s.%s", declaringClass.getName(), name);
}
Aggregations