Skip to content

Conversation

tlively
Copy link
Member

@tlively tlively commented Feb 8, 2024

Get as many of the lit tests as possible to parse with the new parser, mostly by
moving declared module items to be after imports. Also fix a bug in the new
parser's pop validation to allow supertypes of the expected type.

The two big issues that still prevent some lit tests from working correctly
under the new parser are missing support for symbolic field names and missing
support for source map annotations.

Removing support for the legacy syntax will allow us to avoid implementing support for it in the new text parser.
Get as many of the lit tests as possible to parse with the new parser, mostly by moving declared module items to be after imports. Also fix a bug in the new parser's pop validation to allow supertypes of the expected type. The two big issues that still prevent some lit tests from working correctly under the new parser are missing support for symbolic field names and missing support for source map annotations.
@tlively tlively requested a review from kripken February 8, 2024 20:01
@tlively
Copy link
Member Author

tlively commented Feb 8, 2024

}
auto expectedType = scope.exprStack[0]->type;
if (type != expectedType) {
if (!Type::isSubType(expectedType, type)) {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be flipped? That is, the seen type should be a subtype of the expected type?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, in this case if I catch e.g. eqref, it would be valid and safe to overapproximate and have a pop anyref, but it would not be safe or valid to have pop i31ref, since the eqref I'm catching may not be an i31ref.


;; CHECK: (table $0 2 2 funcref)
;; CHECK: (memory $m 1 2)
(memory $m 1 2)
Copy link
Member

Choose a reason for hiding this comment

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

Why add a name here rather than just move it around?

Copy link
Member Author

Choose a reason for hiding this comment

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

Just to improve the output ordering. Adding the name doesn't affect whether the new parser can parse it.

;; As above, but the side effects now are a br. Again, the br must happen
;; before the trap (in fact, the br will skip the trap here).
(block
(block $block
Copy link
Member

Choose a reason for hiding this comment

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

Weird, how did this parse and validate 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.

Because the parser magically assigned the default name "$block" and it happened to match 😆

;; CHECK: (import "wasm:js-string" "fromCodePoint" (func $fromCodePoint_5 (type $5) (param i32) (result (ref extern))))

;; CHECK: (memory $m 1)
(memory $m 1)
Copy link
Member

Choose a reason for hiding this comment

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

Why does this test need a memory? I don't seem to see any memory-using instructions.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, you're right. Will remove.

@tlively tlively requested a review from kripken February 8, 2024 21:52
@tlively
Copy link
Member Author

tlively commented Feb 8, 2024

Merge activity

  • Feb 8, 5:59 PM EST: @tlively started a stack merge that includes this pull request via Graphite.
  • Feb 8, 6:00 PM EST: Graphite couldn't merge this PR because it had conflicts with the trunk branch.
Base automatically changed from remove-legacy-string-syntax to main February 8, 2024 23:00
@tlively tlively merged commit f5d8d30 into main Feb 8, 2024
@tlively tlively deleted the parser-lit-fixes branch February 8, 2024 23:27
radekdoulik pushed a commit to dotnet/binaryen that referenced this pull request Jul 12, 2024
Get as many of the lit tests as possible to parse with the new parser, mostly by moving declared module items to be after imports. Also fix a bug in the new parser's pop validation to allow supertypes of the expected type. The two big issues that still prevent some lit tests from working correctly under the new parser are missing support for symbolic field names and missing support for source map annotations.
@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

2 participants