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

Don't statically enumerate host signatures in Pulley #9693

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

alexcrichton
Copy link
Member

I'm doing some other refactoring which makes it a pain to maintain a list in two locations of what all the host signatures are. Instead remove the pulley for_each_host_signature! macro entirely. My thinking is to instead implement a different system for host calls in pulley:

  • The same relocation-style mechanism is used with some number-embedded-in-the-bytecode.
  • The interpreter exits with "imma call the host" when it sees this special opcode.
  • The interpreter embedder, aka Wasmtime, is responsible for then invoking the actual function pointer.
  • Wasmtime already has static knowledge of all its function signatures, e.g. via various macros.

This will prevent the need to list all function signatures twice and risk them getting out of sync. Most of the Pulley-level integration work here is left to a future commit.

I'm doing some other refactoring which makes it a pain to maintain a
list in two locations of what all the host signatures are. Instead
remove the pulley `for_each_host_signature!` macro entirely. My thinking
is to instead implement a different system for host calls in pulley:

* The same relocation-style mechanism is used with some
  number-embedded-in-the-bytecode.
* The interpreter exits with "imma call the host" when it sees this
  special opcode.
* The interpreter embedder, aka Wasmtime, is responsible for then
  invoking the actual function pointer.
* Wasmtime already has static knowledge of all its function signatures,
  e.g. via various macros.

This will prevent the need to list all function signatures twice and
risk them getting out of sync. Most of the Pulley-level integration work
here is left to a future commit.
@alexcrichton alexcrichton marked this pull request as ready for review November 29, 2024 02:00
@alexcrichton alexcrichton requested review from a team as code owners November 29, 2024 02:00
@alexcrichton alexcrichton requested review from pchickey and removed request for a team November 29, 2024 02:00
@github-actions github-actions bot added the pulley Issues related to the Pulley interpreter label Nov 29, 2024
Copy link

Subscribe to Label Action

cc @fitzgen

This issue or pull request has been labeled: "pulley"

Thus the following users have been cc'd because of the following labels:

  • fitzgen: pulley

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

@alexcrichton alexcrichton added this pull request to the merge queue Dec 2, 2024
Merged via the queue into bytecodealliance:main with commit 2134598 Dec 2, 2024
39 checks passed
@alexcrichton alexcrichton deleted the no-enumerate branch December 2, 2024 20:48
alexcrichton added a commit to alexcrichton/wasmtime that referenced this pull request Dec 4, 2024
This commit is a continuation of the plan of implementing host calls in
Pulley through bytecodealliance#9665, bytecodealliance#9675, and bytecodealliance#9693. Here the `Compiler::call_indirect_host`
method is updated to take a new type, `HostCall`, which indicates what
type of host call is being performed. This is then serialized to a
32-bit integer which will be present in the pulley instruction being
generated. This 32-bit integer will then be used to perform a dispatch
(the dispatch is left for a future PR with more Pulley integration).

This new `HostCall` structure is defined with `BuiltinFunctionIndex`
internally. Additionally a new `ComponentBuiltinFunctionIndex` is added
to enumerate the same set of indexes for components as well. Along the
way the split between component transcoders/builtins were removed and
they're now all lumped together in one macro for builtins. (no need to
have two separate macros).

This new `HostCall` is used to implement the `call_indirect_host`
instruction for Pulley to fill out an unimplemented piece of code.
alexcrichton added a commit to alexcrichton/wasmtime that referenced this pull request Dec 4, 2024
This commit is a continuation of the plan of implementing host calls in
Pulley through bytecodealliance#9665, bytecodealliance#9675, and bytecodealliance#9693. Here the `Compiler::call_indirect_host`
method is updated to take a new type, `HostCall`, which indicates what
type of host call is being performed. This is then serialized to a
32-bit integer which will be present in the pulley instruction being
generated. This 32-bit integer will then be used to perform a dispatch
(the dispatch is left for a future PR with more Pulley integration).

This new `HostCall` structure is defined with `BuiltinFunctionIndex`
internally. Additionally a new `ComponentBuiltinFunctionIndex` is added
to enumerate the same set of indexes for components as well. Along the
way the split between component transcoders/builtins were removed and
they're now all lumped together in one macro for builtins. (no need to
have two separate macros).

This new `HostCall` is used to implement the `call_indirect_host`
instruction for Pulley to fill out an unimplemented piece of code.
alexcrichton added a commit to alexcrichton/wasmtime that referenced this pull request Dec 4, 2024
This commit is a continuation of the plan of implementing host calls in
Pulley through bytecodealliance#9665, bytecodealliance#9675, and bytecodealliance#9693. Here the `Compiler::call_indirect_host`
method is updated to take a new type, `HostCall`, which indicates what
type of host call is being performed. This is then serialized to a
32-bit integer which will be present in the pulley instruction being
generated. This 32-bit integer will then be used to perform a dispatch
(the dispatch is left for a future PR with more Pulley integration).

This new `HostCall` structure is defined with `BuiltinFunctionIndex`
internally. Additionally a new `ComponentBuiltinFunctionIndex` is added
to enumerate the same set of indexes for components as well. Along the
way the split between component transcoders/builtins were removed and
they're now all lumped together in one macro for builtins. (no need to
have two separate macros).

This new `HostCall` is used to implement the `call_indirect_host`
instruction for Pulley to fill out an unimplemented piece of code.
alexcrichton added a commit to alexcrichton/wasmtime that referenced this pull request Dec 5, 2024
This commit is a continuation of the plan of implementing host calls in
Pulley through bytecodealliance#9665, bytecodealliance#9675, and bytecodealliance#9693. Here the `Compiler::call_indirect_host`
method is updated to take a new type, `HostCall`, which indicates what
type of host call is being performed. This is then serialized to a
32-bit integer which will be present in the pulley instruction being
generated. This 32-bit integer will then be used to perform a dispatch
(the dispatch is left for a future PR with more Pulley integration).

