Stream: git-wasmtime

Topic: wasmtime / PR #2632 Switch macOS to using mach ports for ...


view this post on Zulip Wasmtime GitHub notifications bot (Feb 03 2021 at 20:54):

alexcrichton opened PR #2632 from mach-ports to main:

This commit moves macOS to using mach ports instead of signals for
handling traps. The motivation for this is listed in #2456, namely that
once mach ports are used in a process that means traditional UNIX signal
handlers won't get used. This means that if Wasmtime is integrated with
Breakpad, for example, then Wasmtime's trap handler never fires and
traps don't work.

The traphandlers module is refactored as part of this commit to split
the platform-specific bits into their own files (it was growing quite a
lot for one inline cfg_if!). The unix.rs and windows.rs files
remain the same as they were before with a few minor tweaks for some
refactored interfaces. The macos.rs file is brand new and lifts almost
its entire implementation from SpiderMonkey, adapted for Wasmtime
though.

The main gotcha with mach ports is that a separate thread is what
services the exception. Some unsafe magic allows this separate thread to
read non-Send and temporary state from other threads, but is hoped to
be safe in this context. The unfortunate downside is that calling wasm
on macOS now involves taking a global lock and modifying a global hash
map twice-per-call. I'm not entirely sure how to get out of this cost
for now, but hopefully for any embeddings on macOS it's not the end of
the world.

Closes #2456

view this post on Zulip Wasmtime GitHub notifications bot (Feb 03 2021 at 20:55):

alexcrichton updated PR #2632 from mach-ports to main:

This commit moves macOS to using mach ports instead of signals for
handling traps. The motivation for this is listed in #2456, namely that
once mach ports are used in a process that means traditional UNIX signal
handlers won't get used. This means that if Wasmtime is integrated with
Breakpad, for example, then Wasmtime's trap handler never fires and
traps don't work.

The traphandlers module is refactored as part of this commit to split
the platform-specific bits into their own files (it was growing quite a
lot for one inline cfg_if!). The unix.rs and windows.rs files
remain the same as they were before with a few minor tweaks for some
refactored interfaces. The macos.rs file is brand new and lifts almost
its entire implementation from SpiderMonkey, adapted for Wasmtime
though.

The main gotcha with mach ports is that a separate thread is what
services the exception. Some unsafe magic allows this separate thread to
read non-Send and temporary state from other threads, but is hoped to
be safe in this context. The unfortunate downside is that calling wasm
on macOS now involves taking a global lock and modifying a global hash
map twice-per-call. I'm not entirely sure how to get out of this cost
for now, but hopefully for any embeddings on macOS it's not the end of
the world.

Closes #2456

view this post on Zulip Wasmtime GitHub notifications bot (Feb 03 2021 at 20:56):

alexcrichton updated PR #2632 from mach-ports to main:

This commit moves macOS to using mach ports instead of signals for
handling traps. The motivation for this is listed in #2456, namely that
once mach ports are used in a process that means traditional UNIX signal
handlers won't get used. This means that if Wasmtime is integrated with
Breakpad, for example, then Wasmtime's trap handler never fires and
traps don't work.

The traphandlers module is refactored as part of this commit to split
the platform-specific bits into their own files (it was growing quite a
lot for one inline cfg_if!). The unix.rs and windows.rs files
remain the same as they were before with a few minor tweaks for some
refactored interfaces. The macos.rs file is brand new and lifts almost
its entire implementation from SpiderMonkey, adapted for Wasmtime
though.

The main gotcha with mach ports is that a separate thread is what
services the exception. Some unsafe magic allows this separate thread to
read non-Send and temporary state from other threads, but is hoped to
be safe in this context. The unfortunate downside is that calling wasm
on macOS now involves taking a global lock and modifying a global hash
map twice-per-call. I'm not entirely sure how to get out of this cost
for now, but hopefully for any embeddings on macOS it's not the end of
the world.

Closes #2456

view this post on Zulip Wasmtime GitHub notifications bot (Feb 03 2021 at 22:17):

alexcrichton updated PR #2632 from mach-ports to main:

This commit moves macOS to using mach ports instead of signals for
handling traps. The motivation for this is listed in #2456, namely that
once mach ports are used in a process that means traditional UNIX signal
handlers won't get used. This means that if Wasmtime is integrated with
Breakpad, for example, then Wasmtime's trap handler never fires and
traps don't work.

The traphandlers module is refactored as part of this commit to split
the platform-specific bits into their own files (it was growing quite a
lot for one inline cfg_if!). The unix.rs and windows.rs files
remain the same as they were before with a few minor tweaks for some
refactored interfaces. The macos.rs file is brand new and lifts almost
its entire implementation from SpiderMonkey, adapted for Wasmtime
though.

The main gotcha with mach ports is that a separate thread is what
services the exception. Some unsafe magic allows this separate thread to
read non-Send and temporary state from other threads, but is hoped to
be safe in this context. The unfortunate downside is that calling wasm
on macOS now involves taking a global lock and modifying a global hash
map twice-per-call. I'm not entirely sure how to get out of this cost
for now, but hopefully for any embeddings on macOS it's not the end of
the world.

Closes #2456

view this post on Zulip Wasmtime GitHub notifications bot (Feb 03 2021 at 22:55):

alexcrichton updated PR #2632 from mach-ports to main:

This commit moves macOS to using mach ports instead of signals for
handling traps. The motivation for this is listed in #2456, namely that
once mach ports are used in a process that means traditional UNIX signal
handlers won't get used. This means that if Wasmtime is integrated with
Breakpad, for example, then Wasmtime's trap handler never fires and
traps don't work.

The traphandlers module is refactored as part of this commit to split
the platform-specific bits into their own files (it was growing quite a
lot for one inline cfg_if!). The unix.rs and windows.rs files
remain the same as they were before with a few minor tweaks for some
refactored interfaces. The macos.rs file is brand new and lifts almost
its entire implementation from SpiderMonkey, adapted for Wasmtime
though.

The main gotcha with mach ports is that a separate thread is what
services the exception. Some unsafe magic allows this separate thread to
read non-Send and temporary state from other threads, but is hoped to
be safe in this context. The unfortunate downside is that calling wasm
on macOS now involves taking a global lock and modifying a global hash
map twice-per-call. I'm not entirely sure how to get out of this cost
for now, but hopefully for any embeddings on macOS it's not the end of
the world.

Closes #2456

view this post on Zulip Wasmtime GitHub notifications bot (Mar 17 2021 at 09:35):

bnjbvr closed without merge PR #2632.


Last updated: Dec 23 2024 at 12:05 UTC