Search in sources :

Example 6 with LLVMMemory

use of com.oracle.truffle.llvm.runtime.memory.LLVMMemory in project graal by oracle.

the class NativeProfiledMemMove method doInJava.

@Specialization(guards = "length <= MAX_JAVA_LEN")
protected void doInJava(Object target, Object source, long length, @Cached LLVMToNativeNode convertTarget, @Cached LLVMToNativeNode convertSource) {
    LLVMMemory memory = getLanguage().getLLVMMemory();
    LLVMNativePointer t = convertTarget.executeWithTarget(target);
    LLVMNativePointer s = convertSource.executeWithTarget(source);
    long targetPointer = t.asNative();
    long sourcePointer = s.asNative();
    if (CompilerDirectives.injectBranchProbability(CompilerDirectives.LIKELY_PROBABILITY, length > 0 && sourcePointer != targetPointer)) {
        // sourcePointer + length <= targetPointer || targetPointer < sourcePointer
        if (CompilerDirectives.injectBranchProbability(CompilerDirectives.LIKELY_PROBABILITY, Long.compareUnsigned(targetPointer - sourcePointer, length) >= 0)) {
            copyForward(memory, targetPointer, sourcePointer, length);
        } else {
            copyBackward(memory, targetPointer, sourcePointer, length);
        }
    }
}
Also used : LLVMMemory(com.oracle.truffle.llvm.runtime.memory.LLVMMemory) LLVMNativePointer(com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer) Specialization(com.oracle.truffle.api.dsl.Specialization)

Example 7 with LLVMMemory

use of com.oracle.truffle.llvm.runtime.memory.LLVMMemory in project graal by oracle.

the class LLVMLanguage method disposeContext.

@Override
protected void disposeContext(LLVMContext context) {
    // TODO (PLi): The globals loaded by the context needs to be freed manually.
    LLVMMemory memory = getLLVMMemory();
    context.dispose(memory);
}
Also used : LLVMMemory(com.oracle.truffle.llvm.runtime.memory.LLVMMemory)

Example 8 with LLVMMemory

use of com.oracle.truffle.llvm.runtime.memory.LLVMMemory in project graal by oracle.

the class LLVMStringHelper method doNative.

@Specialization
void doNative(LLVMNativePointer dst, long bufLength, String src) {
    LLVMMemory memory = getLanguage().getLLVMMemory();
    byte[] bytes = getBytes(src);
    long ptr = dst.asNative();
    for (int i = 0; i < bytes.length && i < bufLength - 1; i++) {
        memory.putI8(this, ptr++, bytes[i]);
    }
    memory.putI8(this, ptr++, (byte) 0);
}
Also used : LLVMMemory(com.oracle.truffle.llvm.runtime.memory.LLVMMemory) Specialization(com.oracle.truffle.api.dsl.Specialization)

Example 9 with LLVMMemory

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

the class Sulong method disposeContext.

@Override
protected void disposeContext(LLVMContext context) {
    LLVMMemory memory = getCapability(LLVMMemory.class);
    context.dispose(memory);
}
Also used : LLVMMemory(com.oracle.truffle.llvm.runtime.memory.LLVMMemory)

Example 10 with LLVMMemory

use of com.oracle.truffle.llvm.runtime.memory.LLVMMemory in project graal by oracle.

the class NativeMemSetNode method nativeMemset.

@Specialization(replaces = "nativeInJavaMemset")
@SuppressWarnings("deprecation")
protected void nativeMemset(LLVMNativePointer object, byte value, long length, @Cached("createToNativeWithTarget()") LLVMToNativeNode globalAccess) {
    LLVMMemory memory = getLanguage().getLLVMMemory();
    memory.memset(this, globalAccess.executeWithTarget(object), length, value);
}
Also used : LLVMMemory(com.oracle.truffle.llvm.runtime.memory.LLVMMemory) Specialization(com.oracle.truffle.api.dsl.Specialization)

Aggregations

LLVMMemory (com.oracle.truffle.llvm.runtime.memory.LLVMMemory)15 Specialization (com.oracle.truffle.api.dsl.Specialization)11 ExplodeLoop (com.oracle.truffle.api.nodes.ExplodeLoop)7 LLVMNativePointer (com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer)2 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)1 ExportMessage (com.oracle.truffle.api.library.ExportMessage)1 LLVMInternalTruffleObject (com.oracle.truffle.llvm.runtime.interop.LLVMInternalTruffleObject)1