use of com.oracle.truffle.api.CompilerDirectives.TruffleBoundary in project graal by oracle.
the class RuntimeStrengthenStampsPhase method printStaticTruffleBoundaries.
private void printStaticTruffleBoundaries() {
HashSet<ResolvedJavaMethod> foundBoundaries = new HashSet<>();
int callSiteCount = 0;
int calleeCount = 0;
for (CallTreeNode node : methods.values()) {
StructuredGraph graph = node.graph;
for (MethodCallTargetNode callTarget : graph.getNodes(MethodCallTargetNode.TYPE)) {
ResolvedJavaMethod targetMethod = callTarget.targetMethod();
TruffleBoundary truffleBoundary = targetMethod.getAnnotation(TruffleBoundary.class);
if (truffleBoundary != null) {
++callSiteCount;
if (foundBoundaries.contains(targetMethod)) {
// nothing to do
} else {
foundBoundaries.add(targetMethod);
System.out.println("Truffle boundary found: " + targetMethod);
calleeCount++;
}
}
}
}
System.out.println(String.format("Number of Truffle call boundaries: %d, number of unique called methods outside the boundary: %d", callSiteCount, calleeCount));
}
use of com.oracle.truffle.api.CompilerDirectives.TruffleBoundary in project graal by oracle.
the class PolyglotLanguageContext method toHostValue.
@TruffleBoundary
Value toHostValue(Object value) {
assert value != null;
assert !(value instanceof Value);
Object receiver = value;
PolyglotValue cache = valueCache.get(receiver.getClass());
if (cache == null) {
receiver = convertToInterop(receiver);
cache = lookupValueCache(receiver);
}
return getAPIAccess().newValue(receiver, cache);
}
use of com.oracle.truffle.api.CompilerDirectives.TruffleBoundary in project graal by oracle.
the class PolyglotLanguageContext method toGuestValues.
@TruffleBoundary
static Object[] toGuestValues(Object languageContext, Object[] args) {
Object[] newArgs = args;
for (int i = 0; i < args.length; i++) {
Object arg = args[i];
Object newArg = toGuestValue(languageContext, arg);
if (newArg != arg) {
if (newArgs == args) {
newArgs = Arrays.copyOf(args, args.length);
}
newArgs[i] = newArg;
}
}
return newArgs;
}
use of com.oracle.truffle.api.CompilerDirectives.TruffleBoundary in project graal by oracle.
the class CyclicAssumptionSnippets method invalidate.
/**
* @since 0.33
*/
@TruffleBoundary
public void invalidate(String message) {
Assumption newAssumption = Truffle.getRuntime().createAssumption(name);
Assumption oldAssumption = ASSUMPTION_UPDATER.getAndSet(this, newAssumption);
oldAssumption.invalidate(message);
}
use of com.oracle.truffle.api.CompilerDirectives.TruffleBoundary in project graal by oracle.
the class TruffleStackTrace method fillIn.
@TruffleBoundary
static TruffleStackTrace fillIn(Throwable t) {
if (t instanceof ControlFlowException) {
return EMPTY;
}
LazyStackTrace lazy = findImpl(t);
if (lazy == null) {
Throwable insertCause = findInsertCause(t);
if (insertCause == null) {
return null;
}
insert(insertCause, lazy = new LazyStackTrace());
}
if (lazy.stackTrace != null) {
// stack trace already exists
return lazy.stackTrace;
}
int stackFrameLimit;
Node topCallSite;
if (t instanceof TruffleException) {
TruffleException te = (TruffleException) t;
topCallSite = te.getLocation();
stackFrameLimit = te.getStackTraceElementLimit();
} else {
topCallSite = null;
stackFrameLimit = -1;
}
// add the lazily captured stack frames above the manually queried ones
ArrayList<TracebackElement> elements = new ArrayList<>();
TracebackElement currentElement = lazy.current;
while (currentElement != null) {
elements.add(currentElement);
currentElement = currentElement.last;
}
Collections.reverse(elements);
List<TruffleStackTraceElement> frames = new ArrayList<>();
for (TracebackElement element : elements) {
if (element.root != null) {
frames.add(new TruffleStackTraceElement(topCallSite, element.root, element.frame));
topCallSite = null;
}
if (element.callNode != null) {
topCallSite = element.callNode;
}
}
int lazyFrames = frames.size();
// attach the remaining stack trace elements
addStackFrames(stackFrameLimit, lazyFrames, topCallSite, frames);
return lazy.stackTrace = new TruffleStackTrace(frames, lazyFrames);
}
Aggregations