Skip to content

[GUFA] Simplify routines for dropping children (NFC) #4787

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

Merged
merged 29 commits into from
Jul 18, 2022
Merged

Conversation

aheejin
Copy link
Member

@aheejin aheejin commented Jul 9, 2022

I think we can actually move all the checking routines to
getDroppedUnconditionalChildrenAndAppend and remove canRemove and
canRemoveStructurally. Checking things in three different places was a
little hard to understand, and I think
getDroppedUnconditionalChildrenAndAppend actually needs to exclude
more things that canRemoveStructurally covers, if it is to be used in
other places as well.

Additionally, I think it'd better to make these two dropping-children
functions (getDroppedChildrenAndAppend and
getDroppedUnconditionalChildrenAndAppend) to a cpp file and make
getDroppedChildrenAndAppend an internal function, inaccessible to
outer passes, given that it looks all places should use
getDroppedUnconditionalChildrenAndAppend instead. But this can be a
follow-up.

kripken and others added 14 commits July 7, 2022 10:32
#4758 regressed the determinism fuzzer. First, FEATURE_OPTS is not a
list but a string. Second, as a hack another location would add --strip-dwarf
to that list, but that only works in wasm-opt. To fix that, remove the hack
and instead just ignore DWARF-containing files.
Grouping all references together makes it easier for baseline compilers to
zero out memory (as the zeroing out may be different for MVP types vs.
references).

This puts all references together, either at the start or the end. As a
heuristic for that we see if the first local is a reference. As the optimizer
will sort locals by frequency, this ensures that the most-frequent local
stays in index 0.

Fixes #4773. See more details there
Parse type definitions with the format `(type $t (sub $super ...))`. Update the
test to use hybrid types so that the subtypes are reflected in the test output.
This implements it as a StringMeasure opcode. They do have the same number of
operands, same trapping behavior, and same return type. They both get a string and
do some inspection of it to return an i32. Perhaps the name could be StringInspect
or something like that, rather than StringMeasure..? But I think for now this might be
good enough, and the spec may change anyhow later.
This marks all reference operations that return 0/1 as doing so. This
allows various bitwise operations to be optimized on them.

This also marks StringEq as a boolean, though we can't test that fully yet
as Strings support is wip (no interpreter or other stuff yet).

As a driveby this moves emitsBoolean to its own file, and uses it
in getMaxBits to avoid redundancy (the redundant code paths now have
a WASM_UNREACHABLE).
I think we can actually move all the checking routines to
`getDroppedUnconditionalChildrenAndAppend` and remove `canRemove` and
`canRemoveStructurally`. Checking things in three different places was a
little hard to understand, and I think
`getDroppedUnconditionalChildrenAndAppend` actually needs to exclude
more things that `canRemoveStructurally` covers, if it is to be used in
other places as well.

Additionally, I think it'd better to make these two dropping-children
functions (`getDroppedChildrenAndAppend` and
`getDroppedUnconditionalChildrenAndAppend`) to a cpp file and make
`getDroppedChildrenAndAppend` an internal function, inaccessible to
outer passes, given that it looks all places should use
`getDroppedUnconditionalChildrenAndAppend` instead. But this can be a
follow-up.

Not sure why the test signatures change. May need to investigate..?
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.

Nice! Definitely simpler.

kripken and others added 11 commits July 11, 2022 20:00
binaryen.js uses allocate, which is no longer exported by default in emscripten
tip of tree builds.
Update gen-s-parser.py to produce a second version of its parsing code that
works with the new wat parser. The new version automatically replaces the `s`
element argument in the existing parser with the `ctx` and `in` arguments used
by the new parser, so adding new instructions will not require any additional
work in gen-s-parser.py after this change.

Also add stub `make***` functions to the new wat parser, with a few filled out,
namely `makeNop`, `makeUnreachable`, `makeConst`, and `makeRefNull`. Update the
`global` parser to parse global initializer instructions and update
wat-kitchen-sink.wast to demonstrate that the instructions are parsed correctly.

Adding new instruction classes will require adding a new `make***` function to
wat-parser.cpp in additional to wasm-s-parser.{h,cpp} after this change, but
adding a trivial failing implementation is good enough for the time being, so I
don't expect this to appreciably increase our maintenance burden in the near
term.

The infrastructure for parsing folded instructions, instructions with operands,
and control flow instructions will be implemented in future PRs.
This reverts commit 7988682, reversing
changes made to 0da2d8c.
This reverts commit d556760.
@kripken
Copy link
Member

kripken commented Jul 18, 2022

@aheejin I think we can merge this into the gufa branch? (the CI error can be ignored)

@aheejin aheejin merged commit 5198ccc into gufa Jul 18, 2022
@aheejin aheejin deleted the improve_remove branch July 18, 2022 22:25
@aheejin aheejin restored the improve_remove branch July 18, 2022 22:30
@aheejin aheejin deleted the improve_remove branch July 18, 2022 22:35
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.

3 participants