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

[Parser] Support prologue and epilogue sourcemap annotations #6370

Merged
merged 2 commits into from
Mar 4, 2024

Conversation

tlively
Copy link
Member

@tlively tlively commented Mar 1, 2024

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.

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.
@tlively tlively requested a review from kripken March 1, 2024 03:54
@tlively
Copy link
Member Author

tlively commented Mar 1, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @tlively and the rest of your teammates on Graphite Graphite

Copy link
Member

@kripken kripken left a 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;
Copy link
Member

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?)

Copy link
Member Author

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?

Copy link
Member

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)
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds ok to me.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@tlively tlively merged commit 53f8d5f into main Mar 4, 2024
28 checks passed
@tlively tlively deleted the parser-sourcemap-prolog-epilog branch March 4, 2024 23:50
@gkdn gkdn mentioned this pull request Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants