Support Embedded Swift in the core engine - #395
Merged
Conversation
The interpreter shares one untyped-throws execution pipeline on every platform: Embedded Swift 6.5 supports untyped throws and `any Error`, so no typed-throws variants or error-carrying trap cases are needed, and every instruction (including atomics and exception handling) stays available. Capability differences are expressed through traits where possible, and `#if $Embedded` remains only for true compile necessities: - The blocking half of AtomicParkingLot is gated on the MultiThread trait (single-threaded builds cannot create shared memories, so `atomic.wait`/`notify` trap before reaching the parking lot; an inert stub satisfies the type checker). Wait deadlines are computed via a new ParkingDeadline platform type instead of using ContinuousClock at the instruction site. CI trait lists now include the default-on MultiThread trait, which they had silently dropped. - The profiler is gated on the FileSystem trait (it writes its trace to a file), and the instruction-dumping code (`wasmkit explore`) is gated on a new default-on Disassembler trait. - Direct threading is disabled under Embedded; it requires the swifttailcc convention, which Embedded targets (like WASI) do not provide. - mmap-based virtual memory is excluded on targets without an OS. - `Instruction.emitImmediate(to:)` is now generated so the translator avoids calling default protocol methods on existentials, and key-path literals are replaced with closures on shared paths.
kateinoigakukun
force-pushed
the
katei/embedded-core
branch
from
July 29, 2026 16:59
dcb087a to
5a25cf5
Compare
kateinoigakukun
added this pull request to the merge queue
Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the incremental upstreaming of Embedded Swift support (#357). Follows #394.
This makes the core engine build and run with
-enable-experimental-feature Embedded. Embedded Swift 6.5 supports untyped throws andany Error, so the interpreter shares one untyped execution pipeline on every platform — no typed-throws variants, no error-carrying trap cases, and every instruction (including atomics and exception handling) stays available under Embedded.Capability differences are expressed through traits where possible;
#if $Embeddedremains only for true compile necessities:AtomicParkingLot's blocking half is gated on the MultiThread trait. Single-threaded builds can't create shared memories, soatomic.wait/notifytrap before reaching the parking lot; an inert stub satisfies the type checker. Wait deadlines go through a newParkingDeadlineplatform type instead ofContinuousClockat the instruction site. The CI trait lists now include the default-on MultiThread trait, which they had silently dropped.wasmkit explore) is gated on a new default-on Disassembler trait.Instruction.emitImmediate(to:)is generated so the translator avoids calling default protocol methods on existentials; a few key-path literals become closures.Verified on hardware: the ESP32-C6 build and a QEMU run of the demo (guest→host calls, and a host error thrown from a host function caught by identity in the embedder) pass. The example project and portable smoke test land in a follow-up PR.