Skip to content

Language: declare(ticks=N) braced statement cadence (#22840)#22867

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-22840-ticks-per-statement
Jul 24, 2026
Merged

Language: declare(ticks=N) braced statement cadence (#22840)#22867
PurHur merged 1 commit into
masterfrom
agent/issue-22840-ticks-per-statement

Conversation

@PurHur

@PurHur PurHur commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • php-cfg parseStmt_Declare now parses braced declare(ticks=N) { … } bodies and emits LeaveTickInterval so the tick interval restores after the block (previously the body was dropped — under-fire).
  • Compiler emits TYPE_TICKS before tickable CFG statements while CG(declarables).ticks-equivalent compile state is active; VM runs tick callbacks only on that opcode (Zend statement cadence, not per-opcode).
  • php-src-strict: Zend 8.2 fixture n=3 / n2=2 matched on VM.

Closes #22840

php-src reference

  • Zend/zend_execute_API.c — tick handlers
  • Zend/zend_compile.cdeclare(ticks=N) / declarables.ticks

PHP implementation

  • Overlay: patches/overlays/php-cfg/Op/Terminal/{SetTickInterval,LeaveTickInterval}.php + script/apply-patches.sh
  • Lowering: lib/Compiler.php (TYPE_TICKS, scoped ENTER)
  • Dispatch: lib/VM.php (TYPE_TICKSmaybeRunTick)

Test plan

  • Issue repro Zend vs VM
  • test/compliance/cases/language/declare_ticks_statement_cadence.phpt
  • Existing declare_ticks / register_tick_function compliance

Verification

./script/docker-exec.sh -- bash -lc 'php test/repro/ticks_per_statement_22840.php; php bin/vm.php test/repro/ticks_per_statement_22840.php'
# Zend+VM: n=3 / n2=2

./script/docker-exec.sh -- bash -lc 'php -d memory_limit=1536M vendor/bin/phpunit --filter "declare_ticks|register_tick_function" test/compliance/VMTest.php'
# OK (3 tests, 3 assertions)

Pillar note: host release-readiness still has north-star5-fast red via #22642 gen-0 fingerprint (pre-existing); this PR is language/VM-only.

Made with Cursor

)

php-cfg ignored braced declare stmts; parse them, leave the tick scope, and
emit TYPE_TICKS before tickable statements so VM cadence matches php-src.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 0219f3a into master Jul 24, 2026
1 check failed
@PurHur
PurHur deleted the agent/issue-22840-ticks-per-statement branch July 24, 2026 12:25
PurHur added a commit that referenced this pull request Jul 24, 2026
…0533) (#22873)

Post-#22866 merges moved live lowering_source_fingerprint to 0859c4ca…
while the committed stamp stayed at 9aee9361…, redding
north-star5-verify-fast step 4f-m and user_release_ready. Restamp only;
honest verified-fresh remains on #22642/#22717.

Co-authored-by: PurHur <PurHur@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression: declare(ticks=N)+register_tick_function under-fires — Zend per-statement (re-#3343, Zend/zend_execute_API.c)

1 participant