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;
import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.TruffleFile;
import com.oracle.truffle.api.dsl.Cached;
@ -119,6 +120,7 @@ public abstract class InvokeFunctionNode extends BaseNode {
if (!isPrivateCheckDisabled
&& functionSchema.isProjectPrivate()
&& !isInSameProject(function)) {
CompilerDirectives.transferToInterpreter();
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.exception.AbstractTruffleException;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.profiles.BranchProfile;
import java.util.List;
import org.enso.interpreter.node.callable.InvokeCallableNode;
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 {
@Node.Child private UnboxingAtom.FieldSetterNode set;
@Node.Child private UnboxingAtom.FieldGetterNode get;
private final BranchProfile exceptionalState = BranchProfile.create();
@Node.Child
private InvokeFunctionNode invoke =
@ -97,15 +99,17 @@ final class SuspendedFieldGetterNode extends UnboxingAtom.FieldGetterNode {
set.execute(atom, newValue);
return newValue;
} catch (AbstractTruffleException ex) {
exceptionalState.enter();
var rethrow = DataflowError.withTrace(ex, ex);
set.execute(atom, rethrow);
throw ex;
}
} else if (value instanceof DataflowError suspended
&& suspended.getPayload() instanceof AbstractTruffleException ex) {
throw ex;
} else {
return value;
} else if (value instanceof DataflowError suspended) {
exceptionalState.enter();
if (suspended.getPayload() instanceof AbstractTruffleException ex) {
throw ex;
}
}
return value;
}
}

View File

@ -511,17 +511,25 @@ public final class ModuleScope implements EnsoObject {
* currently registered entities
*/
public ModuleScope asModuleScope() {
if (moduleScope != null) return moduleScope;
else
return new ModuleScope(
module,
associatedType,
Collections.unmodifiableMap(polyglotSymbols),
Collections.unmodifiableMap(types),
Collections.unmodifiableMap(methods),
Collections.unmodifiableMap(conversions),
Collections.unmodifiableSet(imports),
Collections.unmodifiableSet(exports));
if (moduleScope != null) {
return moduleScope;
} else {
CompilerDirectives.transferToInterpreterAndInvalidate();
return createModuleScope();
}
}
@CompilerDirectives.TruffleBoundary
private ModuleScope createModuleScope() {
return new ModuleScope(
module,
associatedType,
Collections.unmodifiableMap(polyglotSymbols),
Collections.unmodifiableMap(types),
Collections.unmodifiableMap(methods),
Collections.unmodifiableMap(conversions),
Collections.unmodifiableSet(imports),
Collections.unmodifiableSet(exports));
}
@Override