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);
}
}
}
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);
}
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);
}
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);
}
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);
}
Aggregations