P5.5: migrate the 35 BuildOptions accessors off #compiler to VM-native abi(.compiler)

`BuildOptions :: struct #compiler { ...35 methods... }` becomes
`BuildOptions :: struct { }` (an opaque null-sentinel handle) plus 35 free
`ufcs (self: BuildOptions, …) abi(.compiler)` decls in build.sx, each serviced
by a new `comptime_vm.callBuildOptionFn` arm (off `callCompilerFn`). No legacy
`compiler_lib` handler: the names are registered in `bound_fns` with a single
bailing stub only so `weldedCompilerFn` accepts them.

- String lifetime: setters dupe the arg into the persistent `Vm.gpa` (the
  Compilation allocator, threaded into both `tryEval` and `runBuildCallback` —
  not the per-eval VM arena) and write/append to the threaded `BuildConfig`.
  Getters read the field/slice or compute the target predicate from the triple.
- Dispatch routing (Option B): a `#run`/const-init entry that directly calls a
  compiler-domain/welded fn (`emit_llvm.entryNeedsVm`) runs on the VM with no
  legacy fallback regardless of the `-Dcomptime-flat` gate, so gate-OFF stays
  green without a legacy BuildOptions handler (P5.7 retires the legacy interp).
- Mark the 5 `platform/bundle.sx` getter-calling helpers `abi(.compiler)` (they
  are comptime-only bundler code; otherwise their now-welded getter calls trip
  the runtime-call gate).
- 37 `.ir` snapshots regenerated (std transitively imports build.sx → string-
  pool/type-table indices shift); verified `.ir`-only, zero behavior-stream diffs.

BuildOptions `compiler_call` strict bails gone (1609/1614/1615 strict-clean);
1616 now bails on a separate, pre-existing unported bitwise/shift VM gap (`shr`),
to port first in P5.6. 703/0 both gates.

Also sweep the outdated "flat memory" terminology to "comptime/byte-addressable"
across comptime_vm + the plan/checkpoint/CLAUDE docs: the comptime VM is
arena-backed, byte-addressable memory where `Addr` is a real host pointer, not a
flat contiguous address space (flag names `-Dcomptime-flat`/`SX_COMPTIME_FLAT` kept).
This commit is contained in:
agra
2026-06-19 13:21:09 +03:00
parent af32c3823c
commit ba28488d99
48 changed files with 13896 additions and 14974 deletions

View File

@@ -1,4 +1,4 @@
// Tests for the flat-memory comptime machine (Phase 1 of PLAN-COMPILER-VM.md).
// Tests for the byte-addressable comptime machine (Phase 1 of PLAN-COMPILER-VM.md).
const std = @import("std");
const vm = @import("comptime_vm.zig");
@@ -710,7 +710,7 @@ test "comptime_vm exec: payloadless enum_init + enum_tag" {
test "comptime_vm exec: tagged-union enum_init with payload lays out {tag@0, payload@tag_size}" {
// The construction primitive `define` reuses: build `E.value(42)` where
// `E = { value: i64, closed: void }` and verify the flat-memory bytes — tag 0
// `E = { value: i64, closed: void }` and verify the comptime bytes — tag 0
// at offset 0, the i64 payload at offset tag_size (8). Mirrors the LLVM
// `{ header, [N x i8] }` layout the rest of the compiler reads.
const alloc = std.testing.allocator;
@@ -843,7 +843,7 @@ test "comptime_vm exec: f32 store/load round-trips through 4-byte memory" {
try std.testing.expectEqual(@as(i64, 1), toI64(try v.run(&fb.func, &.{})));
}
test "comptime_vm exec: malloc builtin gives usable flat memory; free is a no-op" {
test "comptime_vm exec: malloc builtin gives usable comptime memory; free is a no-op" {
const alloc = std.testing.allocator;
var module = Module.init(alloc);
defer module.deinit();
@@ -1282,7 +1282,7 @@ test "comptime_vm bridge: Value <-> Reg round-trips (scalar, string, struct)" {
const back_i = try v.regToValue(alloc, &table, r_i, .i64);
try std.testing.expectEqual(@as(i64, 42), back_i.int);
// string (materialized into flat memory, read back + deep-copied out)
// string (materialized into comptime memory, read back + deep-copied out)
const r_s = try v.valueToReg(&table, .{ .string = "hi" }, .string);
const back_s = try v.regToValue(alloc, &table, r_s, .string);
defer alloc.free(back_s.string);