use of jdk.vm.ci.meta.LocalVariableTable in project graal by oracle.
the class SnippetStub method checkConstArg.
protected boolean checkConstArg(int index, String expectedName) {
assert method.getParameterAnnotation(ConstantParameter.class, index) != null : String.format("parameter %d of %s is expected to be constant", index, method.format("%H.%n(%p)"));
LocalVariableTable lvt = method.getLocalVariableTable();
if (lvt != null) {
Local local = lvt.getLocal(index, 0);
assert local != null;
String actualName = local.getName();
assert actualName.equals(expectedName) : String.format("parameter %d of %s is expected to be named %s, not %s", index, method.format("%H.%n(%p)"), expectedName, actualName);
}
return true;
}
use of jdk.vm.ci.meta.LocalVariableTable in project graal by oracle.
the class SubstrateGraphBuilderPlugins method checkParameterUsage.
private static void checkParameterUsage(boolean condition, GraphBuilderContext b, ResolvedJavaMethod targetMethod, int parameterIndex, String message) {
if (condition) {
return;
}
String parameterName = null;
LocalVariableTable variableTable = targetMethod.getLocalVariableTable();
if (variableTable != null) {
Local variable = variableTable.getLocal(parameterIndex, 0);
if (variable != null) {
parameterName = variable.getName();
}
}
if (parameterName == null) {
/* Fall back to parameter number if no name is available. */
parameterName = String.valueOf(parameterIndex);
}
throw UserError.abort(message + ": parameter " + parameterName + " of call to " + targetMethod.format("%H.%n(%p)") + " in " + b.getMethod().asStackTraceElement(b.bci()));
}
use of jdk.vm.ci.meta.LocalVariableTable 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);
}
Aggregations