-
Notifications
You must be signed in to change notification settings - Fork 702
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
Minor fixes for dump printing #2342
base: main
Are you sure you want to change the base?
Conversation
eeaec87
to
2e1b9b5
Compare
test/dump/const.txt
Outdated
00004b: 80 7f | | ||
00004d: 1a | drop | ||
00004e: 42 7f | i64.const -1 | ||
00004e: 42 7f | i64.const 18446744073709551615 |
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.
Are you sure it makes more sense to show these as unsigned?
The numbers are read signed values in the binary reader so maybe it makes sense to show them as signed in the disassembly too?
Line 827 in 2428315
CHECK_RESULT(ReadS64Leb128(&value, "i64.const value")); |
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 there some kind of bug in the literal parser that you are fixing here? If so, I wonder why it was not triggered by any of the spec tests? Are we missing a spec test maybe?
This is coming from my unorthodox usage of wabt—I'm doing some binary parsing and using the dump output as part of my test fixturing to make sure I can produce the same output for the same binary and in reimplementing some of the printing I'm seeing some of the rough edges here.
Either way, it's the const printing inconsistency that's the problem because wabt/src/binary-reader-objdump.cc Line 787 in 2428315
i.e. current test fixtures for the dump even show this discrepancy - see input at the top vs output at the bottom:
The one minor wrinkle in printing them signed is that they are represented unsigned internally and the path to printing is a straightforward one through
Although, for the text spec we have:
So 🤷 are we text or abstract/binary at the point of dumping? |
Could you upload a separate PR for the i64.const printing? I agree it should be consistent with i32.const. I'm not sure I understand the other two items yet.. |
2e1b9b5
to
d676e0f
Compare
Done, leaving this with just the ParseHex change and the extraneous Going deeper into the The What's happening here, and why it's not being picked up by existing tests, is that this branch is only encountered for subnormals, which aren't covered in the dump tests. They are covered in the const.wast spec tests, but not as hexfloat output. I've added a new commit to this branch that passes with the current Clear as mud I'm sure. |
This matches the behaviour of i32 printing. Ref: #2342
96930b2
to
7d48b53
Compare
Digging further into the parse hex thing I've done here, after tracing the normal path of incoming tokens, I can see nan and inf being handled entirely separately in the text lexer and coming in to literal.cc with an indicator that separates the parsing path. So, I've backed out that change that adds extra logic inside And I can flip those failing tests around when you're happy with the change, I just want to demonstrate what it's doing now with those. |
with the help of some wabt upstream fixes: WebAssembly/wabt#2342
7d48b53
to
f5768fe
Compare
f5768fe
to
33ed5f8
Compare
@sbc100 I've fixed the tests with the new subnormal additions so that it passes now. Below is a capture of what it looks like with subnormals added but printing using the format that it comes out if you run the version on Capture of test failure with subnormals included
|
FloatParser<T>::ParseHex
should be able to handlenan
,nan:*
and±inf
too.
in the float hex format,0x1.p+0
is not correct