Search in sources :

Example 1 with DebugExprType

use of com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprType in project graal by oracle.

the class DebugExprNodeFactory method createFunctionCall.

public DebugExpressionPair createFunctionCall(DebugExpressionPair functionPair, List<DebugExpressionPair> arguments) {
    checkError(functionPair, "call(...)");
    if (functionPair.getNode() instanceof DebugExprVarNode) {
        DebugExprVarNode varNode = (DebugExprVarNode) functionPair.getNode();
        DebugExprFunctionCallNode node = varNode.createFunctionCall(arguments, globalScope);
        DebugExprType type = node.getType();
        return DebugExpressionPair.create(node, type);
    }
    throw DebugExprException.typeError(functionPair.getNode(), functionPair.getNode().toString());
}
Also used : DebugExprType(com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprType)

Example 2 with DebugExprType

use of com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprType in project graal by oracle.

the class DebugExprNodeFactory method createArithmeticOp.

public DebugExpressionPair createArithmeticOp(ArithmeticOperation op, DebugExpressionPair left, DebugExpressionPair right) {
    checkError(left, op.name());
    checkError(right, op.name());
    DebugExprType commonType = DebugExprType.commonType(left.getType(), right.getType());
    DebugExpressionPair leftPair = createCastIfNecessary(left, commonType);
    DebugExpressionPair rightPair = createCastIfNecessary(right, commonType);
    LLVMExpressionNode node = CommonNodeFactory.createArithmeticOp(op, commonType.getLLVMRuntimeType(), leftPair.getNode(), rightPair.getNode());
    return DebugExpressionPair.create(node, commonType);
}
Also used : DebugExprType(com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprType) LLVMExpressionNode(com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode)

Example 3 with DebugExprType

use of com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprType in project graal by oracle.

the class DebugExprNodeFactory method createDivNode.

public DebugExpressionPair createDivNode(DebugExpressionPair left, DebugExpressionPair right) {
    checkError(left, "/");
    checkError(right, "/");
    DebugExprType commonType = DebugExprType.commonType(left.getType(), right.getType());
    DebugExpressionPair leftPair = createCastIfNecessary(left, commonType);
    DebugExpressionPair rightPair = createCastIfNecessary(right, commonType);
    ArithmeticOperation op = commonType.isUnsigned() ? ArithmeticOperation.UDIV : ArithmeticOperation.DIV;
    LLVMExpressionNode node = CommonNodeFactory.createArithmeticOp(op, commonType.getLLVMRuntimeType(), leftPair.getNode(), rightPair.getNode());
    return DebugExpressionPair.create(node, commonType);
}
Also used : DebugExprType(com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprType) LLVMExpressionNode(com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode) ArithmeticOperation(com.oracle.truffle.llvm.runtime.ArithmeticOperation)

Example 4 with DebugExprType

use of com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprType in project graal by oracle.

the class DebugExprDereferenceNode method getMemberAndType.

@TruffleBoundary
private Pair<Object, DebugExprType> getMemberAndType(Object executedPointerNode) {
    if (executedPointerNode == null) {
        throw DebugExprException.create(this, "debugObject to dereference is null");
    }
    try {
        LLVMDebuggerValue llvmDebuggerValue = (LLVMDebuggerValue) executedPointerNode;
        Object metaObj = llvmDebuggerValue.resolveMetaObject();
        DebugExprType pointerType = DebugExprType.getTypeFromSymbolTableMetaObject(metaObj);
        if (!pointerType.isPointer()) {
            throw DebugExprException.create(this, llvmDebuggerValue + " is no pointer");
        }
        LLVMSourcePointerType llvmSourcePointerType = (LLVMSourcePointerType) metaObj;
        LLVMSourceType llvmSourceType = llvmSourcePointerType.getBaseType();
        LLVMDebugObject llvmPointerObject = (LLVMDebugObject) executedPointerNode;
        Object llvmPointerValue = llvmPointerObject.getValue();
        Builder builder = CommonNodeFactory.createDebugDeclarationBuilder();
        LLVMDebugValue dereferencedValue = builder.build(llvmPointerValue);
        LLVMDebugObject llvmDebugObject = LLVMDebugObject.create(llvmSourceType, 0L, dereferencedValue, null);
        DebugExprType type = pointerType.getInnerType();
        return Pair.create(type.parse(llvmDebugObject), type);
    } catch (ClassCastException e) {
    // throw cast exception of executedPointerNode (2 lines below)
    }
    throw DebugExprException.create(this, executedPointerNode + " cannot be casted to pointer ");
}
Also used : DebugExprType(com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprType) LLVMDebugObject(com.oracle.truffle.llvm.runtime.debug.value.LLVMDebugObject) Builder(com.oracle.truffle.llvm.runtime.debug.value.LLVMDebugValue.Builder) LLVMDebuggerValue(com.oracle.truffle.llvm.runtime.debug.LLVMDebuggerValue) LLVMDebugObject(com.oracle.truffle.llvm.runtime.debug.value.LLVMDebugObject) LLVMSourcePointerType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourcePointerType) LLVMDebugValue(com.oracle.truffle.llvm.runtime.debug.value.LLVMDebugValue) LLVMSourceType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 5 with DebugExprType

use of com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprType in project graal by oracle.

the class DebugExprFunctionCallNode method getType.

@TruffleBoundary
public DebugExprType getType() {
    InteropLibrary library = InteropLibrary.getFactory().getUncached();
    if (library.isMemberReadable(scope, functionName)) {
        try {
            Object member = library.readMember(scope, functionName);
            if (LLVMManagedPointer.isInstance(member)) {
                LLVMManagedPointer pointer = LLVMManagedPointer.cast(member);
                if (pointer.getOffset() == 0) {
                    member = pointer.getObject();
                }
            }
            if (member instanceof LLVMFunctionDescriptor) {
                LLVMFunctionDescriptor ldv = (LLVMFunctionDescriptor) member;
                Type returnType = ldv.getLLVMFunction().getType().getReturnType();
                DebugExprType t = DebugExprType.getTypeFromLLVMType(returnType);
                return t;
            } else {
                throw DebugExprException.create(this, "variable %s does not point to a function", functionName);
            }
        } catch (UnsupportedMessageException e) {
            throw DebugExprException.create(this, "error while accessing function %s", functionName);
        } catch (UnknownIdentifierException e) {
        // fallthrough
        }
    }
    throw DebugExprException.symbolNotFound(this, functionName, null);
}
Also used : DebugExprType(com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprType) Type(com.oracle.truffle.llvm.runtime.types.Type) DebugExprType(com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprType) UnsupportedMessageException(com.oracle.truffle.api.interop.UnsupportedMessageException) UnknownIdentifierException(com.oracle.truffle.api.interop.UnknownIdentifierException) InteropLibrary(com.oracle.truffle.api.interop.InteropLibrary) LLVMFunctionDescriptor(com.oracle.truffle.llvm.runtime.LLVMFunctionDescriptor) LLVMManagedPointer(com.oracle.truffle.llvm.runtime.pointer.LLVMManagedPointer) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Aggregations

DebugExprType (com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprType)12 LLVMExpressionNode (com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode)5 InteropLibrary (com.oracle.truffle.api.interop.InteropLibrary)3 UnknownIdentifierException (com.oracle.truffle.api.interop.UnknownIdentifierException)3 UnsupportedMessageException (com.oracle.truffle.api.interop.UnsupportedMessageException)3 LLVMDebuggerValue (com.oracle.truffle.llvm.runtime.debug.LLVMDebuggerValue)3 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)2 ArithmeticOperation (com.oracle.truffle.llvm.runtime.ArithmeticOperation)2 Specialization (com.oracle.truffle.api.dsl.Specialization)1 NodeLibrary (com.oracle.truffle.api.interop.NodeLibrary)1 CompareOperator (com.oracle.truffle.llvm.runtime.CompareOperator)1 LLVMFunctionDescriptor (com.oracle.truffle.llvm.runtime.LLVMFunctionDescriptor)1 LLVMSourcePointerType (com.oracle.truffle.llvm.runtime.debug.type.LLVMSourcePointerType)1 LLVMSourceType (com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType)1 LLVMDebugObject (com.oracle.truffle.llvm.runtime.debug.value.LLVMDebugObject)1 LLVMDebugValue (com.oracle.truffle.llvm.runtime.debug.value.LLVMDebugValue)1 Builder (com.oracle.truffle.llvm.runtime.debug.value.LLVMDebugValue.Builder)1 LLVMManagedPointer (com.oracle.truffle.llvm.runtime.pointer.LLVMManagedPointer)1 Type (com.oracle.truffle.llvm.runtime.types.Type)1