use of com.oracle.truffle.llvm.runtime.LLVMVarArgCompoundValue in project sulong by graalvm.
the class LLVMX86_64VAStart method computeOverflowArgAreaSize.
private int computeOverflowArgAreaSize(Object[] realArguments) {
assert numberOfExplicitArguments <= realArguments.length;
int overflowArea = 0;
int gpOffset = calculateUsedGpArea(realArguments);
int fpOffset = X86_64BitVarArgs.GP_LIMIT + calculateUsedFpArea(realArguments);
for (int i = numberOfExplicitArguments; i < realArguments.length; i++) {
final Object arg = realArguments[i];
final VarArgArea area = getVarArgArea(arg);
if (area == VarArgArea.GP_AREA && gpOffset < X86_64BitVarArgs.GP_LIMIT) {
gpOffset += X86_64BitVarArgs.GP_STEP;
} else if (area == VarArgArea.FP_AREA && fpOffset < X86_64BitVarArgs.FP_LIMIT) {
fpOffset += X86_64BitVarArgs.FP_STEP;
} else if (area != VarArgArea.OVERFLOW_AREA) {
overflowArea += X86_64BitVarArgs.STACK_STEP;
} else if (arg instanceof LLVM80BitFloat) {
overflowArea += 16;
} else if (arg instanceof LLVMVarArgCompoundValue) {
LLVMVarArgCompoundValue obj = (LLVMVarArgCompoundValue) arg;
overflowArea += obj.getSize();
} else {
throw new AssertionError(arg);
}
}
return overflowArea;
}
use of com.oracle.truffle.llvm.runtime.LLVMVarArgCompoundValue in project sulong by graalvm.
the class LLVMX86_64VAStart method storeArgument.
private static int storeArgument(Object ptr, long offset, LLVMMemMoveNode memmove, LLVMIncrementPointerNode pointerArithmetic, LLVMStoreNode storeI64Node, LLVMStoreNode storeI32Node, LLVMStoreNode storeFP80Node, Object object) {
if (object instanceof Number) {
return doPrimitiveWrite(ptr, offset, pointerArithmetic, storeI64Node, object);
} else if (object instanceof LLVMVarArgCompoundValue) {
LLVMVarArgCompoundValue obj = (LLVMVarArgCompoundValue) object;
Object currentPtr = pointerArithmetic.executeWithTarget(ptr, offset);
memmove.executeWithTarget(currentPtr, obj.getAddr(), obj.getSize());
return obj.getSize();
} else if (object instanceof LLVMAddress || object instanceof LLVMGlobal || object instanceof LLVMTruffleObject) {
Object currentPtr = pointerArithmetic.executeWithTarget(ptr, offset);
storeI64Node.executeWithTarget(currentPtr, object);
return X86_64BitVarArgs.STACK_STEP;
} else if (object instanceof LLVM80BitFloat) {
Object currentPtr = pointerArithmetic.executeWithTarget(ptr, offset);
storeFP80Node.executeWithTarget(currentPtr, object);
return 16;
} else if (object instanceof LLVMFloatVector) {
final LLVMFloatVector floatVec = (LLVMFloatVector) object;
for (int i = 0; i < floatVec.getLength(); i++) {
Object currentPtr = pointerArithmetic.executeWithTarget(ptr, offset + i * Float.BYTES);
storeI32Node.executeWithTarget(currentPtr, Float.floatToIntBits(floatVec.getValue(i)));
}
return floatVec.getLength() * Float.BYTES;
} else {
throw new AssertionError(object);
}
}
Aggregations