-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Consolidate platform-specific definitions in Wasmtime #7626
Consolidate platform-specific definitions in Wasmtime #7626
Conversation
This commit extends the gating behavior of the preexisting `debug-builtins` Cargo feature to cover more GDB-related functionality associated with debugging. This can additionally slim down the set of exposed symbols from Wasmtime over the default with them included.
This commit adds a `timing` feature to the `cranelift-codegen` crate which is enabled by default. This feature gates the timing functionality in Cranelift to enable turning it off if desired. The goal of this commit is to remove a system dependency on `Instant` for possibly esoteric environments.
Prior to this commit Wasmtime did not not have a style or system for containing platform-specific logic in files. The goal of this commit is to consolidate all platform-specific functionality into one location to make it easier to port Wasmtime to new systems. This commit creates a `sys` module within the `wasmtime-runtime` crate which conditionally defines all of the platform support that Wasmtime requires, namely things related to virtual memory management and trap handling. Many of the previous `unix.rs` files interspersed throughout the tree are now all located in a single `unix` directory. This additionally helps split out `miri`-specific functionality by pretending `miri` is its own platform. This change additionally goes through `#[cfg]` directives throughout `wasmtime-runtime`, `wasmtime-jit`, and `wasmtime` itself to place all of this target-specific functionality within this `sys` directory. The end state is that there are two new top-level modules in the `wasmtime-runtime` crate: * `arch` - this conditionally defines architecture-specific logic such as the state used by backtraces, libcalls, etc. * `sys` - this conditionally defines OS or platform-specific logic such as virtual memory management. One secondary goal of this commit is to enable the ability to easily add new platforms to Wasmtime, even if it's in a fork of Wasmtime. Previously patches might have to touch a good number of locations where now they'd ideally only have to touch `sys/mod.rs` to declare a new platform and `sys/$platform/*.rs` to define all the functionality.
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.
I think this is good to go. The idea of centralizing all the platform-specific bits into one place is a good one. @alexcrichton, my take is that none of this refactoring should substantially change any logic, at least observably for users; is that right?
@@ -47,6 +88,7 @@ macro_rules! wasm_to_libcall_trampoline { | |||
); | |||
}; | |||
} | |||
pub(crate) use wasm_to_libcall_trampoline; | |||
|
|||
#[cfg(test)] | |||
mod wasm_to_libcall_trampoline_offsets_tests { |
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.
I guess a future refactor could move the MPK stuff here as well?
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.
True! I forgot to go back and handle that one as well.
The disabled.rs
file would be used on Windows/MIRI/non-x86_64. Some bits would probably go into arch
like pkru.rs
and others would go into unix/mpk.rs
perhaps where non-Linux systems would use disabled.rs
and Linux would use the "real version"
Correct! |
Prior to this commit Wasmtime did not not have a style or system for
containing platform-specific logic in files. The goal of this commit is
to consolidate all platform-specific functionality into one location to
make it easier to port Wasmtime to new systems. This commit creates a
sys
module within thewasmtime-runtime
crate which conditionallydefines all of the platform support that Wasmtime requires, namely
things related to virtual memory management and trap handling. Many of
the previous
unix.rs
files interspersed throughout the tree are nowall located in a single
unix
directory. This additionally helps splitout
miri
-specific functionality by pretendingmiri
is its ownplatform.
This change additionally goes through
#[cfg]
directives throughoutwasmtime-runtime
,wasmtime-jit
, andwasmtime
itself to place allof this target-specific functionality within this
sys
directory. Theend state is that there are two new top-level modules in the
wasmtime-runtime
crate:arch
- this conditionally defines architecture-specific logic suchas the state used by backtraces, libcalls, etc.
sys
- this conditionally defines OS or platform-specific logic suchas virtual memory management.
One secondary goal of this commit is to enable the ability to easily
add new platforms to Wasmtime, even if it's in a fork of Wasmtime.
Previously patches might have to touch a good number of locations where
now they'd ideally only have to touch
sys/mod.rs
to declare a newplatform and
sys/$platform/*.rs
to define all the functionality.