This new `HostCall` structure is defined with `BuiltinFunctionIndex`
internally. Additionally a new `ComponentBuiltinFunctionIndex` is added
to enumerate the same set of indexes for components as well. Along the
way the split between component transcoders/builtins were removed and
they're now all lumped together in one macro for builtins. (no need to
have two separate macros).

This new `HostCall` is used to implement the `call_indirect_host`
instruction for Pulley to fill out an unimplemented piece of code.
alexcrichton added a commit to alexcrichton/wasmtime that referenced this pull request Dec 5, 2024
This commit is a continuation of the plan of implementing host calls in
Pulley through bytecodealliance#9665, bytecodealliance#9675, and bytecodealliance#9693. Here the `Compiler::call_indirect_host`
method is updated to take a new type, `HostCall`, which indicates what
type of host call is being performed. This is then serialized to a
32-bit integer which will be present in the pulley instruction being
generated. This 32-bit integer will then be used to perform a dispatch
(the dispatch is left for a future PR with more Pulley integration).

This new `HostCall` structure is defined with `BuiltinFunctionIndex`
internally. Additionally a new `ComponentBuiltinFunctionIndex` is added
to enumerate the same set of indexes for components as well. Along the
way the split between component transcoders/builtins were removed and
they're now all lumped together in one macro for builtins. (no need to
have two separate macros).

This new `HostCall` is used to implement the `call_indirect_host`
instruction for Pulley to fill out an unimplemented piece of code.
alexcrichton added a commit to alexcrichton/wasmtime that referenced this pull request Dec 5, 2024
This commit is a continuation of the plan of implementing host calls in
Pulley through bytecodealliance#9665, bytecodealliance#9675, and bytecodealliance#9693. Here the `Compiler::call_indirect_host`
method is updated to take a new type, `HostCall`, which indicates what
type of host call is being performed. This is then serialized to a
32-bit integer which will be present in the pulley instruction being
generated. This 32-bit integer will then be used to perform a dispatch
(the dispatch is left for a future PR with more Pulley integration).

This new `HostCall` structure is defined with `BuiltinFunctionIndex`
internally. Additionally a new `ComponentBuiltinFunctionIndex` is added
to enumerate the same set of indexes for components as well. Along the
way the split between component transcoders/builtins were removed and
they're now all lumped together in one macro for builtins. (no need to
have two separate macros).

This new `HostCall` is used to implement the `call_indirect_host`
instruction for Pulley to fill out an unimplemented piece of code.
alexcrichton added a commit to alexcrichton/wasmtime that referenced this pull request Dec 5, 2024
This commit is a continuation of the plan of implementing host calls in
Pulley through bytecodealliance#9665, bytecodealliance#9675, and bytecodealliance#9693. Here the `Compiler::call_indirect_host`
method is updated to take a new type, `HostCall`, which indicates what
type of host call is being performed. This is then serialized to a
32-bit integer which will be present in the pulley instruction being
generated. This 32-bit integer will then be used to perform a dispatch
(the dispatch is left for a future PR with more Pulley integration).

This new `HostCall` structure is defined with `BuiltinFunctionIndex`
internally. Additionally a new `ComponentBuiltinFunctionIndex` is added
to enumerate the same set of indexes for components as well. Along the
way the split between component transcoders/builtins were removed and
they're now all lumped together in one macro for builtins. (no need to
have two separate macros).

This new `HostCall` is used to implement the `call_indirect_host`
instruction for Pulley to fill out an unimplemented piece of code.
alexcrichton added a commit to alexcrichton/wasmtime that referenced this pull request Dec 5, 2024
This commit is a continuation of the plan of implementing host calls in
Pulley through bytecodealliance#9665, bytecodealliance#9675, and bytecodealliance#9693. Here the `Compiler::call_indirect_host`
method is updated to take a new type, `HostCall`, which indicates what
type of host call is being performed. This is then serialized to a
32-bit integer which will be present in the pulley instruction being
generated. This 32-bit integer will then be used to perform a dispatch
(the dispatch is left for a future PR with more Pulley integration).

This new `HostCall` structure is defined with `BuiltinFunctionIndex`
internally. Additionally a new `ComponentBuiltinFunctionIndex` is added
to enumerate the same set of indexes for components as well. Along the
way the split between component transcoders/builtins were removed and
they're now all lumped together in one macro for builtins. (no need to
have two separate macros).

This new `HostCall` is used to implement the `call_indirect_host`
instruction for Pulley to fill out an unimplemented piece of code.
github-merge-queue bot pushed a commit that referenced this pull request Dec 5, 2024
* Enumerate all host calls in `wasmtime_environ::HostCall`

This commit is a continuation of the plan of implementing host calls in
Pulley through #9665, #9675, and #9693. Here the `Compiler::call_indirect_host`
method is updated to take a new type, `HostCall`, which indicates what
type of host call is being performed. This is then serialized to a
32-bit integer which will be present in the pulley instruction being
generated. This 32-bit integer will then be used to perform a dispatch
(the dispatch is left for a future PR with more Pulley integration).

This new `HostCall` structure is defined with `BuiltinFunctionIndex`
internally. Additionally a new `ComponentBuiltinFunctionIndex` is added
to enumerate the same set of indexes for components as well. Along the
way the split between component transcoders/builtins were removed and
they're now all lumped together in one macro for builtins. (no need to
have two separate macros).

This new `HostCall` is used to implement the `call_indirect_host`
instruction for Pulley to fill out an unimplemented piece of code.

* Rename `max` to `len`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pulley Issues related to the Pulley interpreter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants