Expand description
Running compiled warp programs without the compiler: warp links this crate for its own runs, and its binary warp-runtime (main.rs)
is the standalone executable warp build appends a program’s machine code to (notes/aot.md)
Modules§
- engine
- floats
- Floats as a run shows them (P119)
- foreign
- The bridge of foreign_call(runtime, module, member, arguments) (warp’s lowering/foreign/foreign_modules.rs,
notes/stdlib_connectors.md), shared by warp and its executables (card exe-foreign): one long-lived child per runtime
and process, started on first use, speaking one JSON line per request and per answer. Python:
python3 -urunning FOREIGN_PYTHON_LOOP (WARP_PYTHONnames another interpreter); JavaScript:noderunning FOREIGN_JS_LOOP (WARP_NODE), a global (Math) or a module it requires. A read gives the member itself, a call gives its result (a promise awaited); an exception is an error with the runtime’s message. A value without a JSON form stays in its runtime behind an id, a handle: it crosses as the record{$handle: 7, type: "date", text: "datetime.date(2020, 1, 2)"}and is that object again when it comes back, as an argument or as the receiver ofd.isoformat()(the module position). Handles live until the process ends. A warp function given as an argument crosses as{$warp_function: 0}, its index among the call’s functions; node calls it back with the line{callback: 0, arguments: […]}and waits for its{value}or{error}(card js-callbacks). - fuel
- gc_
values - Warp’s GC Nodes (CLAUDE.md “Serialization”, warp’s type_kinds.rs) as JSON and back, for an executable’s foreign calls (card exe-foreign): what warp does with json_of(node_in(…)) and Builders::build(TaskValue::of(node_of(…))), without warp’s Node. warp’s tests/wasm/test_executable_foreign.rs holds these codes equal to warp’s.
- host_
words - The words of the program’s environment, imported from the “host” module and called like C functions:
sleep(ms)pauses,random()is a float in [0, 1),random_below(n)an int in 0..n,clock()the milliseconds since the Unix epoch. A program that defines a word of the same name keeps its own. warp adds the words that need its compiler, the network or threads (host.rs); these need nothing.signal_poll()andsignal_listen(kind, id, argument)serve the handlers of system signals (system_signals.rs). - libm
- The libm functions programs import from “m” (
cos(x),pow(x, y)…), for a store of any state: Rust’s own f64 functions, so a standalone executable loads no C library (warp itself links the system’s libm, ffi.rs) - macho
- Just enough of 64-bit Mach-O (macOS executables) to carry a program so the executable still signs cleanly: codesign wants every byte of the file inside a segment, its signature last. The carried program goes at the end of the last segment (__LINKEDIT), whose size grows to cover it; the old signature is dropped first. Anything that is not a 64-bit little-endian Mach-O (Linux’s ELF) passes unchanged.
- output
- The one WASI call warp programs make,
fd_write(print), for a store of any state: the warp-runtime stub needs no WASI library - site_
files - The files of a site (
warp build --site, src/web/site.rs in warp) and how a request path finds one, shared by warp’s servers and web view and by an appwarp buildmade: the stub carrying a site packed (card build-links) - standalone
- A standalone executable is the warp-runtime stub carrying a program’s machine code:
<executable><machine code, deflated><its length, u64 little-endian><TRAILER_MAGIC><zeros to a multiple of 16>, then, in a Mach-O executable, its code signature: the machine code lies inside the __LINKEDIT segment, so the executable signs and verifies cleanly (codesign --verify --strict, macho.rs). At start the executable looks for the trailer where its program would end and runs what it carries. - system_
signals - System signals (notes/system_signals.md): handlers of events from outside the program, exported functions the
runtime calls at check points:
signal_poll()(at the start and end of main and at each loop start of a program with such handlers) andsleep, which wakes for them.on interrupt {…}ison·interrupt, run after a ctrl-c: the first poll installs the ctrl-c handler (Unix SIGINT, Windows SetConsoleCtrlHandler), which only sets a flag; a second ctrl-c within a second, or before the handler ran, ends the run at once (exit code 130), so a handler that ignores ctrl-c never makes a program unstoppable.on every 5 seconds {…}ison·every·0, started bysignal_listen(0, 0, 5000)where the handler is declared.on file "notes.txt" change {…}ison·file·0, started bysignal_watch(0, "notes.txt"): a timer of FILE_CHECK_PERIOD that fires only when the file’s modification time or size changed (it appeared, was written, or went).users := fetch urlruns on·fetch·0 once the reply arrived (await_ready, src/web/fetches.rs). A run that allows it (warp run, built executables) stays after main while a timer or watch lives. - system_
values - System values (notes/system_signals.md, P136):
battery(percent),charging,onlineanddark moderead the machine’s state through the host wordsystem_value(name), an i64 (booleans 0 or 1). Listeners on them (whenever battery < 20% {…}) compare readings at the program’s check points, so a reading is kept for READING_LIFETIME: a sleeping program polls often, the platform is asked at most once a second per value. macOS askspmsetanddefaults, Linux /sys andgsettings;onlineis whether a route to the internet exists (a UDP connect sends nothing). A value the platform cannot give is a loud error, never a made-up reading.mouse_x,mouse_y,mouse_down: natively the pointer over the paint window (window_input), read each time;key_downwhether a key is held over it,key code heldwhich (lowering/signals/system_values.rs names itheld_key);window_openwhether that window shows; read before any paint, it opens the window (blank) where one can show.window_width,window_height(window.width, card make-width): the paint window’s inner size in points as it reports it, else as last written, else the view’s; writing one resizes the window through the warp binary’s resizer.display_width,display_height: the main screen’s size in points, read only;display_dpiits device pixels per inch (CoreGraphics’ physical size, xrandr’s millimetres), read only. The clipboard is watched by its change count, which reads no content: macOS asks the user before a program reads what another one copied, so the text is read only when the program asks for it (clipboard, clipboard_text).