◐ Shell
clean mode source ↗

Change some mercurial/ hg.python.org references. by orsenthil · Pull Request #8 · python/cpython

Mariatta

@orsenthil

berkerpeksag

orsenthil added a commit that referenced this pull request

Feb 20, 2017
(cherry picked from commit b2ee40e)

orsenthil added a commit that referenced this pull request

Feb 20, 2017
(cherry picked from commit b2ee40e)

orsenthil added a commit that referenced this pull request

Feb 20, 2017
(cherry picked from commit b2ee40e)

paulmon added a commit to paulmon/cpython that referenced this pull request

Jan 10, 2019
workaround optimizer problem

emmatyping referenced this pull request in emmatyping/cpython

Feb 5, 2020

oraluben referenced this pull request in oraluben/cpython

Jun 25, 2023
Co-authored-by: Ken Jin <kenjin@python.org>

skirpichev referenced this pull request in skirpichev/cpython

Dec 4, 2024

This was referenced

Feb 11, 2025

DinoV added a commit to DinoV/cpython that referenced this pull request

Oct 9, 2025

@Qanux Qanux mentioned this pull request

Feb 11, 2026

johnslavik pushed a commit to johnslavik/cpython that referenced this pull request

Mar 11, 2026

SonicField added a commit to SonicField/cpython that referenced this pull request

Apr 4, 2026
Add compile-time checks before OperandBase devirtualization:
- sizeof(OperandBase) == sizeof(Operand) == sizeof(LinkedOperand)
  (prerequisite for safe deletion through base pointer)
