use of com.oracle.truffle.api.dsl.Specialization in project sulong by graalvm.
the class LLVMPolyglotImport method doImport.
@Specialization
protected Object doImport(Object name, @Cached("getContextReference()") ContextReference<LLVMContext> ctxRef) {
String symbolName = readString.executeWithTarget(name);
LLVMContext ctx = ctxRef.get();
try {
Object ret = ForeignAccess.sendRead(read, (TruffleObject) ctx.getEnv().getPolyglotBindings(), symbolName);
return toLLVM.executeWithTarget(ret);
} catch (InteropException ex) {
throw ex.raise();
}
}
use of com.oracle.truffle.api.dsl.Specialization in project sulong by graalvm.
the class LLVMTruffleWriteManagedToGlobal method doIntrinsic.
@Specialization
protected LLVMTruffleObject doIntrinsic(LLVMGlobal address, LLVMTruffleObject value, @Cached("getContextReference()") ContextReference<LLVMContext> context) {
LLVMTruffleObject typedValue = (LLVMTruffleObject) attachType.execute(value, address.getInteropType());
context.get().getGlobalFrame().setObject(address.getSlot(), typedValue);
return typedValue;
}
use of com.oracle.truffle.api.dsl.Specialization in project sulong by graalvm.
the class NativeAllocateStringNode method alloc.
@Specialization
protected Object alloc(String s, @Cached("getLLVMMemory()") LLVMMemory memory) {
LLVMAddress allocatedMemory = memory.allocateMemory(s.length() + 1);
long currentPtr = allocatedMemory.getVal();
for (byte b : s.getBytes()) {
memory.putI8(currentPtr, b);
currentPtr += 1;
}
memory.putI8(currentPtr, (byte) 0);
return allocatedMemory;
}
use of com.oracle.truffle.api.dsl.Specialization in project sulong by graalvm.
the class LLVMAddressArrayLiteralNode method writeAddress.
@Specialization
@ExplodeLoop
protected LLVMAddress writeAddress(VirtualFrame frame, LLVMAddress addr, @Cached("getLLVMMemory()") LLVMMemory memory) {
long currentPtr = addr.getVal();
for (int i = 0; i < values.length; i++) {
LLVMAddress currentValue = values[i].execute(frame);
memory.putAddress(currentPtr, currentValue);
currentPtr += stride;
}
return addr;
}
use of com.oracle.truffle.api.dsl.Specialization in project sulong by graalvm.
the class LLVMAddressArrayLiteralNode method foreignWriteRef.
// TODO: work around a DSL bug (GR-6493): remove cached int a and int b
@SuppressWarnings("unused")
@Specialization(guards = "addr.isManaged()")
@ExplodeLoop
protected LLVMTruffleObject foreignWriteRef(VirtualFrame frame, LLVMTruffleObject addr, @Cached("0") int a, @Cached("0") int b, @Cached("createForeignWrites()") LLVMForeignWriteNode[] foreignWrites) {
LLVMTruffleObject currentPtr = addr;
for (int i = 0; i < values.length; i++) {
Object currentValue = values[i].execute(frame);
foreignWrites[i].execute(currentPtr, currentValue);
currentPtr = currentPtr.increment(stride);
}
return addr;
}
Aggregations