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

Fuzzer: Better fuzzing of globals #6611

Merged
merged 11 commits into from
May 21, 2024
Merged

Conversation

kripken
Copy link
Member

@kripken kripken commented May 20, 2024

With this PR we generate global.gets in globals, which we did not do before.
We do that by replacing makeConst (the only thing we did before, for the
contents of globals) with makeTrivial, and add code to makeTrivial to sometimes
make a global.get. When no suitable global exists, makeGlobalGet will emit a
constant, so there is no danger in trying.

Also raise the number of globals a little.

Also explicitly note the current limitation of requiring all tuple globals to contain
tuple.make and nothing else, including not global.get, and avoid adding such
invalid global.gets in tuple globals in the fuzzer.

@kripken kripken requested a review from tlively May 20, 2024 20:32
@kripken
Copy link
Member Author

kripken commented May 20, 2024

Here is an example output from this:

 (global $global$32 (ref null $12) (struct.new $12
  (ref.func $1)
  (f32.const -3402823466385288598117041e14)
  (struct.new $8
   (ref.func $1)
   (global.get $global$29)
   (i32.const 127)
   (global.get $global$19)
   (f32.const 0)
  )
 ))

The global.gets there are nested inside struct.news, which is a realistic pattern seen in J2CL output for example, which we did not emit before.

// We also do so if this is a tuple type and we are not in a function, because
// atm tuple globals have only limited support, and in particular we do not
// support a global.get from one such global to another (a tuple global must
// contain a tuple.make instruction).
Copy link
Member

Choose a reason for hiding this comment

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

I would expect us to support arbitrary constant expressions as the children of the tuple.make, though. For example, do things break if we allow a global.get child?

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, that should work, but it would require us to check if we are the toplevel or not, at this location. There isn't a nice way to do that atm. Do you think it's worth it?

Copy link
Member

Choose a reason for hiding this comment

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

I do think it's worth doing at some point, but not necessarily in this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

I realized it is just as simple to disallow only tuple.make at the toplevel, and pushed that now. With that we can get tuple globals whose values include global.gets.

@kripken kripken merged commit 326bfcd into WebAssembly:main May 21, 2024
13 checks passed
@kripken kripken deleted the fuzz.globas branch May 21, 2024 20:06
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.

None yet

2 participants