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;
}
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;
}
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);
}
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);
}
}
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;
}
Aggregations