Search in sources :

Example 1 with SafepointCheckNode

use of com.oracle.svm.core.nodes.SafepointCheckNode in project graal by oracle.

the class NodeLLVMBuilder method emitCondition.

private LLVMValueRef emitCondition(LogicNode condition) {
    if (condition instanceof IsNullNode) {
        return builder.buildIsNull(llvmOperand(((IsNullNode) condition).getValue()));
    }
    if (condition instanceof LogicConstantNode) {
        return builder.constantBoolean(((LogicConstantNode) condition).getValue());
    }
    if (condition instanceof CompareNode) {
        CompareNode compareNode = (CompareNode) condition;
        return builder.buildCompare(compareNode.condition().asCondition(), llvmOperand(compareNode.getX()), llvmOperand(compareNode.getY()), compareNode.unorderedIsTrue());
    }
    if (condition instanceof IntegerTestNode) {
        IntegerTestNode integerTestNode = (IntegerTestNode) condition;
        LLVMValueRef and = builder.buildAnd(llvmOperand(integerTestNode.getX()), llvmOperand(integerTestNode.getY()));
        return builder.buildIsNull(and);
    }
    if (condition instanceof SafepointCheckNode) {
        LLVMValueRef threadData = gen.getSpecialRegisterValue(SpecialRegister.ThreadPointer);
        threadData = builder.buildIntToPtr(threadData, builder.rawPointerType());
        LLVMValueRef safepointCounterAddr = builder.buildGEP(threadData, builder.constantInt(Safepoint.getThreadLocalSafepointRequestedOffset()));
        LLVMValueRef safepointCount = builder.buildLoad(safepointCounterAddr, builder.intType());
        if (ThreadingSupportImpl.isRecurringCallbackSupported()) {
            safepointCount = builder.buildSub(safepointCount, builder.constantInt(1));
            builder.buildStore(safepointCount, builder.buildBitcast(safepointCounterAddr, builder.pointerType(builder.intType())));
        }
        return builder.buildICmp(Condition.LE, safepointCount, builder.constantInt(0));
    }
    throw shouldNotReachHere("logic node: " + condition.getClass().getName());
}
Also used : CompareNode(org.graalvm.compiler.nodes.calc.CompareNode) IsNullNode(org.graalvm.compiler.nodes.calc.IsNullNode) IntegerTestNode(org.graalvm.compiler.nodes.calc.IntegerTestNode) LogicConstantNode(org.graalvm.compiler.nodes.LogicConstantNode) LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef) SafepointCheckNode(com.oracle.svm.core.nodes.SafepointCheckNode)

Aggregations

SafepointCheckNode (com.oracle.svm.core.nodes.SafepointCheckNode)1 LLVMValueRef (com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef)1 LogicConstantNode (org.graalvm.compiler.nodes.LogicConstantNode)1 CompareNode (org.graalvm.compiler.nodes.calc.CompareNode)1 IntegerTestNode (org.graalvm.compiler.nodes.calc.IntegerTestNode)1 IsNullNode (org.graalvm.compiler.nodes.calc.IsNullNode)1