Simplify IGV graph by trimming nodes for code paths that rarely happen (#11381)

Simplifies the IGV graph by removing nodes that shouldn't be there during "normal" execution.
This commit is contained in:
Jaroslav Tulach 2024-10-23 17:30:48 +02:00 committed by GitHub
parent 4f556f2882
commit c460342f74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 30 additions and 16 deletions

View File

@ -1,6 +1,7 @@
package org.enso.interpreter.node.callable.dispatch; package org.enso.interpreter.node.callable.dispatch;
import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.TruffleFile; import com.oracle.truffle.api.TruffleFile;
import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached;
@ -119,6 +120,7 @@ public abstract class InvokeFunctionNode extends BaseNode {
if (!isPrivateCheckDisabled if (!isPrivateCheckDisabled
&& functionSchema.isProjectPrivate() && functionSchema.isProjectPrivate()
&& !isInSameProject(function)) { && !isInSameProject(function)) {
CompilerDirectives.transferToInterpreter();
throw makePrivateAccessPanic(function); throw makePrivateAccessPanic(function);
} }
} }

View File

@ -3,6 +3,7 @@ package org.enso.interpreter.runtime.data.atom;
import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.NodeFactory;
import com.oracle.truffle.api.exception.AbstractTruffleException; import com.oracle.truffle.api.exception.AbstractTruffleException;
import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.profiles.BranchProfile;
import java.util.List; import java.util.List;
import org.enso.interpreter.node.callable.InvokeCallableNode; import org.enso.interpreter.node.callable.InvokeCallableNode;
import org.enso.interpreter.node.callable.argument.ReadArgumentCheckNode; import org.enso.interpreter.node.callable.argument.ReadArgumentCheckNode;
@ -20,6 +21,7 @@ import org.enso.interpreter.runtime.error.DataflowError;
final class SuspendedFieldGetterNode extends UnboxingAtom.FieldGetterNode { final class SuspendedFieldGetterNode extends UnboxingAtom.FieldGetterNode {
@Node.Child private UnboxingAtom.FieldSetterNode set; @Node.Child private UnboxingAtom.FieldSetterNode set;
@Node.Child private UnboxingAtom.FieldGetterNode get; @Node.Child private UnboxingAtom.FieldGetterNode get;
private final BranchProfile exceptionalState = BranchProfile.create();
@Node.Child @Node.Child
private InvokeFunctionNode invoke = private InvokeFunctionNode invoke =
@ -97,15 +99,17 @@ final class SuspendedFieldGetterNode extends UnboxingAtom.FieldGetterNode {
set.execute(atom, newValue); set.execute(atom, newValue);
return newValue; return newValue;
} catch (AbstractTruffleException ex) { } catch (AbstractTruffleException ex) {
exceptionalState.enter();
var rethrow = DataflowError.withTrace(ex, ex); var rethrow = DataflowError.withTrace(ex, ex);
set.execute(atom, rethrow); set.execute(atom, rethrow);
throw ex; throw ex;
} }
} else if (value instanceof DataflowError suspended } else if (value instanceof DataflowError suspended) {
&& suspended.getPayload() instanceof AbstractTruffleException ex) { exceptionalState.enter();
if (suspended.getPayload() instanceof AbstractTruffleException ex) {
throw ex; throw ex;
} else { }
}
return value; return value;
} }
}
} }

View File

@ -511,8 +511,16 @@ public final class ModuleScope implements EnsoObject {
* currently registered entities * currently registered entities
*/ */
public ModuleScope asModuleScope() { public ModuleScope asModuleScope() {
if (moduleScope != null) return moduleScope; if (moduleScope != null) {
else return moduleScope;
} else {
CompilerDirectives.transferToInterpreterAndInvalidate();
return createModuleScope();
}
}
@CompilerDirectives.TruffleBoundary
private ModuleScope createModuleScope() {
return new ModuleScope( return new ModuleScope(
module, module,
associatedType, associatedType,