Commit b28b512
committed
builder: emitAnyCall await-tail → C (PartialConversion, 102/144 → 103/144 = 71.5%)
PartialConversion per theologian PTE pre-audit (chat 2026-04-22 17:15Z) +
supervisor concurrence (chat 17:18Z) + Alex 'NO SESSION BOUNDARIES — keep
working until ZERO C++' anchor [memory 2026-04-21]. Bridge-count gate
satisfied: 1 new top-level bridge (within gate), 0 sub-bridges.
SCOPE: only the await-tail dispatch (lines 2963-2993 in pre-conversion
source) is converted to C. The opcode-switch + INVOKE_FUNCTION/NATIVE/
METHOD/METHOD_VECTORCALL dispatch stay C++ until Tier 6 INVOKE_*
re-architecture (deferred per gate-count gate per [chat L1922]:
FullConversion would require 4+ new bridges, violating ≤1 limit).
Python/jit/hir/builder.cpp:
emitAnyCall await-tail block (lines 2963-2993, ~30 lines C++) →
1) C++ stub: 3x ++bc_it + 3x JIT_CHECK on opcode sequence (PA + A4) +
checkAsyncWithError(get_awaitable_bc) → (error_aenter, error_aexit) +
extract load_const_oparg from LOAD_CONST bc + call C body
2) checkAsyncWithError forward decl added (defined static at builder.cpp
:~4856, post-call-site refactor required forward visibility)
3) New extern decl: hir_builder_emit_awaited_call_tail_c
Python/jit/hir/builder_emit_c.c:
NEW hir_builder_emit_awaited_call_tail_c (~50 lines):
A5 alloc out + 2 blocks (await_block + post_await_block)
A5 dispatch_eager_coro_result (chains to push 55 C function)
A6 tc->block = await_block
A7 get_awaitable using pre-computed error flags (chains to push 56)
A8 load_const using pre-computed oparg + caller-passed code
A9 yield_from_method (chains to push 53)
A10 phx_tc_emit branch to post_await_block
A11 tc->block = post_await_block
PTE-trial invariant inventory verification per theologian [chat L1928]:
12 invariants A1-A12 + 4 pitfalls PA-PD.
PA: JIT_CHECK fires C++-side BEFORE C call ✓
PB: iterator state stays C++-side; only ints + pointers cross boundary ✓
PC: tc->block reassignment in C body (A6 + A11) ✓
PD: code passed as PyCodeObject* (not void*) — preserves emitGetAwaitable
port's PA invariant ✓
PTE TRIAL ROUND 2 FEEDBACK: A4 IF/THEN structure made
'JIT_CHECK MUST fire BEFORE C call' visually unambiguous. PD pitfall
on code_ typing caught at design time. Two empirical wins
(round 1: PD.a/PD.b distinction, round 2: A4 + PD).
Bridge spec (8 args, ratified by theologian [chat L1931]):
void hir_builder_emit_awaited_call_tail_c(
PhxTranslationContext* tc, void* func, void* builder,
PyCodeObject* code, int code_flags,
int get_awaitable_error_aenter, int get_awaitable_error_aexit,
int load_const_oparg);
testkeeper x86_64 compile-only PASS verified pre-commit at binary
timestamp 1776878644 (chat 17:24Z). Iter 1 needed forward decl for
checkAsyncWithError; v2 cleaned.
Tier 5 milestone: 103/144 = 71.5% with PartialConversion-asterisk on
emitAnyCall (await-tail in C, opcode-switch + INVOKE_* still C++).
Pre-push 61 gate ahead (per pythia python#77 python#3 + supervisor [chat L1939]):
testkeeper authors call-shape falsifier extension exercising
emitCallExceptionHandler D1-D3 invariants (theologian spec [chat L1942]:
3 tests covering function-call-in-try + closure-LOAD_DEREF +
unmatched-exception-deopt). Lands as separate commit before
Tier 5 close push.
Authorization chain:
- theologian PTE pre-audit + design lean (a, but generalist chose b): chat L1928
- bridge spec ratification: chat L1931
- supervisor concurrence on (B) PartialConversion: chat L1930
- testkeeper x86_64 compile PASS: chat L19441 parent 9630005 commit b28b512
2 files changed
Lines changed: 95 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2854 | 2854 | | |
2855 | 2855 | | |
2856 | 2856 | | |
| 2857 | + | |
| 2858 | + | |
| 2859 | + | |
| 2860 | + | |
| 2861 | + | |
| 2862 | + | |
| 2863 | + | |
| 2864 | + | |
| 2865 | + | |
| 2866 | + | |
| 2867 | + | |
| 2868 | + | |
| 2869 | + | |
| 2870 | + | |
| 2871 | + | |
| 2872 | + | |
| 2873 | + | |
| 2874 | + | |
2857 | 2875 | | |
2858 | 2876 | | |
2859 | 2877 | | |
| |||
2961 | 2979 | | |
2962 | 2980 | | |
2963 | 2981 | | |
2964 | | - | |
2965 | | - | |
2966 | | - | |
2967 | | - | |
2968 | | - | |
2969 | | - | |
2970 | | - | |
2971 | | - | |
2972 | | - | |
| 2982 | + | |
| 2983 | + | |
| 2984 | + | |
2973 | 2985 | | |
2974 | 2986 | | |
2975 | 2987 | | |
2976 | 2988 | | |
2977 | | - | |
| 2989 | + | |
| 2990 | + | |
| 2991 | + | |
2978 | 2992 | | |
2979 | 2993 | | |
2980 | 2994 | | |
2981 | 2995 | | |
2982 | 2996 | | |
2983 | | - | |
| 2997 | + | |
2984 | 2998 | | |
2985 | 2999 | | |
2986 | 3000 | | |
2987 | 3001 | | |
2988 | 3002 | | |
2989 | | - | |
2990 | | - | |
2991 | 3003 | | |
2992 | | - | |
| 3004 | + | |
| 3005 | + | |
| 3006 | + | |
| 3007 | + | |
| 3008 | + | |
| 3009 | + | |
| 3010 | + | |
| 3011 | + | |
| 3012 | + | |
2993 | 3013 | | |
2994 | 3014 | | |
2995 | 3015 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3343 | 3343 | | |
3344 | 3344 | | |
3345 | 3345 | | |
| 3346 | + | |
| 3347 | + | |
| 3348 | + | |
| 3349 | + | |
| 3350 | + | |
| 3351 | + | |
| 3352 | + | |
| 3353 | + | |
| 3354 | + | |
| 3355 | + | |
| 3356 | + | |
| 3357 | + | |
| 3358 | + | |
| 3359 | + | |
| 3360 | + | |
| 3361 | + | |
| 3362 | + | |
| 3363 | + | |
| 3364 | + | |
| 3365 | + | |
| 3366 | + | |
| 3367 | + | |
| 3368 | + | |
| 3369 | + | |
| 3370 | + | |
| 3371 | + | |
| 3372 | + | |
| 3373 | + | |
| 3374 | + | |
| 3375 | + | |
| 3376 | + | |
| 3377 | + | |
| 3378 | + | |
| 3379 | + | |
| 3380 | + | |
| 3381 | + | |
| 3382 | + | |
| 3383 | + | |
| 3384 | + | |
| 3385 | + | |
| 3386 | + | |
| 3387 | + | |
| 3388 | + | |
| 3389 | + | |
| 3390 | + | |
| 3391 | + | |
| 3392 | + | |
| 3393 | + | |
| 3394 | + | |
| 3395 | + | |
| 3396 | + | |
| 3397 | + | |
| 3398 | + | |
| 3399 | + | |
| 3400 | + | |
| 3401 | + | |
| 3402 | + | |
| 3403 | + | |
| 3404 | + | |
| 3405 | + | |
| 3406 | + | |
3346 | 3407 | | |
3347 | 3408 | | |
0 commit comments