com.oracle.truffle.api.frame.MaterializedFrame Java Examples
The following examples show how to use
com.oracle.truffle.api.frame.MaterializedFrame.
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: FrameAccess.java From trufflesqueak with MIT License | 6 votes |
@TruffleBoundary public static MaterializedFrame findFrameForMarker(final FrameMarker frameMarker) { CompilerDirectives.bailout("Finding materializable frames should never be part of compiled code as it triggers deopts"); LogUtils.ITERATE_FRAMES.fine("Iterating frames to find a marker..."); final Frame frame = Truffle.getRuntime().iterateFrames(frameInstance -> { final Frame current = frameInstance.getFrame(FrameInstance.FrameAccess.READ_ONLY); if (!isTruffleSqueakFrame(current)) { return null; } LogUtils.ITERATE_FRAMES.fine(() -> "..." + FrameAccess.getMethod(current).toString()); if (frameMarker == getMarker(current)) { return frameInstance.getFrame(FrameInstance.FrameAccess.MATERIALIZE); } return null; }); if (frame == null) { throw SqueakException.create("Could not find frame for:", frameMarker); } else { return frame.materialize(); } }
Example #2
Source File: HashemInstrumentTest.java From mr-hashemi with Universal Permissive License v1.0 | 5 votes |
private static void checkRootNode(Scope ls, String name, MaterializedFrame frame) { assertEquals(name, ls.getName()); Node node = ls.getNode(); assertTrue(node.getClass().getName(), node instanceof RootNode); assertEquals(name, ((RootNode) node).getName()); assertEquals(frame.getFrameDescriptor(), ((RootNode) node).getFrameDescriptor()); }
Example #3
Source File: FunctionRootEventHandler.java From nodeprof.js with Apache License 2.0 | 5 votes |
@TruffleBoundary private Object getReceiverFromScope(MaterializedFrame frame, TruffleInstrument.Env env) { Iterable<Scope> scopes = env.findLocalScopes(context.getInstrumentedNode(), frame); assert scopes.iterator().hasNext(); Object receiver = scopes.iterator().next().getReceiver(); assert receiver != null; return receiver; }
Example #4
Source File: ContextObject.java From trufflesqueak with MIT License | 5 votes |
private ContextObject(final SqueakImageContext image, final MaterializedFrame truffleFrame, final int size) { super(image); assert FrameAccess.getSender(truffleFrame) != null; assert FrameAccess.getContext(truffleFrame) == null; assert FrameAccess.getBlockOrMethod(truffleFrame).getSqueakContextSize() == size; this.truffleFrame = truffleFrame; this.size = size; }
Example #5
Source File: ContextObject.java From trufflesqueak with MIT License | 5 votes |
public MaterializedFrame getOrCreateTruffleFrame() { if (truffleFrame == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); // Method is unknown, use dummy frame instead final Object[] dummyArguments = FrameAccess.newDummyWith(null, NilObject.SINGLETON, null, new Object[2]); final CompiledMethodObject dummyMethod = SqueakLanguage.getContext().dummyMethod; truffleFrame = Truffle.getRuntime().createMaterializedFrame(dummyArguments, dummyMethod.getFrameDescriptor()); FrameAccess.setInstructionPointer(truffleFrame, dummyMethod, 0); FrameAccess.setStackPointer(truffleFrame, dummyMethod, 1); } return truffleFrame; }
Example #6
Source File: ContextObject.java From trufflesqueak with MIT License | 5 votes |
private MaterializedFrame getOrCreateTruffleFrame(final CompiledMethodObject method) { if (truffleFrame == null || FrameAccess.getMethod(truffleFrame) == null) { final Object[] frameArguments; final int instructionPointer; final int stackPointer; if (truffleFrame != null) { assert FrameAccess.getSender(truffleFrame) != null : "Sender should not be null"; FrameAccess.assertReceiverNotNull(truffleFrame); final Object[] dummyArguments = truffleFrame.getArguments(); final int expectedArgumentSize = FrameAccess.expectedArgumentSize(method.getNumArgs()); if (dummyArguments.length != expectedArgumentSize) { // Adjust arguments. frameArguments = Arrays.copyOf(dummyArguments, expectedArgumentSize); } else { frameArguments = truffleFrame.getArguments(); } assert truffleFrame.getFrameDescriptor().getSize() > 0; instructionPointer = FrameAccess.getInstructionPointer(truffleFrame, method); stackPointer = FrameAccess.getStackPointer(truffleFrame, method); } else { // Receiver plus arguments. final Object[] squeakArguments = new Object[1 + method.getNumArgs()]; frameArguments = FrameAccess.newDummyWith(method, NilObject.SINGLETON, null, squeakArguments); instructionPointer = 0; stackPointer = method.getNumTemps(); } CompilerDirectives.transferToInterpreterAndInvalidate(); truffleFrame = Truffle.getRuntime().createMaterializedFrame(frameArguments, method.getFrameDescriptor()); FrameAccess.initializeMarker(truffleFrame, method); FrameAccess.setContext(truffleFrame, method, this); FrameAccess.setInstructionPointer(truffleFrame, method, instructionPointer); FrameAccess.setStackPointer(truffleFrame, method, stackPointer); } return truffleFrame; }
Example #7
Source File: ContextObject.java From trufflesqueak with MIT License | 5 votes |
public void become(final ContextObject other) { final MaterializedFrame otherTruffleFrame = other.truffleFrame; final int otherSize = other.size; final boolean otherHasModifiedSender = other.hasModifiedSender; final boolean otherEscaped = other.escaped; other.setFields(truffleFrame, size, hasModifiedSender, escaped); setFields(otherTruffleFrame, otherSize, otherHasModifiedSender, otherEscaped); }
Example #8
Source File: ContextObject.java From trufflesqueak with MIT License | 5 votes |
private void setFields(final MaterializedFrame otherTruffleFrame, final int otherSize, final boolean otherHasModifiedSender, final boolean otherEscaped) { CompilerDirectives.transferToInterpreterAndInvalidate(); truffleFrame = otherTruffleFrame; size = otherSize; hasModifiedSender = otherHasModifiedSender; escaped = otherEscaped; }
Example #9
Source File: MumblerNode.java From mumbler with GNU General Public License v3.0 | 5 votes |
protected static MaterializedFrame getLexicalScope(Frame frame) { Object[] args = frame.getArguments(); if (args.length > 0) { return (MaterializedFrame) frame.getArguments()[0]; } else { return null; } }
Example #10
Source File: ContextObjectNodes.java From trufflesqueak with MIT License | 5 votes |
@SuppressWarnings("unused") @Specialization(guards = {"index >= TEMP_FRAME_START", "context == cachedContext", "index == cachedIndex"}, limit = "4") protected static final void doTempCached(final ContextObject context, final long index, final Object value, @Cached("context") final ContextObject cachedContext, @Cached("index") final long cachedIndex, @Cached("createWriteNode(cachedContext, cachedIndex)") final FrameSlotWriteNode writeNode) { final MaterializedFrame truffleFrame = cachedContext.getTruffleFrame(); FrameAccess.setArgumentIfInRange(truffleFrame, (int) (index - CONTEXT.TEMP_FRAME_START), value); writeNode.executeWrite(truffleFrame, value); }
Example #11
Source File: TruffleMumblerMain.java From mumbler with GNU General Public License v3.0 | 5 votes |
private static Object execute(MumblerNode[] nodes, MaterializedFrame globalFrame) { MumblerFunction function = MumblerFunction.create(null, new FrameSlot[] {}, nodes, globalFrame.getFrameDescriptor()); ((MumblerRootNode) function.callTarget.getRootNode()).setName("main"); return function.callTarget.call(globalFrame); }
Example #12
Source File: MumblerFunction.java From mumbler with GNU General Public License v3.0 | 4 votes |
public void setLexicalScope(MaterializedFrame lexicalScope) { this.lexicalScope = lexicalScope; }
Example #13
Source File: HashemEvaluateLocalNode.java From mr-hashemi with Universal Permissive License v1.0 | 4 votes |
HashemEvaluateLocalNode(HashemLanguage language, String variableName, MaterializedFrame frame) { super(language); this.variable = variableName; this.inspectFrame = frame; }
Example #14
Source File: MumblerFunction.java From mumbler with GNU General Public License v3.0 | 4 votes |
public MaterializedFrame getLexicalScope() { return lexicalScope; }
Example #15
Source File: MumblerContext.java From mumbler with GNU General Public License v3.0 | 4 votes |
private MaterializedFrame initGlobalFrame(MumblerLanguage lang) { VirtualFrame frame = Truffle.getRuntime().createVirtualFrame(null, this.globalFrameDescriptor); addGlobalFunctions(lang, frame); return frame.materialize(); }
Example #16
Source File: ContextObject.java From trufflesqueak with MIT License | 4 votes |
public MaterializedFrame getTruffleFrame() { return truffleFrame; }
Example #17
Source File: ContextObject.java From trufflesqueak with MIT License | 4 votes |
private MaterializedFrame getOrCreateTruffleFrame(final BlockClosureObject closure) { if (truffleFrame == null || FrameAccess.getClosure(truffleFrame) != closure) { final Object[] frameArguments; final CompiledBlockObject compiledBlock = closure.getCompiledBlock(); final int instructionPointer; final int stackPointer; if (truffleFrame != null) { // FIXME: Assuming here this context is not active, add check? assert FrameAccess.getSender(truffleFrame) != null : "Sender should not be null"; final Object[] dummyArguments = truffleFrame.getArguments(); final int expectedArgumentSize = FrameAccess.expectedArgumentSize(compiledBlock.getNumArgsAndCopied()); if (dummyArguments.length != expectedArgumentSize) { // Adjust arguments. frameArguments = Arrays.copyOf(dummyArguments, expectedArgumentSize); } else { frameArguments = truffleFrame.getArguments(); } if (truffleFrame.getFrameDescriptor().getSize() > 0) { instructionPointer = FrameAccess.getInstructionPointer(truffleFrame, compiledBlock); stackPointer = FrameAccess.getStackPointer(truffleFrame, compiledBlock); } else { // Frame slots unknown, so initialize PC and SP; instructionPointer = 0; stackPointer = compiledBlock.getNumArgsAndCopied(); } } else { // Receiver plus arguments. final Object[] squeakArguments = new Object[1 + compiledBlock.getNumArgsAndCopied()]; frameArguments = FrameAccess.newDummyWith(compiledBlock, NilObject.SINGLETON, closure, squeakArguments); instructionPointer = 0; stackPointer = compiledBlock.getNumArgsAndCopied(); } CompilerDirectives.transferToInterpreterAndInvalidate(); truffleFrame = Truffle.getRuntime().createMaterializedFrame(frameArguments, compiledBlock.getFrameDescriptor()); FrameAccess.assertSenderNotNull(truffleFrame); FrameAccess.assertReceiverNotNull(truffleFrame); FrameAccess.initializeMarker(truffleFrame, compiledBlock); FrameAccess.setContext(truffleFrame, compiledBlock, this); FrameAccess.setInstructionPointer(truffleFrame, compiledBlock, instructionPointer); FrameAccess.setStackPointer(truffleFrame, compiledBlock, stackPointer); } return truffleFrame; }
Example #18
Source File: ContextObject.java From trufflesqueak with MIT License | 4 votes |
public static ContextObject create(final MaterializedFrame frame, final CompiledCodeObject blockOrMethod) { final ContextObject context = new ContextObject(blockOrMethod.image, frame, blockOrMethod.getSqueakContextSize()); FrameAccess.setContext(frame, blockOrMethod, context); return context; }
Example #19
Source File: MumblerContext.java From mumbler with GNU General Public License v3.0 | 2 votes |
/** * @return A {@link MaterializedFrame} on the heap that contains all global * values. */ public MaterializedFrame getGlobalFrame() { return this.globalFrame; }
Example #20
Source File: GlobalSymbolNode.java From mumbler with GNU General Public License v3.0 | votes |
public abstract MaterializedFrame getGlobalFrame();