mirror of
https://github.com/enso-org/enso.git
synced 2024-11-24 08:41:40 +03:00
ExpressionNodes are only wrapped in the presence of Chrome inspector (#3970)
Fixes bug in visualization of host polyglot values - `ExpressionNode` is only wrapped once Chrome inspector instrument is attached to the context. With this fix, when chromeinspector is attached (`enso --run --inspect ...`), all the host values are reinterpreted as text - the assumption is invalidated. But when running as language server, nothing is wrapped.
This commit is contained in:
parent
8e880e430b
commit
b91ae2f5ef
@ -20,6 +20,7 @@ import com.oracle.truffle.api.nodes.UnexpectedResultException;
|
||||
import com.oracle.truffle.api.source.SourceSection;
|
||||
import java.util.UUID;
|
||||
import org.enso.interpreter.instrument.HostObjectDebugWrapper;
|
||||
import org.enso.interpreter.runtime.EnsoContext;
|
||||
import org.enso.interpreter.runtime.builtin.Builtins;
|
||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||
import org.enso.interpreter.runtime.callable.atom.AtomConstructor;
|
||||
@ -223,7 +224,12 @@ public abstract class ExpressionNode extends BaseNode implements InstrumentableN
|
||||
*/
|
||||
@OutgoingConverter
|
||||
public Object wrapHostObjects(Object retValue) {
|
||||
return HostObjectDebugWrapper.wrapHostValues(retValue, InteropLibrary.getUncached());
|
||||
// Wrap only if chrome inspector is attached.
|
||||
if (EnsoContext.get(this).getChromeInspectorNotAttached().isValid()) {
|
||||
return retValue;
|
||||
} else {
|
||||
return HostObjectDebugWrapper.wrapHostValues(retValue, InteropLibrary.getUncached());
|
||||
}
|
||||
}
|
||||
|
||||
@ExportMessage
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.enso.interpreter.node.callable.function;
|
||||
|
||||
import com.oracle.truffle.api.Assumption;
|
||||
import com.oracle.truffle.api.frame.VirtualFrame;
|
||||
import com.oracle.truffle.api.instrumentation.InstrumentableNode;
|
||||
import com.oracle.truffle.api.instrumentation.StandardTags;
|
||||
@ -8,6 +9,7 @@ import com.oracle.truffle.api.nodes.ExplodeLoop;
|
||||
import com.oracle.truffle.api.nodes.NodeInfo;
|
||||
import java.util.Set;
|
||||
import org.enso.interpreter.node.ExpressionNode;
|
||||
import org.enso.interpreter.runtime.EnsoContext;
|
||||
|
||||
/**
|
||||
* This node defines the body of a function for execution, as well as the protocol for executing the
|
||||
@ -63,6 +65,14 @@ public class BlockNode extends ExpressionNode {
|
||||
public InstrumentableNode materializeInstrumentableNodes(
|
||||
Set<Class<? extends Tag>> materializedTags) {
|
||||
if (materializedTags.contains(StandardTags.StatementTag.class)) {
|
||||
var ctx = EnsoContext.get(this);
|
||||
if (ctx != null) {
|
||||
Assumption chromeInspectorNotAttached = ctx.getChromeInspectorNotAttached();
|
||||
if (chromeInspectorNotAttached.isValid()
|
||||
&& ctx.getEnvironment().getInstruments().containsKey("inspect")) {
|
||||
chromeInspectorNotAttached.invalidate("Chrome inspector attached");
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < statements.length; i++) {
|
||||
if (!isNodeWrapped(statements[i])) {
|
||||
statements[i] = insert(StatementNode.wrap(statements[i]));
|
||||
|
@ -1,6 +1,8 @@
|
||||
package org.enso.interpreter.runtime;
|
||||
|
||||
import com.oracle.truffle.api.Assumption;
|
||||
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
|
||||
import com.oracle.truffle.api.Truffle;
|
||||
import com.oracle.truffle.api.TruffleFile;
|
||||
import com.oracle.truffle.api.TruffleLanguage;
|
||||
import com.oracle.truffle.api.TruffleLanguage.Env;
|
||||
@ -68,6 +70,9 @@ public class EnsoContext {
|
||||
private final LockManager lockManager;
|
||||
private final AtomicLong clock = new AtomicLong();
|
||||
|
||||
private final Assumption chromeInspectorNotAttached =
|
||||
Truffle.getRuntime().createAssumption("chromeInspectorNotAttached");
|
||||
|
||||
private final Shape rootStateShape = Shape.newBuilder().layout(State.Container.class).build();
|
||||
private final IOPermissions rootIOPermissions;
|
||||
|
||||
@ -203,6 +208,11 @@ public class EnsoContext {
|
||||
return compiler;
|
||||
}
|
||||
|
||||
/** Returns an {@link Assumption} that Chrome inspector is not attached to this context. */
|
||||
public Assumption getChromeInspectorNotAttached() {
|
||||
return chromeInspectorNotAttached;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link Env} instance used by this context.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user