com.oracle.truffle.api.frame.FrameDescriptor Java Examples
The following examples show how to use
com.oracle.truffle.api.frame.FrameDescriptor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HashemStackTraceBuiltin.java From mr-hashemi with Universal Permissive License v1.0 | 5 votes |
@TruffleBoundary private static String createStackTrace() { final StringBuilder str = new StringBuilder(); Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<Integer>() { private int skip = 1; // skip stack trace builtin @Override public Integer visitFrame(FrameInstance frameInstance) { if (skip > 0) { skip--; return null; } CallTarget callTarget = frameInstance.getCallTarget(); Frame frame = frameInstance.getFrame(FrameAccess.READ_ONLY); RootNode rn = ((RootCallTarget) callTarget).getRootNode(); // ignore internal or interop stack frames if (rn.isInternal() || rn.getLanguageInfo() == null) { return 1; } if (str.length() > 0) { str.append(System.getProperty("line.separator")); } str.append("Frame: ").append(rn.toString()); FrameDescriptor frameDescriptor = frame.getFrameDescriptor(); for (FrameSlot s : frameDescriptor.getSlots()) { str.append(", ").append(s.getIdentifier()).append("=").append(frame.getValue(s)); } return null; } }); return str.toString(); }
Example #2
Source File: HashemContext.java From mr-hashemi with Universal Permissive License v1.0 | 5 votes |
public void installBuiltin(NodeFactory<? extends HashemBuiltinNode> factory) { /* * The builtin node factory is a class that is automatically generated by the Truffle DSL. * The signature returned by the factory reflects the signature of the @Specialization * * methods in the builtin classes. */ int argumentCount = factory.getExecutionSignature().size(); HashemExpressionNode[] argumentNodes = new HashemExpressionNode[argumentCount]; /* * Builtin functions are like normal functions, i.e., the arguments are passed in as an * Object[] array encapsulated in SLArguments. A SLReadArgumentNode extracts a parameter * from this array. */ for (int i = 0; i < argumentCount; i++) { argumentNodes[i] = new HashemReadArgumentNode(i); } /* Instantiate the builtin node. This node performs the actual functionality. */ HashemBuiltinNode builtinBodyNode = factory.createNode((Object) argumentNodes); builtinBodyNode.addRootTag(); /* The name of the builtin function is specified via an annotation on the node class. */ String name = lookupNodeInfo(builtinBodyNode.getClass()).shortName(); builtinBodyNode.setUnavailableSourceSection(); /* Wrap the builtin in a RootNode. Truffle requires all AST to start with a RootNode. */ HashemRootNode rootNode = new HashemRootNode(language, new FrameDescriptor(), builtinBodyNode, BUILTIN_SOURCE.createUnavailableSection(), name); /* Register the builtin function in our function registry. */ getFunctionRegistry().register(name, Truffle.getRuntime().createCallTarget(rootNode)); }
Example #3
Source File: CompiledCodeObject.java From trufflesqueak with MIT License | 5 votes |
@TruffleBoundary protected CompiledCodeObject(final SqueakImageContext image, final int hash, final int numCopiedValues) { super(image, hash); this.numCopiedValues = numCopiedValues; frameDescriptor = new FrameDescriptor(); thisMarkerSlot = frameDescriptor.addFrameSlot(SLOT_IDENTIFIER.THIS_MARKER, FrameSlotKind.Object); thisContextSlot = frameDescriptor.addFrameSlot(SLOT_IDENTIFIER.THIS_CONTEXT, FrameSlotKind.Illegal); instructionPointerSlot = frameDescriptor.addFrameSlot(SLOT_IDENTIFIER.INSTRUCTION_POINTER, FrameSlotKind.Int); stackPointerSlot = frameDescriptor.addFrameSlot(SLOT_IDENTIFIER.STACK_POINTER, FrameSlotKind.Int); }
Example #4
Source File: BuiltinNode.java From mumbler with GNU General Public License v3.0 | 5 votes |
public static MumblerFunction createBuiltinFunction( MumblerLanguage lang, NodeFactory<? extends BuiltinNode> factory, VirtualFrame outerFrame) { int argumentCount = factory.getExecutionSignature().size(); MumblerNode[] argumentNodes = new MumblerNode[argumentCount]; for (int i=0; i<argumentCount; i++) { argumentNodes[i] = new ReadArgumentNode(i); } BuiltinNode node = factory.createNode((Object) argumentNodes); return new MumblerFunction(Truffle.getRuntime().createCallTarget( new MumblerRootNode(lang, new MumblerNode[] {node}, new FrameDescriptor()))); }
Example #5
Source File: MumblerRootNode.java From mumbler with GNU General Public License v3.0 | 5 votes |
public static MumblerRootNode create(MumblerLanguage lang, FrameSlot[] argumentNames, MumblerNode[] bodyNodes, FrameDescriptor frameDescriptor) { MumblerNode[] allNodes = new MumblerNode[argumentNames.length + bodyNodes.length]; for (int i=0; i<argumentNames.length; i++) { allNodes[i] = DefineNodeGen.create( new ReadArgumentNode(i), argumentNames[i]); } System.arraycopy(bodyNodes, 0, allNodes, argumentNames.length, bodyNodes.length); return new MumblerRootNode(lang, allNodes, frameDescriptor); }
Example #6
Source File: HashemRootNode.java From mr-hashemi with Universal Permissive License v1.0 | 4 votes |
public HashemRootNode(HashemLanguage language, FrameDescriptor frameDescriptor, HashemExpressionNode bodyNode, SourceSection sourceSection, String name) { super(language, frameDescriptor); this.bodyNode = bodyNode; this.name = name; this.sourceSection = sourceSection; }
Example #7
Source File: CompiledCodeObject.java From trufflesqueak with MIT License | 4 votes |
public final FrameDescriptor getFrameDescriptor() { return frameDescriptor; }
Example #8
Source File: Namespace.java From mumbler with GNU General Public License v3.0 | 4 votes |
public Namespace(FrameDescriptor frameDescriptor) { this.functionName = GLOBAL_NS; this.parent = null; this.frameDescriptor = frameDescriptor; }
Example #9
Source File: Namespace.java From mumbler with GNU General Public License v3.0 | 4 votes |
public Namespace(String name, Namespace parent) { this.functionName = name; this.parent = parent; this.frameDescriptor = new FrameDescriptor(); }
Example #10
Source File: Namespace.java From mumbler with GNU General Public License v3.0 | 4 votes |
public FrameDescriptor getFrameDescriptor() { return this.frameDescriptor; }
Example #11
Source File: MumblerContext.java From mumbler with GNU General Public License v3.0 | 4 votes |
public MumblerContext(MumblerLanguage lang) { this.globalFrameDescriptor = new FrameDescriptor(); this.globalNamespace = new Namespace(this.globalFrameDescriptor); this.globalFrame = this.initGlobalFrame(lang); this.lang = lang; }
Example #12
Source File: MumblerContext.java From mumbler with GNU General Public License v3.0 | 4 votes |
private static void addGlobalFunctions(MumblerLanguage lang, VirtualFrame virtualFrame) { FrameDescriptor frameDescriptor = virtualFrame.getFrameDescriptor(); virtualFrame.setObject(frameDescriptor.addFrameSlot("println"), createBuiltinFunction(lang, PrintlnBuiltinNodeFactory.getInstance(), virtualFrame)); virtualFrame.setObject(frameDescriptor.addFrameSlot("+"), createBuiltinFunction(lang, AddBuiltinNodeFactory.getInstance(), virtualFrame)); virtualFrame.setObject(frameDescriptor.addFrameSlot("-"), createBuiltinFunction(lang, SubBuiltinNodeFactory.getInstance(), virtualFrame)); virtualFrame.setObject(frameDescriptor.addFrameSlot("*"), createBuiltinFunction(lang, MulBuiltinNodeFactory.getInstance(), virtualFrame)); virtualFrame.setObject(frameDescriptor.addFrameSlot("/"), createBuiltinFunction(lang, DivBuiltinNodeFactory.getInstance(), virtualFrame)); virtualFrame.setObject(frameDescriptor.addFrameSlot("%"), createBuiltinFunction(lang, ModBuiltinNodeFactory.getInstance(), virtualFrame)); virtualFrame.setObject(frameDescriptor.addFrameSlot("="), createBuiltinFunction(lang, EqualBuiltinNodeFactory.getInstance(), virtualFrame)); virtualFrame.setObject(frameDescriptor.addFrameSlot("<"), createBuiltinFunction(lang, LessThanBuiltinNodeFactory.getInstance(), virtualFrame)); virtualFrame.setObject(frameDescriptor.addFrameSlot(">"), createBuiltinFunction(lang, GreaterThanBuiltinNodeFactory.getInstance(), virtualFrame)); virtualFrame.setObject(frameDescriptor.addFrameSlot("list"), createBuiltinFunction(lang, ListBuiltinNodeFactory.getInstance(), virtualFrame)); virtualFrame.setObject(frameDescriptor.addFrameSlot("cons"), createBuiltinFunction(lang, ConsBuiltinNodeFactory.getInstance(), virtualFrame)); virtualFrame.setObject(frameDescriptor.addFrameSlot("car"), createBuiltinFunction(lang, CarBuiltinNodeFactory.getInstance(), virtualFrame)); virtualFrame.setObject(frameDescriptor.addFrameSlot("cdr"), createBuiltinFunction(lang, CdrBuiltinNodeFactory.getInstance(), virtualFrame)); virtualFrame.setObject(frameDescriptor.addFrameSlot("now"), createBuiltinFunction(lang, NowBuiltinNodeFactory.getInstance(), virtualFrame)); // virtualFrame.setObject(frameDescriptor.addFrameSlot("eval"), // createBuiltinFunction(EvalBuiltinNodeFactory.getInstance(), // virtualFrame)); virtualFrame.setObject(frameDescriptor.addFrameSlot("read"), createBuiltinFunction(lang, ReadBuiltinNodeFactory.getInstance(), virtualFrame)); virtualFrame.setObject(frameDescriptor.addFrameSlot("sleep"), createBuiltinFunction(lang, SleepBuiltinNodeFactory.getInstance(), virtualFrame)); }
Example #13
Source File: MumblerRootNode.java From mumbler with GNU General Public License v3.0 | 4 votes |
public MumblerRootNode(MumblerLanguage lang, MumblerNode[] bodyNodes, FrameDescriptor frameDescriptor) { super(lang, frameDescriptor); this.bodyNodes = bodyNodes; }
Example #14
Source File: MumblerFunction.java From mumbler with GNU General Public License v3.0 | 4 votes |
public static MumblerFunction create(MumblerLanguage lang, FrameSlot[] arguments, MumblerNode[] bodyNodes, FrameDescriptor frameDescriptor) { return new MumblerFunction( Truffle.getRuntime().createCallTarget( MumblerRootNode.create(lang, arguments, bodyNodes, frameDescriptor))); }