-
Notifications
You must be signed in to change notification settings - Fork 323
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
Conversation
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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);
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 " |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 <| |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
?
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. |
@@ -150,6 +150,9 @@ type Context | |||
## PRIVATE | |||
ADVANCED | |||
Output | |||
## PRIVATE |
There was a problem hiding this comment.
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.
## PRIVATE | |
## PRIVATE |
engine/runtime/src/main/java/org/enso/interpreter/runtime/error/DataflowError.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great
public static DataflowError withoutTrace(Object payload, Node location) { | ||
public static DataflowError withoutTrace(State state, Object payload, Node location) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
assert payload != null; | ||
if (assertsOn) { | ||
boolean attachFullStackTrace = |
There was a problem hiding this comment.
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.
This is part 1 of #8665, giving the ability to enable full stack traces for dataflow errors that are thrown from Enso code:
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:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
./run ide build
.