ffi step 6: print / format migrate to ..\$args (comptime per-position pack)
`format` and `print` move from `..args: []Any` to `..$args`. The
pack-fn machinery monomorphises each call shape, so the
build_format-emitted body's `any_to_string(args[i])` substitutes
to the i-th concrete-typed call arg via packArgNodeAt — no more
runtime Any-boxing for static args. The Any boxing path still
fires for arg positions whose types collapse to `.any` (already
Any-typed inputs).
Net effect:
- Calls with statically-typed args produce per-shape monos
(`print__ct_<fmt_hash>__pack_s64_string_bool` etc). The mono
cache key now reflects both the format string AND the arg
types, so different shapes get distinct emit paths.
- Compile-time arity errors are now possible (callers passing
the wrong number of args mismatch the mono's positional
binding instead of silently mis-boxing).
- Optionals flow through the new `case optional:` arm in
`any_to_string` (commit ce77867); the variadic auto-unwrap
in `packVariadicCallArgs` stays as a fast-path but is no
longer load-bearing.
IR snapshots regenerated for 13 tests where the print/format
mono shape changed the string-constant pool: 142, the ffi-jni
test cluster, ffi-objc-call-03/06, ffi-objc-dsl-07. Test
08-types' undef-memory-read snapshot also shifted (the test
exercises `field = ---` reads from a print call's stack
neighbours; the new pack-mono lays out its stack frame
differently, so the previously-stale 1s now read as 0s — same
undefined behaviour, different garbage).
218/218 example tests + `zig build test` green.
This commit is contained in:
@@ -750,25 +750,8 @@ entry:
|
||||
; Function Attrs: nounwind
|
||||
define i32 @main() #0 {
|
||||
entry:
|
||||
call void @print__ct_sfeff9eeccd48b824__pack(ptr @__sx_default_context)
|
||||
call void @__sx_objc_defined_class_init()
|
||||
%alloca = alloca { ptr, i64 }, align 8
|
||||
%gep = getelementptr inbounds { ptr, i64 }, ptr %alloca, i32 0, i32 0
|
||||
store ptr null, ptr %gep, align 8
|
||||
%gepN = getelementptr inbounds { ptr, i64 }, ptr %alloca, i32 0, i32 1
|
||||
store i64 0, ptr %gepN, align 8
|
||||
%allocaN = alloca { ptr, i64 }, align 8
|
||||
store { ptr, i64 } { ptr @str.16, i64 9 }, ptr %allocaN, align 8
|
||||
%allocaN = alloca { ptr, i64 }, align 8
|
||||
store { ptr, i64 } { ptr @str.17, i64 0 }, ptr %allocaN, align 8
|
||||
%load = load { ptr, i64 }, ptr %allocaN, align 8
|
||||
%loadN = load { ptr, i64 }, ptr %allocaN, align 8
|
||||
%call = call { ptr, i64 } @substr(ptr @__sx_default_context, { ptr, i64 } %loadN, i64 0, i64 9)
|
||||
%callN = call { ptr, i64 } @concat(ptr @__sx_default_context, { ptr, i64 } %load, { ptr, i64 } %call)
|
||||
store { ptr, i64 } %callN, ptr %allocaN, align 8
|
||||
%loadN = load { ptr, i64 }, ptr %allocaN, align 8
|
||||
%str.ptr = extractvalue { ptr, i64 } %loadN, 0
|
||||
%str.len = extractvalue { ptr, i64 } %loadN, 1
|
||||
%0 = call i64 @write(i32 1, ptr %str.ptr, i64 %str.len)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
@@ -786,6 +769,30 @@ entry:
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define internal void @print__ct_sfeff9eeccd48b824__pack(ptr %0) #0 {
|
||||
entry:
|
||||
%alloca = alloca { ptr, i64 }, align 8
|
||||
store { ptr, i64 } { ptr @str.16, i64 9 }, ptr %alloca, align 8
|
||||
%allocaN = alloca { ptr, i64 }, align 8
|
||||
%gep = getelementptr inbounds { ptr, i64 }, ptr %allocaN, i32 0, i32 0
|
||||
store ptr null, ptr %gep, align 8
|
||||
%gepN = getelementptr inbounds { ptr, i64 }, ptr %allocaN, i32 0, i32 1
|
||||
store i64 0, ptr %gepN, align 8
|
||||
%allocaN = alloca { ptr, i64 }, align 8
|
||||
store { ptr, i64 } { ptr @str.17, i64 0 }, ptr %allocaN, align 8
|
||||
%load = load { ptr, i64 }, ptr %allocaN, align 8
|
||||
%loadN = load { ptr, i64 }, ptr %alloca, align 8
|
||||
%call = call { ptr, i64 } @substr(ptr %0, { ptr, i64 } %loadN, i64 0, i64 9)
|
||||
%callN = call { ptr, i64 } @concat(ptr %0, { ptr, i64 } %load, { ptr, i64 } %call)
|
||||
store { ptr, i64 } %callN, ptr %allocaN, align 8
|
||||
%loadN = load { ptr, i64 }, ptr %allocaN, align 8
|
||||
%str.ptr = extractvalue { ptr, i64 } %loadN, 0
|
||||
%str.len = extractvalue { ptr, i64 } %loadN, 1
|
||||
%1 = call i64 @write(i32 1, ptr %str.ptr, i64 %str.len)
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define internal { ptr, i64 } @__insert_0(ptr %0) #0 {
|
||||
entry:
|
||||
|
||||
Reference in New Issue
Block a user