use of com.oracle.truffle.api.frame.MaterializedFrame in project graal by oracle.
the class DebugStackFrame method getScope.
/**
* Get the current inner-most scope. The scope remain valid as long as the current stack frame
* remains valid.
* <p>
* Use {@link DebuggerSession#getTopScope(java.lang.String)} to get scopes with global validity.
* <p>
* This method is not thread-safe and will throw an {@link IllegalStateException} if called on
* another thread than it was created with.
*
* @return the scope, or <code>null</code> when no language is associated with this frame
* location, or when no local scope exists.
* @since 0.26
*/
public DebugScope getScope() {
verifyValidState(false);
SuspendedContext context = getContext();
RootNode root = findCurrentRoot();
if (root == null) {
return null;
}
Node node;
if (currentFrame == null) {
node = context.getInstrumentedNode();
} else {
node = currentFrame.getCallNode();
}
if (node.getRootNode().getLanguageInfo() == null) {
// no language, no scopes
return null;
}
Debugger debugger = event.getSession().getDebugger();
MaterializedFrame frame = findTruffleFrame();
Iterable<Scope> scopes = debugger.getEnv().findLocalScopes(node, frame);
Iterator<Scope> it = scopes.iterator();
if (!it.hasNext()) {
return null;
}
return new DebugScope(it.next(), it, debugger, event, frame, root);
}
use of com.oracle.truffle.api.frame.MaterializedFrame in project graal by oracle.
the class FrameTest method framesCanBeMaterialized.
@Test
public void framesCanBeMaterialized() {
final TruffleRuntime runtime = Truffle.getRuntime();
class FrameRootNode extends RootNode {
FrameRootNode() {
super(null);
}
@Override
public Object execute(VirtualFrame frame) {
FrameInstance frameInstance = runtime.getCurrentFrame();
Frame readWrite = frameInstance.getFrame(FrameInstance.FrameAccess.READ_WRITE);
Frame materialized = frameInstance.getFrame(FrameInstance.FrameAccess.MATERIALIZE);
assertTrue("Really materialized: " + materialized, materialized instanceof MaterializedFrame);
assertEquals("It's my frame", frame, readWrite);
return this;
}
}
FrameRootNode frn = new FrameRootNode();
Object ret = Truffle.getRuntime().createCallTarget(frn).call();
assertEquals("Returns itself", frn, ret);
}
use of com.oracle.truffle.api.frame.MaterializedFrame in project graal by oracle.
the class DebuggerSessionSnippets method evalInContext.
/**
* Evaluates a snippet of code in a halted execution context. Assumes frame is part of the
* current execution stack, behavior is undefined if not.
*
* @param ev event notification where execution is halted
* @param code text of the code to be executed
* @param frameInstance frame where execution is halted
* @return
* @throws IOException
*/
static Object evalInContext(SuspendedEvent ev, String code, FrameInstance frameInstance) throws IOException {
try {
Node node;
MaterializedFrame frame;
if (frameInstance == null) {
node = ev.getContext().getInstrumentedNode();
frame = ev.getMaterializedFrame();
} else {
node = frameInstance.getCallNode();
frame = frameInstance.getFrame(FrameAccess.MATERIALIZE).materialize();
}
return Debugger.ACCESSOR.evalInContext(node, frame, code);
} catch (KillException kex) {
throw new IOException("Evaluation was killed.", kex);
}
}
use of com.oracle.truffle.api.frame.MaterializedFrame in project sulong by graalvm.
the class LLVMGlobalWriteNode method slowPrimitiveWrite.
public static void slowPrimitiveWrite(LLVMContext context, LLVMMemory memory, PrimitiveType primitiveType, LLVMGlobal global, Object value) {
MaterializedFrame frame = context.getGlobalFrame();
FrameSlot slot = global.getSlot();
boolean isNative = frame.getValue(slot) instanceof Native;
long address = isNative ? ((Native) frame.getValue(slot)).getPointer() : 0;
switch(primitiveType.getPrimitiveKind()) {
case I1:
if (isNative) {
memory.putI1(address, (boolean) value);
} else {
frame.setBoolean(slot, (boolean) value);
}
return;
case I8:
if (isNative) {
memory.putI8(address, (byte) value);
} else {
frame.setByte(slot, (byte) value);
}
return;
case I16:
if (isNative) {
memory.putI16(address, (short) value);
} else {
frame.setInt(slot, (short) value);
}
return;
case I32:
if (isNative) {
memory.putI32(address, (int) value);
} else {
frame.setInt(slot, (int) value);
}
return;
case I64:
if (isNative) {
memory.putI64(address, (long) value);
} else {
frame.setLong(slot, (long) value);
}
return;
case FLOAT:
if (isNative) {
memory.putFloat(address, (float) value);
} else {
frame.setFloat(slot, (float) value);
}
return;
case DOUBLE:
if (isNative) {
memory.putDouble(address, (double) value);
} else {
frame.setDouble(slot, (double) value);
}
return;
}
CompilerDirectives.transferToInterpreter();
throw new IllegalStateException();
}
Aggregations