1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! The runtime hook a standalone AOT binary needs.
//!
//! fusevm's AOT model puts the bincode-serialized `Chunk` in the object and, at
//! load, deserializes it and runs it on a `VM` (`fusevm_aot_run_embedded`).
//! Before running, it calls back into the frontend through the C symbol
//! `fusevm_aot_register_builtins` to install the frontend's builtins on that VM.
//! A standalone texrs binary is that object plus this runtime (the hook and the
//! `\message` builtins) plus a `main` that calls the entry below.
//!
//! texrs needs only the two message builtins, and the whole document is in the
//! chunk — there is no host-side table to rebuild, unlike the sibling frontends
//! whose closures live outside their bytecode. That is what makes this file
//! twenty lines rather than two hundred: everything a TeX document does at run
//! time is register writes, branches and `\message`, and all three are ops.
use VM;
thread_local!
/// Install texrs's builtins on the AOT run's VM.
///
/// # Safety
///
/// Called by fusevm's AOT entry with the VM it is about to run.
pub unsafe extern "C"
/// The `main` a linked texrs AOT binary calls.
///
/// Runs the embedded chunk, then prints the `\message` stream the way an
/// ordinary run prints it — the compiled document has to be observationally the
/// same program, or "compiled ahead of time" would mean "behaves differently".
pub extern "C"