use of com.oracle.truffle.llvm.runtime.pointer.LLVMManagedPointer in project graal by oracle.
the class LLVMInteropReadNode method doClazz.
@Specialization(guards = { "type != null", "hasVirtualMethods(type)", "offset == 0" }, replaces = "doClazzCached")
Object doClazz(LLVMInteropType.Clazz type, Object foreign, long offset, ForeignToLLVMType accessType, @Cached LLVMInteropAccessNode access, @Cached ReadLocationNode read) {
if (type.hasVirtualMethods() && offset == 0) {
// return an artificially created pointer pointing to vtable and foreign object
LLVMInteropType.VTableObjectPair vTableObjectPair = LLVMInteropType.VTableObjectPair.create(type.getVTable(), foreign);
LLVMManagedPointer pointer = LLVMManagedPointer.create(vTableObjectPair);
return pointer;
}
AccessLocation location = access.execute(type, foreign, offset);
return read.execute(location.identifier, location, accessType);
}
use of com.oracle.truffle.llvm.runtime.pointer.LLVMManagedPointer in project graal by oracle.
the class LLDBSupport method pointsToObjectAccess.
public static boolean pointsToObjectAccess(LLVMPointer pointer) {
if (!LLVMManagedPointer.isInstance(pointer)) {
return false;
}
final LLVMManagedPointer managedPointer = LLVMManagedPointer.cast(pointer);
final Object target = managedPointer.getObject();
return !LLVMAsForeignLibrary.getFactory().getUncached().isForeign(target);
}
use of com.oracle.truffle.llvm.runtime.pointer.LLVMManagedPointer in project graal by oracle.
the class LLVMDebugObject method toString.
/**
* A representation of the current value of the referenced variable for the debugger to show.
*
* @return a string describing the referenced value
*/
@Override
@TruffleBoundary
public String toString() {
Object currentValue = getValue();
if (LLVMManagedPointer.isInstance(currentValue)) {
final LLVMManagedPointer managedPointer = LLVMManagedPointer.cast(currentValue);
final Object target = managedPointer.getObject();
String targetString;
if (target instanceof LLVMFunctionDescriptor) {
final LLVMFunctionDescriptor function = (LLVMFunctionDescriptor) target;
targetString = "LLVM function " + function.getLLVMFunction().getName();
} else {
targetString = "<managed pointer>";
}
final long targetOffset = managedPointer.getOffset();
if (targetOffset != 0L) {
targetString = String.format("%s + %d byte%s", targetString, targetOffset, targetOffset == 1L ? "" : "s");
}
currentValue = targetString;
}
return Objects.toString(currentValue);
}
use of com.oracle.truffle.llvm.runtime.pointer.LLVMManagedPointer in project graal by oracle.
the class LLVMToDebugValueNode method fromGlobal.
@Specialization
protected LLVMDebugValue fromGlobal(LLVMDebugGlobalVariable value, @Cached BranchProfile exception) {
LLVMGlobal global = value.getDescriptor();
LLVMPointer target = getContext().getSymbol(global, exception);
if (LLVMManagedPointer.isInstance(target)) {
final LLVMManagedPointer managedPointer = LLVMManagedPointer.cast(target);
if (LLDBSupport.pointsToObjectAccess(LLVMManagedPointer.cast(target))) {
return new LLDBMemoryValue(managedPointer);
}
}
return new LLDBGlobalConstant(global);
}
use of com.oracle.truffle.llvm.runtime.pointer.LLVMManagedPointer in project graal by oracle.
the class LLVMStructArrayLiteralNode method doVoid.
@Specialization(guards = { "noOffset(addr)" })
@ExplodeLoop
protected Object doVoid(VirtualFrame frame, LLVMManagedPointer addr) {
LLVMManagedPointer currentPtr = addr;
for (int i = 0; i < values.length; i++) {
Object currentValue = values[i].executeGeneric(frame);
memMove.executeWithTarget(currentPtr, currentValue, stride);
currentPtr = currentPtr.increment(stride);
}
return addr;
}
Aggregations