Skip to content

Language: property hooks JIT — MCJIT execute with builtin calls in hook body (phase 2 of #3145) #4025

Closed

Description

@PurHur

Category

language

Problem

PHP 8.4 property hooks VM + JIT dispatch landed (#3145, #3723), but capability-syntax-lib.php notes MCJIT execute still segfaults when a set-hook body calls ordinary builtins such as str_contains(). That blocks self-host / compliance paths that compile hook bodies natively.

php-src reference

Repro

<?php
class U {
    public string $e {
        set (string $v) {
            $this->e = str_contains($v, '@') ? $v : $v . '@local';
        }
    }
}
$o = new U();
$o->e = 'user';
echo $o->e, "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php repro.php                    # VM: user@local (or Zend-equivalent)
php bin/jit.php repro.php 2>&1 | tail -5    # JIT: segfault / abort today
'

Scope

Layer Files
JIT lib/JIT/PropertyHookDispatch.php, lib/JIT.php — ensure hook invoke preserves frame, $this, raw-property write slot
Builtin calls inside hook verify TYPE_FUNCCALL from hook method IR does not corrupt MCJIT stack
Tests extend test/compliance/cases/language/property_hook_set.phpt with str_contains body

Done when

  • bin/jit.php repro prints same line as VM without segfault
  • ./script/ci-fast.sh --filter property_hook green
  • Remove segfault note from capability-syntax-lib.php property_hooks row

Related

Activity

  1. added
    enhancementNew feature or request
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 1, 2026
  2. PurHur commented on Jun 1, 2026

    @PurHur
    OwnerAuthor

    claim: cursor-lane-c-worker — starting this run

  3. PurHur commented on Jun 1, 2026

    @PurHur
    OwnerAuthor

    Merged via #4059.

    Fix: While lowering __phpc_property_set_* methods, JIT now sets Context::jitPropertyHookRawProperty so assignments to the backing property inside the hook body call propertyStore directly instead of re-entering PropertyHookDispatch (infinite hook recursion → MCJIT segfault).

    Verification (harness):
    ```bash
    ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter PropertyHook'
    ```
    → OK (6 tests; PropertyHookJitExecuteTest skipped until script/jit-runtime-probe.php is green).

    When MCJIT probe passes, bin/jit.php test/repro-maintainer/property_hook_jit.php should match VM (reject / a@b.c).

    php-src: Zend/zend_property_hooks.c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITarea:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions