Repository navigation
Commit b44f075
committed
builder: emitInlineExceptionMatch → C (100/144 → 101/144 = 70.1%)
Convert HIRBuilder::emitInlineExceptionMatch — the largest, most
complex method in the original 7-method remaining set (185-line C++
source with inline bytecode dispatch + 5-block + D-1774910012
invariant). Mirrors C++ HIRBuilder::emitInlineExceptionMatch @
builder.cpp:1329 (pre-conversion).
Tier 5 milestone: 70.1%. emitInlineExceptionMatch is the FIRST method
shipping with both encoding-clean AND invariant-preserved validation
per pythia python#73 (chat 14:39:something) gap closure: D-1774910012
falsifier (3 tests, 595734c) landed pre-port and preserved post-port
per testkeeper 8-test gate at chat 15:31:50Z.
W25-defer-aware A1 stub-heavy bytecode-parse design (theologian
chat 14:48:10Z pre-audit): ZERO new bridges. Pre-audit bridge-count
gate per supervisor 14:16:55Z policy (>1 → HALT for Option B
reconsideration); this method passed at 0 ≤ 1.
5 phases per pre-audit:
P1: getitem CallStatic dispatch (pointer pre-resolved by C++ stub
via JITRT_DictGetItem vs PyObject_GetItem)
P2: exc_tc setup with depth-trim + LoadConst exc_type +
JITRT_MatchAndClearException CallStatic + match_block /
deopt_block CondBranch
P3: match_tc setup + Py_None placeholder push (D-1774910012 PA)
+ bytecode dispatch loop (10 cases + default)
P4: deopt_tc setup with re-push left/right + Snapshot + Deopt
P5: ok block — RefineType in-place SSA-rename
3 separate PhxTranslationContext objects (PB):
exc_tc copies from tc.frame
match_tc copies from EXC_TC.FRAME (depth-trimmed)
deopt_tc copies from TC.FRAME (original, NOT exc_tc)
Approach: C++ stub iterates info.except_body bytecodes via
BytecodeInstruction.nextInstr() and builds an opcode array with
pre-resolved const_obj (LOAD_CONST/RETURN_CONST) and
jump_target_block (JUMP_BACKWARD*). C body switches on the array.
Sibling C emit functions (hir_builder_emit_swap_c / load_fast_c /
store_fast_c / binary_op_c) called directly with extern decls.
OpcodeArrayEntry struct mirrored on C++ + C side (5 fields per entry:
opcode, oparg, base_offset, const_obj, jump_target_block). C++
static_assert on size sanity check.
D-1774910012 invariant (PA pitfall): Py_None placeholder pushed on
match_tc.frame.stack BEFORE dispatch loop; POP_EXCEPT case pops the
placeholder. Mirrors the inline exception handler deopt fix at
28b4ee1 from 2026-04-01. Failure mode: closure LOAD_DEREF in
except blocks → deopt stack mismatch → exc_info chain corruption
post-threshold (only triggers post-1000 calls). Preserved via the
falsifier in test_phoenix_jit_inline_except_closure.py (push 595734c).
Bytecode dispatch loop opcodes (10 handled + default):
POP_EXCEPT (pops placeholder per PA), POP_TOP (pops TOS),
SWAP, LOAD_FAST/_CHECK/_AND_CLEAR (3 cases), LOAD_CONST,
STORE_FAST, BINARY_OP, RETURN_CONST, RETURN_VALUE,
JUMP_BACKWARD/_NO_INTERRUPT (2 cases), default → deopt
Pitfalls addressed inline (theologian chat 14:48:10Z 8 pitfalls):
PA: D-1774910012 Py_None placeholder + POP_EXCEPT pops
PB: 3-TC frame-copy origins (each from correct source frame)
PC: handler.depth depth-trim while-loop in P2
PD: dispatch loop default → deopt (silent path; supervisor
chat 15:30:08Z (b) JIT_DCHECK addition deferred to follow-up
commit pending design clarification)
PE: emitted_terminator semantics replaced by `goto match_loop_done`
pattern in C
PF: phx_frame_state_destroy on ALL 3 TCs at function end
PG: sibling C emit functions take match_tc explicitly
PH: stub-built opcode array with 5 fields per entry
JITRT_MatchAndClearException pointer passed from C++ stub via void*
(vs C-side direct reference) — avoids C-vs-C++ name mangling at
link time. Same pattern as getitem_fn.
testkeeper iter cycle:
iter 1: 5 errors (extern decl signature mismatches on sibling
emit functions + arg counts on LOAD_FAST/STORE_FAST)
iter 2: 2 errors (binary_op_c PhxTranslationContext* sig +
BCOffset→int conversion)
iter 3: 1 link error (JITRT_MatchAndClearException name mangling)
iter 4: PASS — JIT_BUILD_EXIT=0, full --clean BUILD_EXIT=0,
8-test gate including D-1774910012 falsifier 8/8 PASS
W26 gate-hardening not triggered (clean build path). ZERO new
bridges held. Per pythia python#74 (chat 15:29:something): PA invariant
validated by falsifier; PB-PH rely on theologian's spec + reviewer
inspection. Mutation test per supervisor chat 15:30:08Z (a) is
gating push 59 PUSH AUTHORIZED — testkeeper to execute before
dual-arch.1 parent 595734c commit b44f075
2 files changed
Lines changed: 299 additions & 167 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1326 | 1326 | | |
1327 | 1327 | | |
1328 | 1328 | | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
1329 | 1354 | | |
1330 | | - | |
| 1355 | + | |
1331 | 1356 | | |
1332 | 1357 | | |
1333 | 1358 | | |
1334 | 1359 | | |
1335 | 1360 | | |
1336 | 1361 | | |
1337 | 1362 | | |
1338 | | - | |
1339 | | - | |
1340 | | - | |
| 1363 | + | |
1341 | 1364 | | |
1342 | 1365 | | |
1343 | 1366 | | |
1344 | | - | |
1345 | | - | |
1346 | | - | |
1347 | | - | |
1348 | | - | |
1349 | | - | |
1350 | 1367 | | |
1351 | | - | |
1352 | | - | |
1353 | | - | |
1354 | | - | |
1355 | | - | |
1356 | | - | |
1357 | | - | |
1358 | | - | |
1359 | | - | |
1360 | | - | |
1361 | | - | |
1362 | | - | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
1363 | 1385 | | |
1364 | | - | |
1365 | | - | |
1366 | | - | |
1367 | | - | |
1368 | | - | |
1369 | | - | |
1370 | | - | |
1371 | | - | |
1372 | | - | |
1373 | | - | |
1374 | | - | |
1375 | | - | |
1376 | | - | |
1377 | | - | |
1378 | | - | |
1379 | | - | |
1380 | | - | |
1381 | | - | |
1382 | | - | |
1383 | | - | |
1384 | | - | |
1385 | | - | |
1386 | | - | |
1387 | | - | |
1388 | | - | |
1389 | | - | |
1390 | | - | |
1391 | | - | |
1392 | | - | |
1393 | | - | |
1394 | | - | |
1395 | | - | |
1396 | | - | |
1397 | | - | |
1398 | | - | |
1399 | | - | |
1400 | | - | |
1401 | | - | |
1402 | | - | |
1403 | | - | |
1404 | | - | |
1405 | | - | |
1406 | | - | |
1407 | | - | |
1408 | | - | |
1409 | | - | |
1410 | | - | |
1411 | | - | |
1412 | | - | |
1413 | | - | |
1414 | | - | |
1415 | | - | |
1416 | | - | |
1417 | | - | |
1418 | | - | |
1419 | | - | |
1420 | | - | |
1421 | | - | |
1422 | | - | |
1423 | | - | |
1424 | | - | |
1425 | | - | |
1426 | | - | |
1427 | | - | |
1428 | | - | |
1429 | | - | |
1430 | | - | |
1431 | | - | |
1432 | | - | |
1433 | | - | |
1434 | | - | |
1435 | | - | |
1436 | | - | |
1437 | | - | |
1438 | | - | |
1439 | | - | |
1440 | | - | |
1441 | | - | |
1442 | | - | |
1443 | | - | |
1444 | | - | |
1445 | | - | |
1446 | | - | |
1447 | | - | |
1448 | | - | |
1449 | | - | |
1450 | | - | |
1451 | | - | |
1452 | | - | |
1453 | | - | |
1454 | | - | |
1455 | | - | |
1456 | | - | |
1457 | | - | |
1458 | | - | |
1459 | | - | |
1460 | | - | |
1461 | | - | |
1462 | | - | |
1463 | | - | |
1464 | | - | |
1465 | | - | |
1466 | | - | |
1467 | | - | |
1468 | | - | |
1469 | | - | |
1470 | | - | |
1471 | | - | |
1472 | | - | |
1473 | | - | |
1474 | | - | |
1475 | | - | |
1476 | | - | |
1477 | | - | |
1478 | | - | |
1479 | | - | |
1480 | | - | |
1481 | | - | |
1482 | | - | |
1483 | | - | |
1484 | | - | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
1485 | 1389 | | |
1486 | | - | |
1487 | | - | |
1488 | | - | |
1489 | | - | |
1490 | | - | |
1491 | | - | |
1492 | | - | |
1493 | | - | |
1494 | | - | |
1495 | | - | |
1496 | | - | |
1497 | | - | |
1498 | | - | |
1499 | | - | |
1500 | | - | |
1501 | | - | |
1502 | | - | |
1503 | | - | |
1504 | | - | |
1505 | | - | |
1506 | | - | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
1507 | 1404 | | |
1508 | 1405 | | |
1509 | 1406 | | |
1510 | | - | |
1511 | | - | |
1512 | | - | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
1513 | 1423 | | |
1514 | 1424 | | |
| 1425 | + | |
1515 | 1426 | | |
1516 | 1427 | | |
1517 | 1428 | | |
| |||
0 commit comments