- sizeof(LirBasicBlock) == sizeof(BasicBlock)
- sizeof(LirFunction) == sizeof(Function)
  (cross-validate C and C++ struct layouts per Pythia python#8)

SonicField added a commit to SonicField/cpython that referenced this pull request

Apr 22, 2026
Convert HIRBuilder::emitLoadMethodOrAttrSuper from C++ multi-block
deopt+dispatch to a thin delegation stub. New C function
hir_builder_emit_load_method_or_attr_super_c builds the deopt path
(snapshot+deopt) and fast path (CondBranchCheckType + RefineType +
LoadAttrSuper or LoadMethodSuper+GetSecondOutput).

C++ stub computes nothing — passes oparg + bc_offset.value() through
to C. The C body computes name_idx/load_method/no_args from oparg
(3.11+ packing per theologian audit python#3 — load_method param overwrite),
following the project's 3.12-only convention dropping the pre-3.11
oparg-tuple branch.

Theologian invariant audit (2026-04-22 11:58:52Z) drives the
implementation:

  python#1 phx_frame_state_copy runs BEFORE the 3 pops so deopt-path frame
     preserves PRE-POP stack for interpreter resumption
  python#4 pop order: receiver (TOS), type, global_super
  python#5 push order varies by load_method (1 value vs 2)
  python#8 deopt-path emits go into deopt_tc.block
  python#9 CondBranchCheckType branches; tc.block <- fast_path; emit
     RefineType in-place

Both exit paths phx_frame_state_destroy the deopt_tc to avoid leaking
the heap-allocated stack/locals arrays.

testkeeper pre-commit verify (2026-04-22 12:15:46Z): JIT_BUILD_EXIT=0,
full BUILD_EXIT=0, 7/7 phoenix-jit tests PASS at HEAD+uncommitted.
W26 gate-hardening not triggered (no recent fail).

SonicField added a commit to SonicField/cpython that referenced this pull request

Apr 23, 2026
Eliminate the C++ wrapper HIRBuilder::emitSetupWith by folding its
PY_VERSION_HEX conditional + handler_off compute into the existing C
body hir_builder_emit_setup_with_c. Caller now passes the raw bytecode
oparg + next_instr_off; the C body derives enter_id/exit_id/is_async
(version-conditional) and computes
handler_off = next_instr_off + oparg * sizeof(_Py_CODEUNIT) locally.

Second Cat-B fold-into-C in Phase 1 burndown (after python#6 emitBeforeWith).
Pattern remaining for emitSetupWithCommon (Register* helper sibling,
Phase 1 python#8).

Authorization: theologian 22:30:11Z + supervisor 22:30:26Z. Lib/test
scope verified clean (0 references) per medic 21:16:05Z gate.

Numstat:
  Python/jit/hir/builder.cpp     +5 -28  (delete wrapper + extern,
                                          add file-scope extern,
                                          rewrite caller)
  Python/jit/hir/builder.h       +0 -3   (delete decl)
  Python/jit/hir/builder_emit_c.c +28 -8 (fold version+compute logic)
NET: -6 lines, substantive (algorithmic fold-into-C).

W44 gate: PASS (2 markers, 0 production callers).

SonicField added a commit to SonicField/cpython that referenced this pull request

Apr 23, 2026
Phase 1 python#6 (emitBeforeWith) + python#7 (emitSetupWith) both folded their
PY_VERSION_HEX conditional + C++ wrapper logic INTO the C body, and
their callers now invoke hir_builder_emit_setup_with_common_c (the
internal C-bridge helper) directly from C — bypassing the C++ method
HIRBuilder::emitSetupWithCommon entirely.

That made the C++ wrapper DEAD: zero production callers.

Delete:
  builder.cpp: -21L (15L method def + 3L extern decl + 3L blanks)
  builder.h:   -10L (decl removed)
  builder_emit_c.c: +4 -5 (stale doc comment refresh — drop W27c
                          tag + C++ method back-reference)
NET: -32L pure deletion (no fold-into-C, no sig mutation).

The C body hir_builder_emit_setup_with_common_c is RETAINED — used
internally by hir_builder_emit_setup_with_c (Phase 1 python#7) and
hir_builder_emit_before_with_c (Phase 1 python#6) as a .c→.c helper.

Authorization: theologian 22:49:41Z (cross-check PASS, exhaustive
caller enumeration via grep -rnE '\bemitSetupWithCommon\b' Python
Include Lib/test → 0 production callers) + supervisor 22:49:52Z
(GO Step B). W45 fixture exemption justified per theologian 22:49:41Z:
shepard 22:46:33Z discipline applies to fold-into-C / sig-mutation;
delete-of-dead-code is neither (same precedent as Phase 1 python#1 INVOKE_*
delegation-stub deletes).

W44 gate: PASS (2 markers, 0 production callers).

SonicField added a commit to SonicField/cpython that referenced this pull request

Apr 24, 2026
ROOT CAUSE FIX for the 8-incident undiagnosed-recurring file-state
revert class (D-1776998268 + 7 priors).

Per supervisor 04:14:27Z post-incident-python#8 ROOT CAUSE IDENTIFICATION:
the §3.5 falsifier's restore_files() trap was the "external reverter"
across all 8 incidents. It ran `git checkout HEAD --` on TOUCHED_FILES
on script exit; if those files had unstaged modifications BEFORE the
script ran (e.g., agent's in-flight Tier 8 Phase A content), the trap
blew them away.

Empirical validation (this session 04:13:36Z):
- Test python#6 + python#7 (trivial content, single-mechanism): no revert
- Tests python#5/python#7 idle: no revert
- cmake build alone: no revert
- §3.5 invocation on staged Phase A: REVERT (PhxExceptionTable
  count 13 → 0; mtime bumped 1777002918 → 1777003987; builder_state_c.h
  no longer M in git status)

8 prior incidents now retroactively attributed to §3.5 trap firing
during build/gate cycles concurrent with agent Tier 8 attempts.
NO external actor (no VS Code, no Alex, no formatter, no cron).
W48 inotify daemon NOT NEEDED. (Iso-A) host relocation NOT NEEDED.
Class size CLOSED — class type changed from "undiagnosed-recurring"
to "self-inflicted via §3.5 trap, RESOLVED".

Fix mechanism: snapshot per-file content to /tmp on first
snapshot_file_if_new() call (per fixture mutation start). restore_files()
copies from snapshot (not HEAD), preserving pre-script unstaged state.
Snapshots cleaned + FILE_SNAPSHOTS array unset post-restore.

Re-validation (this session post-fix):
- §3.5 BUILD MODE 4/4 PASS
- post-restore build [OK]
- Phase A content (PhxExceptionTable count 13) SURVIVED §3.5 invocation
- ALL 6 Tier 8 staged files still M

Doc-only (script-only) push, no §3.5 BUILD MODE per touched-files rule
(this IS the §3.5 script being amended; meta-circular but doc-only
gate appropriate).

Authorization: supervisor 04:14:27Z FIX directive post-ROOT-CAUSE
identification (generalist 04:13:58Z catch).

Pythia python#105 'fever has name infection still spreads' was structurally
correct re self-inflicted infrastructure — but the infection wasn't
external-class undiagnosable; it was OUR OWN script's exit trap
trampling unstaged work. 5 detection layers (Alex directive D-1776434533,
gate python#3 D-1776887480, 4-step Pre-Edit WT Integrity D-1776995670,
mtime-checkpoint D-1776998268, W48 spec D-1776999077) added to detect
ourselves. Audit own scripts BEFORE external-actor hypotheses (per
new feedback memory entry).

SonicField added a commit to SonicField/cpython that referenced this pull request

Apr 24, 2026
…esolution)

Per supervisor 04:41:28Z (2) + theologian 04:43:15Z findings + supervisor
04:43:37Z accept-all-3 disposition. Adds rollback-audit subsection
under Pre-Edit Working-Tree Integrity rationale.

KEEP-all-3 with cost-acknowledgment:
- 4-step Pre-Edit WT Integrity: KEEP (validated discipline regardless
  of false-actor framing)
- mtime-checkpoint extension: KEEP (caught self-inflicted bug pre-
  commit at incident python#8)
- Expanded pre-commit gate (compile + §3.5 BUILD MODE + per-bench):
  KEEP (validated; cost ~17min per Tier 8 commit acceptable)

NEW cost-benefit rule: future detection-layer additions require
explicit cost-benefit framing + cite the 8-incident false-actor lesson
before authoring. trivial-push exemption (supervisor 00:39:20Z)
remains in force.

Sequencing slip: this was directed as part of cascade bundle per
supervisor 04:41:28Z but landed separately. Acceptable per supervisor
04:43:37Z.

Doc-only +2L (paragraph wrap; supervisor counted +6L logical).
Authorization: theologian 04:43:15Z findings + supervisor 04:43:37Z GO.

SonicField added a commit to SonicField/cpython that referenced this pull request

Apr 27, 2026
Phase 4.A pilot conversion of the BuiltinLoadMethodElimination pass
(theologian invariant pre-audit 08:10:43Z + patch-shape APPROVE
08:39:30Z + nit-close 08:43:33Z; supervisor 08:14:58Z). First mutating-
pass conversion under Phase 4 OPEN; methodology (b) sole-path swap +
per-commit ABBA gate per supervisor 08:15:23Z + theologian 08:15:08Z.

  Python/jit/hir/builtin_load_method_elimination_c.c (NEW, 295 LOC)
    Pure-C body for the LoadMethod / GetSecondOutput / CallMethod
    triple rewrite. Uses the Cat-A helpers already in
    blme_helpers_c.{c,h}: phx_get_method_object_from_type +
    phx_immutable_multithreaded_type_lookup. Container is a
    PhxBlmeArray linear-scan keyed on LoadMethodBase pointer
    (theologian recommendation; max LoadMethodBase per function is
    typically <50). Outer fixed-point loop has a defensive iteration
    cap (PHX_BLME_MAX_ITERATIONS=100) per theologian invariant python#8 —
    cap-hit fires JIT_DCHECK_C in pydebug, benign early-out in
    release. JIT_COMPILE_GUARD wraps each per-triple rewrite per
    invariant python#7. addReference for both method_obj AND type_obj per
    invariant python#6 (PyClassMethodDescr branch).

  Python/jit/hir/builtin_load_method_elimination.cpp (-172 +9)
    Deleted the C++ tryEliminateLoadMethod + Run bodies and the
    extern "C" wrapper. Run() now forwards to
    hir_builtin_load_method_elimination_run via static_cast<HirFunction>;
    jit::hir::BuiltinLoadMethodElimination remains an instantiable
    Pass for compiler.cpp:127's runPassIf chain.

  Python/jit/hir/hir_instr_c_verify.cpp (+9)
    Cross-C-struct name_idx-offset asserts for the LoadMethodBase set
    (HirLoadMethod / HirLoadMethodCached / HirLoadModuleMethodCached).
    No concrete C++ classes for these opcodes — Phoenix allocates them
    via C factories — so the load-bearing invariant is C-side layout
    consistency, not C↔C++ matching. Cross-arch DeoptBaseWithNameIdx
    layout is covered indirectly by the existing FillTypeAttrCache
    assert (same HIR_DEOPT_NAMEIDX_FIELDS macro origin).

Build: scripts/build_phoenix.sh --clean ThinLTO PASS (testkeeper
09:06:00Z, isolated to these 3 files). 5 JIT_DCHECK_C call sites,
1 new include cinderx/Common/jit_log_c.h.

ABBA (4-bench, 3-rep, baseline = vanilla CPython):
  fibonacci    2.29x  (+56.3%)
  nqueens      1.59x  (+37.2%)
  gen_simple   0.74x  (-34.7%)  pre-existing alert (push 59 baseline 0.70x;
                                BLME modifies CallMethod/LoadMethodBase
                                pairs, generators don't exercise that hot
                                path; no causal mechanism for new regression)
  func_calls   1.01x  (+0.6%)
  GEO-MEAN     1.28x   no >5% drop trigger; well above 1.0x floor

Per-trajectory accounting per docs/phase4-hir-burndown-spec.md §5
(post 7a11cc0 refinement):
- C added: +295 (.c body) + 9 (verifier) = +304
- C++ removed: 172 (algorithm body) — shell deletion deferred to
  Phase 4.D (compiler.cpp:127 still consumes the C++ Pass type)
- Shell-pending: builtin_load_method_elimination.cpp 21 LOC