Search in sources :

Example 1 with LLVMAddress

use of com.oracle.truffle.llvm.runtime.LLVMAddress in project sulong by graalvm.

the class LLVMInfo method uname.

public static long uname(LLVMMemory memory, LLVMAddress name) {
    LLVMAddress ptr = name;
    LLVMString.strcpy(memory, ptr, sysname);
    ptr = ptr.increment(UTS_FIELD_LENGTH);
    LLVMString.strcpy(memory, ptr, getHostname());
    ptr = ptr.increment(UTS_FIELD_LENGTH);
    LLVMString.strcpy(memory, ptr, release);
    ptr = ptr.increment(UTS_FIELD_LENGTH);
    LLVMString.strcpy(memory, ptr, getVersion());
    ptr = ptr.increment(UTS_FIELD_LENGTH);
    LLVMString.strcpy(memory, ptr, machine);
    ptr = ptr.increment(UTS_FIELD_LENGTH);
    LLVMString.strcpy(memory, ptr, getDomainName());
    return 0;
}
Also used : LLVMAddress(com.oracle.truffle.llvm.runtime.LLVMAddress)

Example 2 with LLVMAddress

use of com.oracle.truffle.llvm.runtime.LLVMAddress in project sulong by graalvm.

the class LLVMString method strcpy.

public static void strcpy(LLVMMemory memory, LLVMAddress dst, String src) {
    memcpy(memory, getBytes(src), dst, src.length());
    LLVMAddress zero = dst.increment(src.length());
    memory.putI8(zero, (byte) 0);
}
Also used : LLVMAddress(com.oracle.truffle.llvm.runtime.LLVMAddress)

Example 3 with LLVMAddress

use of com.oracle.truffle.llvm.runtime.LLVMAddress in project sulong by graalvm.

the class LLVMString method strncpy.

public static void strncpy(LLVMMemory memory, LLVMAddress dst, String src, long size) {
    memcpy(memory, getBytes(src), dst, size);
    if (src.length() < size) {
        LLVMAddress zero = dst.increment(src.length());
        memory.putI8(zero, (byte) 0);
    }
}
Also used : LLVMAddress(com.oracle.truffle.llvm.runtime.LLVMAddress)

Example 4 with LLVMAddress

use of com.oracle.truffle.llvm.runtime.LLVMAddress in project sulong by graalvm.

the class LLVMAMD64SyscallClockGetTimeNode method clockGetTime.

private static int clockGetTime(LLVMMemory memory, int clkId, LLVMAddress timespec) {
    long s;
    long ns;
    switch(clkId) {
        case CLOCK_REALTIME:
            {
                long t = currentTimeMillis();
                s = t / 1000;
                ns = (t % 1000) * 1000000;
                break;
            }
        case CLOCK_MONOTONIC:
            {
                long t = nanoTime();
                s = t / 1000000000L;
                ns = (t % 1000000000L);
                break;
            }
        default:
            return -LLVMAMD64Error.EINVAL;
    }
    LLVMAddress ptr = timespec;
    memory.putI64(ptr, s);
    ptr = ptr.increment(8);
    memory.putI64(ptr, ns);
    return 0;
}
Also used : LLVMAddress(com.oracle.truffle.llvm.runtime.LLVMAddress)

Example 5 with LLVMAddress

use of com.oracle.truffle.llvm.runtime.LLVMAddress in project sulong by graalvm.

the class LLVMPanic method doOp.

@Specialization
protected Object doOp(LLVMGlobal panicLocVar, @Cached("createToNativeWithTarget()") LLVMToNativeNode globalAccess, @Cached("createPanicLocation()") PanicLocType panicLoc, @Cached("getLLVMMemory()") LLVMMemory memory) {
    LLVMAddress addr = globalAccess.executeWithTarget(panicLocVar);
    CompilerDirectives.transferToInterpreter();
    throw panicLoc.read(memory, addr.getVal());
}
Also used : LLVMAddress(com.oracle.truffle.llvm.runtime.LLVMAddress) Specialization(com.oracle.truffle.api.dsl.Specialization)

Aggregations

LLVMAddress (com.oracle.truffle.llvm.runtime.LLVMAddress)18 Specialization (com.oracle.truffle.api.dsl.Specialization)6 ExplodeLoop (com.oracle.truffle.api.nodes.ExplodeLoop)3 UnexpectedResultException (com.oracle.truffle.api.nodes.UnexpectedResultException)3 LLVMTruffleObject (com.oracle.truffle.llvm.runtime.LLVMTruffleObject)3 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)1 FrameSlotTypeException (com.oracle.truffle.api.frame.FrameSlotTypeException)1 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)1 LLVMException (com.oracle.truffle.llvm.runtime.LLVMException)1 LLVMVarArgCompoundValue (com.oracle.truffle.llvm.runtime.LLVMVarArgCompoundValue)1 LLVM80BitFloat (com.oracle.truffle.llvm.runtime.floating.LLVM80BitFloat)1 LLVMGlobal (com.oracle.truffle.llvm.runtime.global.LLVMGlobal)1 LLVMStack (com.oracle.truffle.llvm.runtime.memory.LLVMStack)1 LLVMFloatVector (com.oracle.truffle.llvm.runtime.vector.LLVMFloatVector)1