-
Notifications
You must be signed in to change notification settings - Fork 747
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
[Parser] Support prologue and epilogue sourcemap annotations #6370
Conversation
and fix a bug with sourcemap annotations on folded `if` conditions. Update IRBuilder to apply prologue and epilogue source locations when beginning and ending a function scope. Add basic support in the parser for explicitly tracking annotations on module fields, although only do anything with them in the case of prologue source location annotations.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
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.
lgtm % question
const Annotation* annotation = nullptr; | ||
for (auto& a : annotations) { | ||
if (a.kind == srcAnnotationKind) { | ||
annotation = &a; |
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 is just moved code, but I a question: can there be more than one srcAnnotationKind
? (seems like if so then the last wins?)
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.
Yes and yes. Is there some other existing behavior I should try to match instead?
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.
I can't think of one, so lgtm.
;;@ src.cpp:50:1 | ||
(then | ||
;; For the new parser | ||
;;@ src.cpp:50:1 | ||
(return) |
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 like the old parser doesn't roundtrip this properly and the new one does, is that correct? Perhaps add a comment to clarify that so it's obvious why we have these two 50:1 annotations?
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.
They can both round-trip properly, but the old one only if the annotation is on the then
and the new one only if the annotation is on the return
. Do you think this kind of breaking change is going to be an issue? We can make sure j2wasm is doing the right thing, but other users would be more difficult.
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.
Is it hard to match the old behavior?
This doesn't seem like a dangerous breaking change to me, as our text format in general is not entirely standard nor stable, but we should document it.
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 would be some very ad-hoc plumbing required to carry the annotation from the then
to the first instruction inside the then
, so I'd like to avoid it if it's not necessary.
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.
Sounds ok to me.
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.
Do you have a suggestion about where to document it? The changelog might make sense, but more so if we were actually enabling the new parser at the same time.
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.
Yes, the changelog. I agree it makes more sense when we enable the new parser. Maybe we can put a note in the changelog up above the current release notes, in preparation for enabling the new parser, to remind us, or something like that.
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.
Done.
and fix a bug with sourcemap annotations on folded
if
conditions. UpdateIRBuilder to apply prologue and epilogue source locations when beginning and ending
a function scope. Add basic support in the parser for explicitly tracking
annotations on module fields, although only do anything with them in the case of
prologue source location annotations.