use of com.oracle.truffle.llvm.runtime.pointer.LLVMPointer in project graal by oracle.
the class LLVMInteropVtableAccessNode method doPointer.
@Specialization
@GenerateAOT.Exclude
Object doPointer(LLVMPointer vtablePointer, long virtualIndex, Object[] arguments, @Cached LLVMForeignReadNode read, @CachedLibrary(limit = "5") InteropLibrary interop) throws UnsupportedTypeException, ArityException, UnsupportedMessageException {
LLVMPointer vtableElementPointer = vtablePointer.increment(virtualIndex * LLVMNode.ADDRESS_SIZE_IN_BYTES);
final LLVMInteropType type = LLVMInteropType.ValueKind.POINTER.type;
return interop.execute(read.execute(vtableElementPointer, type), arguments);
}
use of com.oracle.truffle.llvm.runtime.pointer.LLVMPointer in project graal by oracle.
the class LLVMForeignVirtualSuperElemPtrNode method doResolve.
@Specialization
public LLVMPointer doResolve(LLVMPointer receiver, long offset, @Cached LLVMForeignReadNode read) {
Object vtablePointer = read.execute(receiver, LLVMInteropType.ValueKind.POINTER.type);
LLVMPointer parent = LLVMPointer.cast(vtablePointer).increment(-offset);
Object parentOffset = read.execute(parent, LLVMInteropType.ValueKind.I64.type);
return receiver.increment((long) parentOffset);
}
use of com.oracle.truffle.llvm.runtime.pointer.LLVMPointer in project graal by oracle.
the class LLVMResolveForeignClassChainNode method doClazzResolving.
@Specialization(replaces = "doClassResolvingCached")
public LLVMPointer doClazzResolving(LLVMPointer receiver, String ident, LLVMInteropType.Clazz clazz, @Cached LLVMForeignVirtualSuperElemPtrNode virtualSuperElemPtrNode, @Cached LLVMForeignDirectSuperElemPtrNode directSuperElemPtrNode) throws UnknownIdentifierException {
LLVMPointer curReceiver = receiver;
Pair<long[], Struct> p = clazz.getSuperOffsetInformation(ident);
for (long val : p.getLeft()) {
LLVMForeignGetSuperElemPtrNode access = (val & 1) == 1 ? virtualSuperElemPtrNode : directSuperElemPtrNode;
curReceiver = access.execute(curReceiver, val >> 1);
}
return curReceiver.export(p.getRight() == null ? clazz : p.getRight());
}
use of com.oracle.truffle.llvm.runtime.pointer.LLVMPointer in project graal by oracle.
the class LLVMAarch64VaListStorage method shift.
/**
* This is the implementation of the {@code va_arg} instruction.
*/
@SuppressWarnings("static-method")
@ExportMessage
Object shift(Type type, @SuppressWarnings("unused") Frame frame, @CachedLibrary(limit = "1") LLVMManagedReadLibrary readLib, @CachedLibrary(limit = "1") LLVMManagedWriteLibrary writeLib, @Cached BranchProfile regAreaProfile, @Cached("createBinaryProfile()") ConditionProfile isNativizedProfile) {
int regSaveOffs = 0;
int regSaveStep = 0;
boolean lookIntoRegSaveArea = true;
VarArgArea varArgArea = getVarArgArea(type);
RegSaveArea regSaveArea = null;
switch(varArgArea) {
case GP_AREA:
regSaveOffs = Aarch64BitVarArgs.GP_OFFSET;
regSaveStep = Aarch64BitVarArgs.GP_STEP;
regSaveArea = gpSaveArea;
break;
case FP_AREA:
regSaveOffs = Aarch64BitVarArgs.FP_OFFSET;
regSaveStep = Aarch64BitVarArgs.FP_STEP;
regSaveArea = fpSaveArea;
break;
case OVERFLOW_AREA:
lookIntoRegSaveArea = false;
break;
}
if (lookIntoRegSaveArea) {
regAreaProfile.enter();
int offs = readLib.readI32(this, regSaveOffs);
if (offs < 0) {
// The va shift logic for GP/FP regsave areas is done by updating the gp/fp offset
// field in va_list
writeLib.writeI32(this, regSaveOffs, offs + regSaveStep);
assert regSaveArea != null;
long n = regSaveArea.offsetToIndex(offs);
if (n >= 0) {
int i = (int) ((n << 32) >> 32);
return regSaveArea.args[i];
}
}
}
// overflow area
if (isNativizedProfile.profile(isNativized())) {
// Synchronize the managed current argument pointer from the native overflow area
this.overflowArgArea.setOffset(getArgPtrFromNativePtr(this, readLib));
Object currentArg = this.overflowArgArea.getCurrentArg();
// Shift the managed current argument pointer
this.overflowArgArea.shift(1);
// Update the new native current argument pointer from the managed one
long shiftOffs = this.overflowArgArea.getOffset();
LLVMPointer shiftedOverflowAreaPtr = overflowArgAreaBaseNativePtr.increment(shiftOffs);
writeLib.writePointer(this, Aarch64BitVarArgs.OVERFLOW_ARG_AREA, shiftedOverflowAreaPtr);
return currentArg;
} else {
Object currentArg = this.overflowArgArea.getCurrentArg();
this.overflowArgArea.shift(1);
return currentArg;
}
}
use of com.oracle.truffle.llvm.runtime.pointer.LLVMPointer in project graal by oracle.
the class LLVMComplex80BitFloatDiv method doDiv.
@Specialization
public Object doDiv(VirtualFrame frame, @Cached("getSizeInBytes()") int sizeInBytes) {
try {
LLVM80BitFloat longDoubleA = (LLVM80BitFloat) aNode.executeGeneric(frame);
LLVM80BitFloat longDoubleB = (LLVM80BitFloat) bNode.executeGeneric(frame);
LLVM80BitFloat longDoubleC = (LLVM80BitFloat) cNode.executeGeneric(frame);
LLVM80BitFloat longDoubleD = (LLVM80BitFloat) dNode.executeGeneric(frame);
double a = longDoubleA.getDoubleValue();
double b = longDoubleB.getDoubleValue();
double c = longDoubleC.getDoubleValue();
double d = longDoubleD.getDoubleValue();
double denom = c * c + d * d;
double zReal = (a * c + b * d) / denom;
double zImag = (b * c - a * d) / denom;
LLVMPointer allocatedMemory = alloc.executeLLVMPointer(frame);
storeReal.executeWithTarget(allocatedMemory, LLVM80BitFloat.fromDouble(zReal));
storeImag.executeWithTarget(allocatedMemory, sizeInBytes, LLVM80BitFloat.fromDouble(zImag));
return allocatedMemory;
} catch (UnexpectedResultException | ClassCastException e) {
throw CompilerDirectives.shouldNotReachHere(e);
}
}
Aggregations