Skip to content

Conversation

@sjrd
Copy link
Member

@sjrd sjrd commented Mar 25, 2025

This avoids the JS call overhead for that "primitive" operation.

As can be seen in the implementation, fmod is far from a primitive, though. We took an MIT implemention of fmod, generic in the bit-width, and translated it by hand to Wasm. We use the newly introduced GenericInstructions to also have a generic implementation. So we generate one function for Float_% and one for Double_%.


/cc @tanishiking This also removes the dependency on JS for that operation, which will be useful to compile to Wasm-without-JS-host.

sjrd added 2 commits March 25, 2025 11:12
They contain groups of instructions by Wasm type, so that it is
easier to generically write algorithms over multiple primitive
types.

We use them for the implementations of signed division and modulo
on integers.
This avoids the JS call overhead for that "primitive" operation.

As can be seen in the implementation, `fmod` is far from a
primitive, though. We took an MIT implemention of `fmod`, generic
in the bit-width, and translated it by hand to Wasm. We use the
newly introduced `GenericInstructions` to also have a generic
implementation. So we generate one function for `Float_%` and one
for `Double_%`.
@sjrd sjrd requested a review from gzm0 March 25, 2025 16:13
@sjrd
Copy link
Member Author

sjrd commented Mar 26, 2025

#5149 is probably a better alternative.

@sjrd sjrd marked this pull request as draft March 26, 2025 12:52
@sjrd
Copy link
Member Author

sjrd commented Apr 6, 2025

Superseded by #5149.

@sjrd sjrd closed this Apr 6, 2025
@sjrd sjrd deleted the wasm-fmod-in-wasm branch April 6, 2025 22:00
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.

1 participant