feat(opcache): macOS/arm64 support for the relocator (addressing-model tripwire) - #268
Merged
Merged
Conversation
Merged
6 tasks
…pwire Scope finding for issue #119 (macOS/arm64 relocator support): the per-opline absolute-address branches of zend_file_cache_(un)serialize_op_array (op1/op2.zv SERIALIZE_PTR and the jmp_addr switch) are compiled in only when ZEND_USE_ABS_CONST_ADDR / ZEND_USE_ABS_JMP_ADDR are 1, and zend_compile.h (PHP-8.4.19) defines both as 1 exactly when SIZEOF_SIZE_T == 4. Darwin x64 and arm64 are 64-bit builds and use the same relative addressing as linux - there is no darwin-specific opline walking to port. Implementing those branches would be dead code on every build the relocator supports, so they are deliberately NOT implemented; 32-bit builds (the only ones that use absolute addressing) stay refused by the PHP_INT_SIZE === 8 predicate. What lands instead: - OpcodeAddressingModelTest: proves the relative model on a real compiled payload - every IS_CONST operand in the file is a literal-table index and every JMP-family operand lands on an opline of its own op_array. The test runs (does not skip) on every supported build, darwin CI legs included, and FAILS loudly if a build ever produces absolute operands. - fixtures/addressing-probe.php: top-level code built around getenv() so SCCP cannot fold away the ?: and !== branches - IS_CONST operands and conditional jumps are guaranteed in the main op_array. - The opcodes comment in PayloadRelocator and docs/opcache-binary.md now state the invariant and its source precisely. Darwin execution of these tests happens on the PR's tests-macos CI legs (the relocator group already gates there since #118 removed the ZTS exclusion); no local darwin validation is possible from this environment. Acceptance evidence: - host: full default suite (520 tests, baseline skip counts), --group opcache --fail-on-skipped OK (48 tests, 338 assertions) - z-engine-php:debug84 and z-engine-php:debug84-zts containers: same opcache gate OK (48/338 each) - phpstan level max clean, php-cs-fixer clean Fixes #119 Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BDcCQiYqbMkjRPyhWgLL6M
lisachenko
force-pushed
the
claude/opcache-118-zts-relocator
branch
from
August 20, 2026 00:30
67fee31 to
fb8bda9
Compare
lisachenko
force-pushed
the
claude/opcache-119-darwin-relocator
branch
from
August 20, 2026 00:30
193bd6e to
a20e806
Compare
6 tasks
lisachenko
marked this pull request as ready for review
August 20, 2026 00:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Fixes #119 — stacked on #267.
Scoping finding (the point of the issue): the
ZEND_USE_ABS_CONST_ADDR/ZEND_USE_ABS_JMP_ADDRper-opline branches are compiled in only whenSIZEOF_SIZE_T == 4(zend_compile.h). Darwin x64 and arm64 are 64-bit and use the same relative addressing as linux — there is no darwin-specific opline walking to port, and implementing those branches would be dead code on every supported build. So they are deliberately not implemented; 32-bit builds (the only absolute-addressing ones) stay refused byPHP_INT_SIZE === 8.Landed instead:
OpcodeAddressingModelTest— a tripwire proving the relative model on a real compiled payload (every IS_CONST operand is a literal-table index; every JMP-family operand lands on an opline of its own op_array) that fails, not skips, on any supported build (darwin CI legs included) if a build ever emits absolute operands. Plusfixtures/addressing-probe.php(getenv-guarded so SCCP can't fold the const/jump ops). Docs + the opcodes comment record the invariant and its source.Darwin execution happens on this PR's
tests-macosCI legs — the tripwire runs there; if it ever goes red, a darwin build unexpectedly uses absolute addressing and the abs-addr branches would then need porting.Environment it was verified on
php -v): PHP 8.4.19 (cli) (built: Mar 30 2026 19:28:35) (NTS) + ZTS debug container--enable-debug)? yes — debug84 NTS + debug84-zts, opcache gate 48 eachAlso: host 520 tests, opcache gate 48; PHPStan level max clean; cs-fixer clean.
Checklist
8.4)composer testpasses on the matching PHP minorcomposer phpstan(level max) andcomposer cs:checkare greentools/generator/symbols.phpunchanged — nothing generated touched🤖 Generated with Claude Code
https://claude.ai/code/session_01BDcCQiYqbMkjRPyhWgLL6M
Generated by Claude Code