Skip to content

php-in-php: JIT ErrorHandlerJitRuntime — route set_error_handler through VmErrorHandler PHP not ~556-line LLVM (#1492) #9472

Description

@PurHur

Category

php-in-php · stdlib

Problem

JIT/AOT link currently emits ~556 lines of hand-written LLVM in lib/JIT/Builtin/ErrorHandlerJitRuntime.php for set_error_handler() / restore_error_handler() / dispatch — duplicating semantics already implemented in PHP at ext/standard/VmErrorHandler.php (235 lines, php-src basic_functions.c parity).

Per #1492 PHP-in-PHP strategy: JIT should call compiled PHP helpers (or thin trampolines), not maintain a parallel error-handler stack in LLVM globals (phpc_error_handler_depth, phpc_error_handler_fn, …).

php-src reference

Repro (parity must hold after migration)

<?php
set_error_handler(function (int $no, string $msg) {
    echo "handled:$msg\n";
    return true;
});
trigger_error('boom', E_USER_WARNING);
restore_error_handler();
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/jit.php repro.php
php bin/compile.php repro.php -o /tmp/repro && /tmp/repro
'

VM baseline already green; JIT/AOT must match after deleting LLVM stack logic.

Scope (this repo)

Path Work
lib/JIT/Builtin/ErrorHandlerJitRuntime.php Delete/shrink LLVM handler stack; delegate to VmErrorHandler via JIT builtin call
ext/standard/VmErrorHandler.php SSOT — ensure callable for JIT emit-helper link
lib/JIT/Builtin/ErrorHandlerOutput.php Wire lowering to PHP path
lib/AOT/runtime/phpc_error_handler.c Remove or shrink if still linked (note lines deleted in PR)
Tests Existing error-handler PHPTs + JIT filter

Forbidden: re-implementing handler stack logic in new runtime/*.c.

Done when

  • JIT + AOT repro matches VM output (handled:boom)
  • ErrorHandlerJitRuntime.php reduced to thin ensureLinked() / trampoline (target: >400 LLVM lines removed)
  • ./script/ci-fast.sh --filter ErrorHandler green (VM + JIT smoke)
  • PR body cites php-src path + lists C/LLVM symbols deleted

Related

Activity

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 / JITenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-0:FoundationPhase 0 – foundation & DevExphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions