veko-lang.org
Download Free EPUB 3.0

Part III · Performance, Cross-Compilation, Security Governance & Diagnostics

Chapter 12

Strict No-JIT Performance, Tree-Shaking, SIMD & AArch64 Cross-Compilation

Zero-W^X execution, whole-program dead-code elimination, AVX2/SSE2/AES-NI intrinsics, and Windows/Linux/Apple Silicon targets

Veko delivers predictable, low-latency native execution strictly without a JIT compiler and with zero W^X (write-then-execute) memory pages. Every native binary is compiled ahead-of-time (AOT) directly from Veko's 64-bit VKO intermediate representation into standalone machine code across 5 zero-dependency OS/CPU targets — Windows x86_64 (win-x64), Windows 11 ARM64 (win-arm64), Linux x86_64 (linux-x64), Linux AArch64 (linux-arm64), and macOS Apple Silicon (macos-arm64) — with zero external C compiler, LLVM, libc, or crypto library dependencies.


1. Strict No-JIT & Zero-W^X Execution Model

CODEGEN & BINARY LINKERS

64-Bit VKO ISA, Hardware SIMD & Four-Target Native Binary Emitters

Zero-JIT, zero-W^X compilation from typed ASTs to superinstruction bytecode, x86_64, and AArch64 executables.

IR & BYTECODE TRACK vko_emit.vk + oro_vm.vk X86_64 NATIVE BACKEND x64_enc.vk + native_emit.vk AARCH64 NATIVE BACKEND arm64_enc.vk + arm64_emit.vk VKO1 words x86_64 code ARM64 code Shared AST PAL parity Bytecode IR64-Bit VKO Emitterop:u8 | flags:u8 | a:u16 | bx:u32 VM EngineVM SuperinstructionsZero-JIT Dispatch Fusion x86_64 Codegenx86_64 Machine EmitterCPUID AVX2 / SSE2 / AES-NI x86_64 LinkersWin64 PE32+ & Linux ELF64pe_emit.vk + elf_emit.vk ARM64 CodegenAArch64 Machine EmitterARMv8-A + NEON-ready PAL ARM64 LinkersLinux ELF64 & macOS Mach-Oelf_emit.vk + macho_emit.vk
Component & ModuleArchitectural Role
64-Bit VKO Emitter
vko_emit.vk
Compiles ASTs into fixed-width 64-bit instructions serialized as portable 'VKO1' binaries.
VM Superinstructions
oro_vm.vk
Fuses hot local-load, arithmetic, comparison, and branch sequences in pure AOT code.
x86_64 Machine Emitter
x64_enc.vk + native_emit.vk
Lowers typed ASTs directly to x86_64 machine code with 79-group dead-code elimination.
Win64 PE32+ & Linux ELF64
pe_emit.vk + elf_emit.vk
Writes standalone Windows .exe and static zero-libc Linux x86_64 executables.
AArch64 Machine Emitter
arm64_enc.vk + arm64_emit.vk
Encodes fixed 32-bit ARM64 instructions with dedicated callee-saved runtime registers.
Linux ELF64 & macOS Mach-O
elf_emit.vk + macho_emit.vk
Emits static Linux EM_AARCH64 ELF64 and ad-hoc SHA-256 signed 16 KiB Apple Silicon Mach-O.

Across all three execution tracks, Veko enforces strict separation between writable memory and executable code:

  • Track A (--vm / .vko): The pure-Veko 64-bit bytecode VM (oro_vm.vk) uses fused superinstructions (LOAD_CONST_ADD, LOAD_CONST_LT_JMP_FALSE, LOCAL_INC, LOAD_LOCAL_INDEX, LOAD_LOCAL_LEN), shared devirtualization, guarded leaf inlining, optional --fuel=<n> instruction quotas, and .secret-preserving native fast-paths for modular big-integer/Curve25519/Keccak-f[1600]/SHA-2 kernels so even interpreted veko run completes full post-quantum TLS 1.3 HTTPS handshakes in milliseconds without allocating executable heap pages.
  • Track B (--wasm / vvm): Compiles to validated WebAssembly 3.0 with hardware f64.sqrt, bulk memory ops, unboxed i64/f64 loops, and capability-confined HostSandbox isolation.
  • Track C (--native): Emits standalone OS executables directly for five OS/CPU architectures and platforms:
    • --target=win-x64 — Windows x86_64 64-bit PE32+ executable (kernel32.dll / ws2_32.dll only, optional --gui)
    • --target=win-arm64 — Windows 11 ARM64 64-bit PE32+ (0xAA64) executable (kernel32.dll / ws2_32.dll only, optional --gui — Snapdragon X Elite/Plus, Surface Pro/Laptop, Windows on ARM VMs)
    • --target=linux-x64 — Static zero-libc Linux x86_64 ELF64 executable (direct Linux syscalls)
    • --target=linux-arm64 — Static zero-libc Linux AArch64 (arm64) ELF64 executable (direct asm-generic Linux syscalls — AWS Graviton, Ampere, Raspberry Pi 5)
    • --target=macos-arm64 — 16 KiB-aligned Apple Silicon M1–M4 Mach-O MH_EXECUTE binary with dyld chained fixups, /usr/lib/libSystem.B.dylib stubs, and automatic pure-Veko SHA-256 ad-hoc LC_CODE_SIGNATURE

On x86_64 native targets, startup performs a single read-only CPUID + XGETBV probe (SSE2, AVX2, AES-NI) and dispatches hot byte and cryptographic loops automatically to the widest supported instruction set—falling back cleanly to constant-time scalar code on older CPUs.


2. Hardware & Bulk Byte Intrinsics (3-Track Parity)

Six built-in primitives accelerate numeric, buffer-scanning, and cryptographic workloads across all three backends with bit-identical semantics:

BuiltinArityDescriptionNative Hardware Acceleration
f64/sqrt1IEEE-754 double-precision square rootSQRTSD (x86_64), FSQRT (AArch64), f64.sqrt (Wasm 3.0)
bytes/eq2Exact byte-buffer equality checkAVX2 32B / SSE2 16B lanes (x86_64), 8B word loop (AArch64)
bytes/index-of2First byte offset of needle in haystack, or -1AVX2 / SSE2 PMOVMSKB scan (x86_64), fast prefix scan (AArch64)
bytes/xor2Returns a new bytes buffer XORing two equal-length buffersAVX2 32B / SSE2 16B VPXOR/PXOR (x86_64), 8B EOR loop (AArch64)
bytes/xor!2In-place ORO mut XOR (bytes/xor! mut dst mask) with zero allocationAVX2 32B / SSE2 16B in-place vector XOR (x86_64), 8B EOR loop (AArch64)
bytes/aes-enc-block2Single-block AES-128/192/256 encryption (blk16, rk)Hardware AESENC/AESENCLAST (x86_64 AES-NI), constant-time branchless algebraic GF(2^8) fallback (AArch64 / non-AES-NI / Wasm / VM)

Example: Using Hardware & Bulk Intrinsics

VEKO
use [m = math, bits, hex = codec/hex, aes = crypto/aes]

// Hardware IEEE-754 square root (`math/sqrt` delegates to `f64/sqrt`)
root2 = f64/sqrt 2.0

// Bulk SIMD equality, search, and zero-allocation in-place XOR
hay = bytes/from-str 'veko-simd-acceleration-pipeline-sentinel-99'
idx = bytes/index-of hay (bytes/from-str 'sentinel-99')

mut payload = bytes/from-str '0123456789abcdef'
mask = bytes/fill 16 0x5a
_ = bytes/xor! mut payload mask
_ = bytes/xor! mut payload mask
ok = bytes/eq payload (bytes/from-str '0123456789abcdef')

// NIST FIPS-197 AES-256 block & AES-256-GCM AEAD (automatically uses AES-NI when present)
key = hex/decode '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'
pt = hex/decode '00112233445566778899aabbccddeeff'
ct = aes/encrypt-block key pt   // '8ea2b7ca516745bfeafc49904b496089'

// Table-driven IEEE 802.3 CRC32 (256-entry Sarwate table in `lib/bits.vk`)
sum = bits/crc32 (bytes/from-str '123456789')   // 0xcbf43926

Run the complete self-verifying demonstration (examples/28_simd_optimization_and_arm64_cross_compile.vk) across all tracks:

POWERSHELL
veko run examples/28_simd_optimization_and_arm64_cross_compile.vk
veko run --wasm --fuel=0 --check-slabs examples/28_simd_optimization_and_arm64_cross_compile.vk
veko run --native examples/28_simd_optimization_and_arm64_cross_compile.vk

3. Content-Addressed Incremental Cache & veko run --native

Veko accelerates both interactive type-checking and AOT native builds via a deterministic content-addressed cache under dist/.veko_cache/ (bypassable anytime with --no-cache):

  1. Frontend & Binary Cache (dist/.veko_cache/mod_v1/): Keyed by a SHA-256 digest over the compiler binary fingerprint, embedded 'VFS2' stdlib fingerprint (stdlib_vfs.bin, lazy per-module zlib decompression), target triple, --strict-types / --gui flags, and FNV-1a + mtime content hashes of all transitive modules.
  2. Warm Sub-50ms Turnaround: On a 42-module production server (veko-site, including TLS 1.3, HTTP/2, QUIC HTTP/3, and Zero-FFI SQLite), cold veko check completes in ~2.7s and warm veko check in ~43 ms; cold veko compile --native completes in ~9.7s and warm veko compile --native in ~48 ms. Pass --no-cache (used automatically by build.vk -- fixed-point) to force a full uncached rebuild and verify S1 == S2 bit-identical determinism.
  3. Native Codegen Fast-Paths (native_emit.vk & x64_enc.vk): Unboxed vstack loop conditions fuse while i < (len xs) into 3 machine instructions with zero [R13] stack spills or rt_release calls, inline bounds-checked bytes[i] loads, and patch x64 jump/call relocations in $O(L + F)$ in-place passes.

For scripts and benchmarks that want full native throughput without managing output paths manually, use veko run --native:

POWERSHELL
veko run --native benchmarks/bench_suite.vk
veko compile --native --no-cache src/main.vk -o dist/app.exe

4. Cross-Compiling to AArch64 (win-arm64, linux-arm64 & macos-arm64)

Every veko binary includes both the x86_64 and AArch64 native code generators and linkers built in. You can cross-compile from any host OS to any of the 5 supported targets in a single command—no cross-compilers, Docker toolchains, Visual Studio Build Tools, or Xcode SDKs are required.

Target Matrix

--targetArchitectureBinary FormatRuntime ABI & LinkingSigning / Permissions
win-x64x86_64PE32+ (.exe, 0x8664)kernel32.dll + ws2_32.dll IAT (--gui optional)Standard Windows x64 executable
win-arm64AArch64 (arm64)PE32+ (.exe, 0xAA64)kernel32.dll + ws2_32.dll IAT (--gui optional)Native Windows 11 ARM64 executable (zero x64 emulation)
linux-x64x86_64Static ELF64 (ET_EXEC)Direct Linux syscalls (zero libc)Automatic 0o755 executable mode
linux-arm64AArch64 (arm64)Static ELF64 (EM_AARCH64)Direct asm-generic Linux syscalls (zero libc)Automatic 0o755 executable mode
macos-arm64AArch64 (arm64)16 KiB Mach-O MH_EXECUTEdyld chained fixups + /usr/lib/libSystem.B.dylib stubsBuilt-in pure-Veko SHA-256 ad-hoc LC_CODE_SIGNATURE

Cross-Compile Commands

POWERSHELL
# Windows 11 ARM64 PE32+ (0xAA64) binary (Snapdragon X Elite/Plus, Surface Pro/Laptop, Windows on ARM VMs)
veko compile --native --target=win-arm64 examples/28_simd_optimization_and_arm64_cross_compile.vk -o dist/app_win_arm64.exe

# Static Linux AArch64 (arm64) binary (runs on Raspberry Pi 4/5, AWS Graviton, Ampere, or QEMU)
veko compile --native --target=linux-arm64 examples/28_simd_optimization_and_arm64_cross_compile.vk -o dist/app_linux_arm64

# Apple Silicon macOS arm64 binary (16 KiB pages + automatic ad-hoc SHA-256 LC_CODE_SIGNATURE)
veko compile --native --target=macos-arm64 examples/28_simd_optimization_and_arm64_cross_compile.vk -o dist/app_macos_arm64

# Self-host the full Veko compiler itself for Windows arm64, Linux arm64, or macOS arm64
veko compile --native --target=win-arm64   src/main.vk -o dist/veko_win_arm64.exe
veko compile --native --target=linux-arm64 src/main.vk -o dist/veko_linux_arm64
veko compile --native --target=macos-arm64 src/main.vk -o dist/veko_macos_arm64

Deploying win-arm64 Binaries on Windows 11 on ARM

--target=win-arm64 emits a native AArch64 PE32+ (IMAGE_FILE_MACHINE_ARM64 = 0xAA64) executable using the Windows ARM64 AAPCS64 calling convention (X0..X7 integer arguments, X18 reserved for the Win32 TEB, ADRP+LDR Win32 IAT thunks). Binaries execute directly on Snapdragon X Elite/Plus workstations, Surface Pro/Laptop devices, and Azure/AWS Windows on ARM instances with zero Prism x64 binary-translation overhead, and veko run --native / veko compile --native auto-detect Windows ARM64 hosts automatically.

Testing linux-arm64 Binaries on x86_64 Hosts via QEMU

On Linux or Windows WSL2 (Ubuntu/Debian), install user-mode QEMU emulation and execute linux-arm64 binaries directly:

BASH
sudo apt-get update && sudo apt-get install -y qemu-user
qemu-aarch64 ./dist/app_linux_arm64

Deploying macos-arm64 Binaries on Apple Silicon

Apple Silicon (arm64) macOS requires every executable to be 16 KiB page-aligned and signed with at least an ad-hoc LC_CODE_SIGNATURE containing SHA-256 hashes of every 4 KiB code page. Veko's built-in Mach-O linker (macho_emit.vk) computes and embeds the full CS_MAGIC_EMBEDDED_SIGNATURE / CS_MAGIC_CODEDIRECTORY SHA-256 blob automatically (and unlinks any existing Mach-O target before writing to avoid APFS code-signing vnode cache SIGKILL), while veko run --native, veko compile --native, and veko doc --test --native auto-detect Apple Silicon (macos-arm64) and Linux AArch64 (linux-arm64) hosts out of the box without requiring --target, codesign, or Xcode.


5. Benchmarking Across All Three Tracks

Run Veko's reproducible benchmark suite (benchmarks/bench_suite.vk) to measure native, Wasm 3.0, and bytecode VM throughput on your machine:

POWERSHELL
veko run --native benchmarks/bench_suite.vk
veko run --wasm --fuel=0 benchmarks/bench_suite.vk
veko run benchmarks/bench_suite.vk

The suite benchmarks 9 real-world pure-Veko workloads: math/sqrt+sin, bits/crc32 (1 KiB), seq/sort (64 ints), regex/find-all, compress/gzip, crypto/sha3-256 (1 KiB), crypto/blake2b-256 (1 KiB), crypto/aes-256-gcm, and crypto/mlkem-512 post-quantum encapsulation.