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

Drop support for non-standard quoted function names #6188

Merged
merged 2 commits into from
Dec 20, 2023
Merged

Conversation

tlively
Copy link
Member

@tlively tlively commented Dec 20, 2023

We previously supported a non-standard (func "name" ... syntax for declaring
functions exported with the quoted name. Since that is not part of the standard
text format, drop support for it, replacing it with the standard (func $name (export "name") ... syntax instead.

Also replace our other usage of the quoted form in our text output, which was
where we quoted names containing characters that are not allowed to appear in
standard names. To handle that case, adjust our output from "$name" to
$"name", which is the standards-track way of supporting such names. Also fix
how we detect non-standard name characters to match the spec.

Update the lit test output generation script to account for these changes,
including by making the $ prefix on names mandatory. This causes the script to
stop interpreting declarative element segments with the (elem declare ...
syntax as being named "declare", so prevent our generated output from regressing
by counting "declare" as a name in the script.

We previously supported a non-standard `(func "name" ...` syntax for declaring
functions exported with the quoted name. Since that is not part of the standard
text format, drop support for it, replacing it with the standard `(func $name
(export "name") ...` syntax instead.

Also replace our other usage of the quoted form in our text output, which was
where we quoted names containing characters that are not allowed to appear in
standard names. To handle that case, adjust our output from `"$name"` to
`$"name"`, which is the standards-track way of supporting such names. Also fix
how we detect non-standard name characters to match the spec.

Update the lit test output generation script to account for these changes,
including by making the `$` prefix on names mandatory. This causes the script to
stop interpreting declarative element segments with the `(elem declare ...`
syntax as being named "declare", so prevent our generated output from regressing
by printing a real name for these segments to ensure the output generation
script continues including them.
@tlively
Copy link
Member Author

tlively commented Dec 20, 2023

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

@tlively tlively requested a review from kripken December 20, 2023 17:53
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.

I have a strong recollection that this used to be a thing in the wast format. Did we remove it? Or is my memory wrong? Either way, if it isn't any more, sgtm to remove it.

@@ -4,12 +4,12 @@
(type $0 (func (param f32 i31ref i64 f64 funcref)))
(type $1 (func (result funcref)))
(global $global$0 (mut funcref) (ref.null nofunc))
(elem declare func $0)
(export "export" (func $1))
(elem $decl declare func$0)
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 this now named?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, this is the last paragraph in the description I guess. But why does fixing the parsing force us to add names here? It is valid even without the name, isn't it? If so doesn't that mean we no longer parse valid code?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is an output .txt file, so the printer now names this. We don't need to name declarative segments in the input.

Copy link
Member

Choose a reason for hiding this comment

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

Can we avoid printing this name in the output, if it's unnecessary? It just seems to add clutter compared to before.

Copy link
Member Author

Choose a reason for hiding this comment

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

The auto update script only recognizes named items, so even with --all-items, it won't include these declarative segments in the output unless we give them names. It previously included them because it thought "declare" was its name.

Are you ok with dropping declarative element segments from generated test output? If so, I can remove this emitted name. Otherwise we can consider trying to change how the update script works, but that is very difficult.

Copy link
Member

Choose a reason for hiding this comment

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

I'm confused, didn't that work before this PR? We didn't have named declarative segments before, so it seems like it must have?

@tlively
Copy link
Member Author

tlively commented Dec 20, 2023

I would believe that this might have been a thing pre-1.0, but I don't know for sure. It's definitely not in the spec now.

@tlively
Copy link
Member Author

tlively commented Dec 20, 2023

By counting declare as a name as a special case, I was able to include declarative segments in the output without having to name them.

@tlively tlively requested a review from kripken December 20, 2023 21:04
;; NORMAL-NEXT: [trap unreachable]
;; TNH: [fuzz-exec] calling foo
;; TNH-NEXT: [LoggingExternalInterface logging 42]
;; TNH-NEXT: [trap unreachable]
Copy link
Member

Choose a reason for hiding this comment

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

These lines seem to duplicate new lines 64-67? Might be a pre-existing problem before this PR, but it's odd this PR just hoists one of them and not the other.

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 know why the execution log is duplicated in the first place? I think only the first repetition was hoisted because the update script only knows to pair a single ouput item with a given input item.

Copy link
Member

Choose a reason for hiding this comment

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

No idea. But from what you say the updater script is doing the right thing, so it's definitely a separate issue.

@tlively tlively merged commit fb7d00b into main Dec 20, 2023
27 checks passed
@tlively tlively deleted the standard-func-names branch December 20, 2023 22:17
radekdoulik pushed a commit to dotnet/binaryen that referenced this pull request Jul 12, 2024
We previously supported a non-standard `(func "name" ...` syntax for declaring
functions exported with the quoted name. Since that is not part of the standard
text format, drop support for it, replacing it with the standard `(func $name
(export "name") ...` syntax instead.

Also replace our other usage of the quoted form in our text output, which was
where we quoted names containing characters that are not allowed to appear in
standard names. To handle that case, adjust our output from `"$name"` to
`$"name"`, which is the standards-track way of supporting such names. Also fix
how we detect non-standard name characters to match the spec.

Update the lit test output generation script to account for these changes,
including by making the `$` prefix on names mandatory. This causes the script to
stop interpreting declarative element segments with the `(elem declare ...`
syntax as being named "declare", so prevent our generated output from regressing
by counting "declare" as a name in the script.
@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