Search in sources :

Example 1 with LocalVariableTable

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;
}
Also used : LocalVariableTable(jdk.vm.ci.meta.LocalVariableTable) Local(jdk.vm.ci.meta.Local) ConstantParameter(org.graalvm.compiler.api.replacements.Snippet.ConstantParameter)

Example 2 with LocalVariableTable

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()));
}
Also used : LocalVariableTable(jdk.vm.ci.meta.LocalVariableTable) Local(jdk.vm.ci.meta.Local)

Example 3 with LocalVariableTable

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);
}
Also used : LocalVariableTable(jdk.vm.ci.meta.LocalVariableTable) GraalError(org.graalvm.compiler.debug.GraalError) ByteArrayInputStream(java.io.ByteArrayInputStream) Local(jdk.vm.ci.meta.Local) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream)

Aggregations

Local (jdk.vm.ci.meta.Local)3 LocalVariableTable (jdk.vm.ci.meta.LocalVariableTable)3 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 IOException (java.io.IOException)1 ConstantParameter (org.graalvm.compiler.api.replacements.Snippet.ConstantParameter)1 GraalError (org.graalvm.compiler.debug.GraalError)1