use of com.oracle.truffle.api.CompilerDirectives.TruffleBoundary in project graal by oracle.
the class SLGraalRuntimeBuiltin method findCallsTo.
/**
* Finds all {@link DirectCallNode} instances calling a certain original {@link CallTarget} in
* the caller function.
*/
@TruffleBoundary
protected static final Set<DirectCallNode> findCallsTo(OptimizedCallTarget originalCallTarget) {
FrameInstance frame = Truffle.getRuntime().getCallerFrame();
RootNode root = frame.getCallNode().getRootNode();
return findCallsTo(root, originalCallTarget);
}
use of com.oracle.truffle.api.CompilerDirectives.TruffleBoundary in project graal by oracle.
the class SLGraalRuntimeBuiltin method findCallsTo.
/**
* Finds all {@link DirectCallNode} instances calling a certain original {@link CallTarget} in a
* given {@link RootNode}.
*/
@TruffleBoundary
protected static final Set<DirectCallNode> findCallsTo(RootNode root, OptimizedCallTarget originalCallTarget) {
final Set<DirectCallNode> allCallNodes = new HashSet<>();
root.accept(new NodeVisitor() {
@Override
public boolean visit(Node node) {
if (node instanceof DirectCallNode) {
DirectCallNode callNode = (DirectCallNode) node;
if (callNode.getCallTarget() == originalCallTarget || callNode.getClonedCallTarget() == originalCallTarget) {
allCallNodes.add(callNode);
}
}
return true;
}
});
return allCallNodes;
}
use of com.oracle.truffle.api.CompilerDirectives.TruffleBoundary in project graal by oracle.
the class ShapeImpl method toStringLimit.
/**
* @since 0.17 or earlier
*/
@TruffleBoundary
public String toStringLimit(int limit) {
StringBuilder sb = new StringBuilder();
sb.append('@');
sb.append(Integer.toHexString(hashCode()));
if (!isValid()) {
sb.append('!');
}
sb.append("{");
for (Iterator<Property> iterator = propertyMap.reverseOrderedValueIterator(); iterator.hasNext(); ) {
Property p = iterator.next();
sb.append(p);
if (iterator.hasNext()) {
sb.append(",");
}
if (sb.length() >= limit) {
sb.append("...");
break;
}
sb.append("\n");
}
sb.append("}");
return sb.toString();
}
use of com.oracle.truffle.api.CompilerDirectives.TruffleBoundary in project graal by oracle.
the class DynamicObjectImpl method changeFlags.
/**
* @since 0.17 or earlier
*/
@TruffleBoundary
public boolean changeFlags(Object key, int newFlags) {
Shape oldShape = getShape();
Property existing = oldShape.getProperty(key);
if (existing != null) {
if (existing.getFlags() != newFlags) {
Property newProperty = existing.copyWithFlags(newFlags);
Shape newShape = oldShape.replaceProperty(existing, newProperty);
this.setShape(newShape);
}
return true;
} else {
return false;
}
}
use of com.oracle.truffle.api.CompilerDirectives.TruffleBoundary in project graal by oracle.
the class ProbeNode method exceptionEventForClientInstrument.
/**
* Handles exceptions from non-language instrumentation code that must not be allowed to alter
* guest language execution semantics. Normal response is to log and continue.
*/
@TruffleBoundary
static void exceptionEventForClientInstrument(EventBinding.Source<?> b, String eventName, Throwable t) {
assert !b.isLanguageBinding();
if (t instanceof ThreadDeath) {
// Terminates guest language execution immediately
throw (ThreadDeath) t;
}
// Exception is a failure in (non-language) instrumentation code; log and continue
InstrumentClientInstrumenter instrumenter = (InstrumentClientInstrumenter) b.getInstrumenter();
Class<?> instrumentClass = instrumenter.getInstrumentClass();
String message = //
String.format(//
"Event %s failed for instrument class %s and listener/factory %s.", eventName, instrumentClass.getName(), b.getElement());
Exception exception = new Exception(message, t);
PrintStream stream = new PrintStream(instrumenter.getEnv().err());
exception.printStackTrace(stream);
}
Aggregations