Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Runtime.Context.Dataflow_Stack_Trace for dataflow errors thrown from Enso #9625

Merged
merged 15 commits into from
Jul 26, 2024

Conversation

GregoryTravis
Copy link
Contributor

This is part 1 of #8665, giving the ability to enable full stack traces for dataflow errors that are thrown from Enso code:

        Context.Dataflow_Stack_Trace.with_enabled <|
            throw_something_here

The next part will implement the same check for dataflow errors thrown (returned) directly from Java.

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

@GregoryTravis GregoryTravis changed the title Wip/gmt/8665 stack trace context Implement Runtime.Context.Dataflow_Stack_Trace for dataflow errors thrown from Enso Apr 3, 2024
public Object execute(VirtualFrame giveMeAStackFrame, Object payload) {
return DataflowError.withoutTrace(payload, this);
public Object execute(VirtualFrame giveMeAStackFrame, State state, Object payload) {
return DataflowError.withoutTrace(state, payload, this);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing State this way might be a temporary solution; there might be another approach I will use when calling withoutTrace from Java which makes this unnecessary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this State argument change modifies the ThrowErrorNodeGen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diff:

112a113,114
>     /***  Start of processing argument 0  ***/
>     /***  End of processing argument 0  ***/
127c129
<         result = bodyNode.execute(frame, arg1);
---
>         result = bodyNode.execute(frame, state, arg1);
139c141
<         return bodyNode.execute(frame, arg1);
---
>         return bodyNode.execute(frame, state, arg1);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. So we can get access to State when we have args and we extract it from there. This is tedious, especially when we consider

It makes more sense to fix #7117 by storing the state in ContextThreadLocal. Then it is going to be easy to access it even when our interpreter code doesn't have access to args.

@@ -61,6 +55,10 @@ public static DataflowError withoutTrace(Object payload, Node location) {
}
}

public static DataflowError withoutTrace(Object payload, Node location) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This overload is here for the calls to withoutTrace which originate in Java and cannot pass a State value. This will be removed in part 2 which implements the same functionality for such calls.

@@ -161,6 +164,7 @@ type Context
case self of
Input -> "Input"
Output -> "Output"
Dataflow_Stack_Trace -> "Dataflow_Stack_Trace "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there a space at the end of the text literal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

shallow_stack_trace.length . should_equal 1
shallow_stack_trace.at 0 . name . should_equal (names.at 0)

Context.Dataflow_Stack_Trace.with_enabled <|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, this is the right test.

public Object execute(VirtualFrame giveMeAStackFrame, Object payload) {
return DataflowError.withoutTrace(payload, this);
public Object execute(VirtualFrame giveMeAStackFrame, State state, Object payload) {
return DataflowError.withoutTrace(state, payload, this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this State argument change modifies the ThrowErrorNodeGen?

@GregoryTravis
Copy link
Contributor Author

As I discussed with @JaroslavTulach, it makes sense to merge this PR to implement the context control for dataflow errors coming from Enso code, and do errors coming from Java in another PR.

@GregoryTravis GregoryTravis added the CI: No changelog needed Do not require a changelog entry for this PR. label Apr 4, 2024
@enso-bot enso-bot bot mentioned this pull request Apr 5, 2024
2 tasks
@@ -150,6 +150,9 @@ type Context
## PRIVATE
ADVANCED
Output
## PRIVATE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a newline between the constructors.

Suggested change
## PRIVATE
## PRIVATE

Copy link
Member

@radeusgd radeusgd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great

Comment on lines 52 to 45
public static DataflowError withoutTrace(Object payload, Node location) {
public static DataflowError withoutTrace(State state, Object payload, Node location) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename this constructor?

It is not really withoutTrace, more like withDefaultTrace or something like that.

I'd also like to update the comment to mention that it has the default location (top elem) or full stack depending on the Context.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed.

…g/enso into wip/gmt/8665-stack-trace-context
@GregoryTravis GregoryTravis added the CI: Ready to merge This PR is eligible for automatic merge label Jul 26, 2024
@mergify mergify bot merged commit f0e9616 into develop Jul 26, 2024
42 checks passed
@mergify mergify bot deleted the wip/gmt/8665-stack-trace-context branch July 26, 2024 19:20
assert payload != null;
if (assertsOn) {
boolean attachFullStackTrace =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a regression in standard library benchmarks

My hypothesis: It has to be caused the call to hasContextEnabled check on this line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants