diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/ExpressionNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/ExpressionNode.java index c7c5ceced3..df2d58b2a4 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/ExpressionNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/ExpressionNode.java @@ -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 diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/function/BlockNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/function/BlockNode.java index a7e4ff525e..fd911a4705 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/function/BlockNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/function/BlockNode.java @@ -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> 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])); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/EnsoContext.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/EnsoContext.java index a9a31d4098..977aae3304 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/EnsoContext.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/EnsoContext.java @@ -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. *