use of com.oracle.truffle.api.dsl.Specialization in project graal by oracle.
the class SLDisableSplittingBuiltin method disableSplitting.
@Specialization
@TruffleBoundary
public SLNull disableSplitting(@SuppressWarnings("unused") SLNull argument) {
RootNode parentRoot = Truffle.getRuntime().getCallerFrame().getCallNode().getRootNode();
((SLRootNode) parentRoot).setCloningAllowed(false);
return SLNull.SINGLETON;
}
use of com.oracle.truffle.api.dsl.Specialization in project graal by oracle.
the class SLDisableSplittingBuiltin method disableSplitting.
@Specialization
@TruffleBoundary
public SLFunction disableSplitting(SLFunction function) {
OptimizedCallTarget target = (OptimizedCallTarget) function.getCallTarget();
((SLRootNode) target.getRootNode()).setCloningAllowed(false);
return function;
}
use of com.oracle.truffle.api.dsl.Specialization in project sulong by graalvm.
the class LLVMDispatchNode method doNative.
@Specialization(replaces = "doCachedNative", guards = "descriptor.isNativeFunction()")
protected Object doNative(LLVMFunctionDescriptor descriptor, Object[] arguments, @Cached("createToNativeNodes()") LLVMNativeConvertNode[] toNative, @Cached("createFromNativeNode()") LLVMNativeConvertNode fromNative, @Cached("createNativeCallNode()") Node nativeCall, @Cached("getBindNode()") Node bindNode, @Cached("getContextReference()") ContextReference<LLVMContext> context, @Cached("nativeCallStatisticsEnabled(context)") boolean statistics) {
Object[] nativeArgs = prepareNativeArguments(arguments, toNative);
TruffleObject boundSymbol = LLVMNativeCallUtils.bindNativeSymbol(bindNode, descriptor.getNativeFunction(), getSignature());
Object returnValue;
try (StackPointer save = ((StackPointer) arguments[0]).newFrame()) {
returnValue = LLVMNativeCallUtils.callNativeFunction(statistics, context, nativeCall, boundSymbol, nativeArgs, descriptor);
}
return fromNative.executeConvert(returnValue);
}
use of com.oracle.truffle.api.dsl.Specialization in project sulong by graalvm.
the class LLVMDispatchNode method doCachedNative.
/*
* Function is not defined in the user program (not available as LLVM IR). No intrinsic
* available. We do a native call.
*/
@Specialization(limit = "10", guards = { "descriptor == cachedDescriptor", "descriptor.isNativeFunction()" })
protected Object doCachedNative(@SuppressWarnings("unused") LLVMFunctionDescriptor descriptor, Object[] arguments, @Cached("descriptor") LLVMFunctionDescriptor cachedDescriptor, @Cached("createToNativeNodes()") LLVMNativeConvertNode[] toNative, @Cached("createFromNativeNode()") LLVMNativeConvertNode fromNative, @Cached("createNativeCallNode()") Node nativeCall, @Cached("bindSymbol(cachedDescriptor)") TruffleObject cachedBoundFunction, @Cached("getContextReference()") ContextReference<LLVMContext> context, @Cached("nativeCallStatisticsEnabled(context)") boolean statistics) {
Object[] nativeArgs = prepareNativeArguments(arguments, toNative);
Object returnValue;
try (StackPointer save = ((StackPointer) arguments[0]).newFrame()) {
returnValue = LLVMNativeCallUtils.callNativeFunction(statistics, context, nativeCall, cachedBoundFunction, nativeArgs, cachedDescriptor);
}
return fromNative.executeConvert(returnValue);
}
use of com.oracle.truffle.api.dsl.Specialization in project sulong by graalvm.
the class LLVMToFunctionNode method doTruffleObject.
@Specialization
protected Object doTruffleObject(LLVMTruffleObject from, @Cached("create()") LLVMAsForeignNode asForeign) {
TruffleObject foreign = asForeign.execute(from);
if (ForeignAccess.sendIsNull(isNull, foreign)) {
return LLVMAddress.fromLong(0);
} else if (ForeignAccess.sendIsExecutable(isExecutable, foreign)) {
return from;
}
CompilerDirectives.transferToInterpreter();
throw new IllegalStateException("Not a function");
}
Aggregations