Search in sources :

Example 21 with ExplodeLoop

use of com.oracle.truffle.api.nodes.ExplodeLoop in project sulong by graalvm.

the class LLVMStoreVectorNode method writeVector.

@Specialization(guards = "address.isManaged()")
@ExplodeLoop
protected Object writeVector(LLVMTruffleObject address, LLVMDoubleVector value, @Cached("createForeignWrite()") LLVMForeignWriteNode foreignWrite) {
    assert value.getLength() == vectorLength;
    LLVMTruffleObject currentPtr = address;
    for (int i = 0; i < vectorLength; i++) {
        foreignWrite.execute(currentPtr, value.getValue(i));
        currentPtr = currentPtr.increment(DOUBLE_SIZE_IN_BYTES);
    }
    return null;
}
Also used : LLVMTruffleObject(com.oracle.truffle.llvm.runtime.LLVMTruffleObject) Specialization(com.oracle.truffle.api.dsl.Specialization) ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop)

Example 22 with ExplodeLoop

use of com.oracle.truffle.api.nodes.ExplodeLoop in project sulong by graalvm.

the class LLVMStoreVectorNode method writeVector.

@Specialization(guards = "address.isManaged()")
@ExplodeLoop
protected Object writeVector(LLVMTruffleObject address, LLVMI32Vector value, @Cached("createForeignWrite()") LLVMForeignWriteNode foreignWrite) {
    assert value.getLength() == vectorLength;
    LLVMTruffleObject currentPtr = address;
    for (int i = 0; i < vectorLength; i++) {
        foreignWrite.execute(currentPtr, value.getValue(i));
        currentPtr = currentPtr.increment(I32_SIZE_IN_BYTES);
    }
    return null;
}
Also used : LLVMTruffleObject(com.oracle.truffle.llvm.runtime.LLVMTruffleObject) Specialization(com.oracle.truffle.api.dsl.Specialization) ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop)

Example 23 with ExplodeLoop

use of com.oracle.truffle.api.nodes.ExplodeLoop in project graal by oracle.

the class ExecuteMethodNode method doOverloadedCached.

// Note: checkArgTypes must be evaluated after selectOverload.
@SuppressWarnings("unused")
@ExplodeLoop
@Specialization(guards = { "method == cachedMethod", "checkArgTypes(args, cachedArgTypes, toJavaNode, asVarArgs)" }, limit = "LIMIT")
Object doOverloadedCached(OverloadedMethodDesc method, Object obj, Object[] args, Object languageContext, @Cached("method") OverloadedMethodDesc cachedMethod, @Cached("create()") ToJavaNode toJavaNode, @Cached(value = "createArgTypesArray(args)", dimensions = 1) Type[] cachedArgTypes, @Cached("selectOverload(method, args, languageContext, toJavaNode, cachedArgTypes)") SingleMethodDesc overload, @Cached("asVarArgs(args, overload)") boolean asVarArgs, @Cached("createClassProfile()") ValueProfile receiverProfile) {
    assert overload == selectOverload(method, args, languageContext, toJavaNode);
    Class<?>[] types = overload.getParameterTypes();
    Type[] genericTypes = overload.getGenericParameterTypes();
    Object[] convertedArguments = new Object[cachedArgTypes.length];
    if (asVarArgs) {
        assert overload.isVarArgs();
        int parameterCount = overload.getParameterCount();
        for (int i = 0; i < cachedArgTypes.length; i++) {
            Class<?> expectedType = i < parameterCount - 1 ? types[i] : types[parameterCount - 1].getComponentType();
            Type expectedGenericType = i < parameterCount - 1 ? genericTypes[i] : getGenericComponentType(genericTypes[parameterCount - 1]);
            convertedArguments[i] = toJavaNode.execute(args[i], expectedType, expectedGenericType, languageContext);
        }
        convertedArguments = createVarArgsArray(overload, convertedArguments, parameterCount);
    } else {
        for (int i = 0; i < cachedArgTypes.length; i++) {
            convertedArguments[i] = toJavaNode.execute(args[i], types[i], genericTypes[i], languageContext);
        }
    }
    return doInvoke(overload, receiverProfile.profile(obj), convertedArguments, languageContext);
}
Also used : GenericArrayType(java.lang.reflect.GenericArrayType) Type(java.lang.reflect.Type) Specialization(com.oracle.truffle.api.dsl.Specialization) ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop)

Example 24 with ExplodeLoop

