alexcrichton opened PR #7626 from alexcrichton:consolidate-platform-definitions
to bytecodealliance:main
:
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 conditionally
defines all of the platform support that Wasmtime requires, namely
things related to virtual memory management and trap handling. Many of
the previousunix.rs
files interspersed throughout the tree are now
all located in a singleunix
directory. This additionally helps split
outmiri
-specific functionality by pretendingmiri
is its own
platform.This change additionally goes through
#[cfg]
directives throughout
wasmtime-runtime
,wasmtime-jit
, andwasmtime
itself to place all
of this target-specific functionality within thissys
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 touchsys/mod.rs
to declare a new
platform andsys/$platform/*.rs
to define all the functionality.
alexcrichton requested wasmtime-compiler-reviewers for a review on PR #7626.
alexcrichton requested abrown for a review on PR #7626.
alexcrichton requested pchickey for a review on PR #7626.
alexcrichton requested wasmtime-core-reviewers for a review on PR #7626.
alexcrichton requested wasmtime-default-reviewers for a review on PR #7626.
alexcrichton updated PR #7626.
alexcrichton updated PR #7626.
alexcrichton updated PR #7626.
alexcrichton updated PR #7626.
alexcrichton updated PR #7626.
alexcrichton updated PR #7626.
abrown submitted PR review:
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?
abrown submitted PR review:
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?
abrown created PR review comment:
pub unsafe fn expose_existing_mapping(ptr: *mut u8, len: usize) -> io::Result<()> {
abrown created PR review comment:
source: MemoryImageSource,
Maybe? Since it seems you're doing clarity refactors in this PR...
abrown created PR review comment:
// For MIRI, set up just enough of a setjmp/longjmp with catching panics
abrown created PR review comment:
//! or Windows, for example. The goal of this module is to be the "single
abrown created PR review comment:
I guess a future refactor could move the MPK stuff here as well?
abrown created PR review comment:
Why not make this a compile-time check instead, then?
alexcrichton updated PR #7626.
alexcrichton updated PR #7626.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Could you elaborate? Do you mean asserting that this file isn't used on macos? (it's used on macos intentionally so wanted to clarify)
alexcrichton commented on PR #7626:
my take is that none of this refactoring should substantially change any logic, at least observably for users; is that right?
Correct!
alexcrichton submitted PR review.
alexcrichton created PR review comment:
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 intoarch
likepkru.rs
and others would go intounix/mpk.rs
perhaps where non-Linux systems would usedisabled.rs
and Linux would use the "real version"
abrown submitted PR review.
abrown created PR review comment:
Oh, sorry... I was just looking at the
cfg!
part but clearlymachos_use_mach_ports
is runtime-defined. Never mind!
abrown merged PR #7626.
Last updated: Nov 22 2024 at 16:03 UTC