Search in sources :

Example 31 with TruffleBoundary

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);
}
Also used : RootNode(com.oracle.truffle.api.nodes.RootNode) FrameInstance(com.oracle.truffle.api.frame.FrameInstance) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 32 with TruffleBoundary

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;
}
Also used : Node(com.oracle.truffle.api.nodes.Node) DirectCallNode(com.oracle.truffle.api.nodes.DirectCallNode) SLBuiltinNode(com.oracle.truffle.sl.builtins.SLBuiltinNode) RootNode(com.oracle.truffle.api.nodes.RootNode) DirectCallNode(com.oracle.truffle.api.nodes.DirectCallNode) HashSet(java.util.HashSet) NodeVisitor(com.oracle.truffle.api.nodes.NodeVisitor) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 33 with TruffleBoundary

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();
}
Also used : Property(com.oracle.truffle.api.object.Property) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 34 with TruffleBoundary

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;
    }
}
Also used : Shape(com.oracle.truffle.api.object.Shape) Property(com.oracle.truffle.api.object.Property) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 35 with TruffleBoundary

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);
}
Also used : PrintStream(java.io.PrintStream) InstrumentClientInstrumenter(com.oracle.truffle.api.instrumentation.InstrumentationHandler.InstrumentClientInstrumenter) NoSuchElementException(java.util.NoSuchElementException) FrameSlotTypeException(com.oracle.truffle.api.frame.FrameSlotTypeException) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Aggregations

TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)49 RootNode (com.oracle.truffle.api.nodes.RootNode)6 Property (com.oracle.truffle.api.object.Property)6 Specialization (com.oracle.truffle.api.dsl.Specialization)5 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)5 BigInteger (java.math.BigInteger)4 Node (com.oracle.truffle.api.nodes.Node)3 SourceSection (com.oracle.truffle.api.source.SourceSection)3 ByteBuffer (java.nio.ByteBuffer)3 Substitute (com.oracle.svm.core.annotate.Substitute)2 FrameInstance (com.oracle.truffle.api.frame.FrameInstance)2 FrameSlot (com.oracle.truffle.api.frame.FrameSlot)2 NodeVisitor (com.oracle.truffle.api.nodes.NodeVisitor)2 Source (com.oracle.truffle.api.source.Source)2 LLVMContext (com.oracle.truffle.llvm.runtime.LLVMContext)2 SLRootNode (com.oracle.truffle.sl.nodes.SLRootNode)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Assumption (com.oracle.truffle.api.Assumption)1 RootCallTarget (com.oracle.truffle.api.RootCallTarget)1