use of com.oracle.truffle.api.nodes.ExplodeLoop in project sulong by graalvm.

the class LLVMTruffleInvoke method doInvoke.

@ExplodeLoop
private Object doInvoke(VirtualFrame frame, TruffleObject value, String id, ContextReference<LLVMContext> contextReference, LLVMGetStackNode getStack) {
    Object[] evaluatedArgs = new Object[args.length];
    for (int i = 0; i < args.length; i++) {
        evaluatedArgs[i] = prepareValuesForEscape[i].executeWithTarget(args[i].executeGeneric(frame));
    }
    try {
        LLVMContext context = contextReference.get();
        LLVMStack stack = getStack.executeWithTarget(getThreadingStack(context), Thread.currentThread());
        Object rawValue;
        try (StackPointer save = stack.newFrame()) {
            rawValue = ForeignAccess.sendInvoke(foreignInvoke, value, id, evaluatedArgs);
        }
        return toLLVM.executeWithTarget(rawValue);
    } catch (UnknownIdentifierException | UnsupportedMessageException | UnsupportedTypeException | ArityException e) {
        CompilerDirectives.transferToInterpreter();
        throw new IllegalStateException(e);
    }
}
Also used : LLVMContext(com.oracle.truffle.llvm.runtime.LLVMContext) UnsupportedMessageException(com.oracle.truffle.api.interop.UnsupportedMessageException) UnknownIdentifierException(com.oracle.truffle.api.interop.UnknownIdentifierException) UnsupportedTypeException(com.oracle.truffle.api.interop.UnsupportedTypeException) TruffleObject(com.oracle.truffle.api.interop.TruffleObject) LLVMTruffleObject(com.oracle.truffle.llvm.runtime.LLVMTruffleObject) StackPointer(com.oracle.truffle.llvm.runtime.memory.LLVMStack.StackPointer) ArityException(com.oracle.truffle.api.interop.ArityException) LLVMStack(com.oracle.truffle.llvm.runtime.memory.LLVMStack) ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop)

Example 25 with ExplodeLoop

use of com.oracle.truffle.api.nodes.ExplodeLoop in project sulong by graalvm.

the class LLVMAddressArrayLiteralNode method writeAddress.

@Specialization
@ExplodeLoop
protected LLVMAddress writeAddress(VirtualFrame frame, LLVMAddress addr, @Cached("getLLVMMemory()") LLVMMemory memory) {
    long currentPtr = addr.getVal();
    for (int i = 0; i < values.length; i++) {
        LLVMAddress currentValue = values[i].execute(frame);
        memory.putAddress(currentPtr, currentValue);
        currentPtr += stride;
    }
    return addr;
}
Also used : LLVMAddress(com.oracle.truffle.llvm.runtime.LLVMAddress) Specialization(com.oracle.truffle.api.dsl.Specialization) ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop)

Aggregations

ExplodeLoop (com.oracle.truffle.api.nodes.ExplodeLoop)34 Specialization (com.oracle.truffle.api.dsl.Specialization)27 LLVMTruffleObject (com.oracle.truffle.llvm.runtime.LLVMTruffleObject)25 UnexpectedResultException (com.oracle.truffle.api.nodes.UnexpectedResultException)5 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)3 LLVMAddress (com.oracle.truffle.llvm.runtime.LLVMAddress)3 StackPointer (com.oracle.truffle.llvm.runtime.memory.LLVMStack.StackPointer)3 ArityException (com.oracle.truffle.api.interop.ArityException)2 UnsupportedMessageException (com.oracle.truffle.api.interop.UnsupportedMessageException)2 UnsupportedTypeException (com.oracle.truffle.api.interop.UnsupportedTypeException)2 LLVMContext (com.oracle.truffle.llvm.runtime.LLVMContext)2 LLVMFunctionDescriptor (com.oracle.truffle.llvm.runtime.LLVMFunctionDescriptor)2 LLVM80BitFloat (com.oracle.truffle.llvm.runtime.floating.LLVM80BitFloat)2 LLVMStack (com.oracle.truffle.llvm.runtime.memory.LLVMStack)2 GenericArrayType (java.lang.reflect.GenericArrayType)2 Type (java.lang.reflect.Type)2 Assumption (com.oracle.truffle.api.Assumption)1 UnknownIdentifierException (com.oracle.truffle.api.interop.UnknownIdentifierException)1 CodeAnnotationMirror (com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror)1 CodeAnnotationValue (com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue)1