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
Related
Category
php-in-php·stdlibProblem
JIT/AOT link currently emits ~556 lines of hand-written LLVM in
lib/JIT/Builtin/ErrorHandlerJitRuntime.phpforset_error_handler()/restore_error_handler()/ dispatch — duplicating semantics already implemented in PHP atext/standard/VmErrorHandler.php(235 lines, php-srcbasic_functions.cparity).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
ext/standard/basic_functions.c—PHP_FUNCTION(set_error_handler),restore_error_handlerZend/zend_errors.c— user error handler stackRepro (parity must hold after migration)
VM baseline already green; JIT/AOT must match after deleting LLVM stack logic.
Scope (this repo)
lib/JIT/Builtin/ErrorHandlerJitRuntime.phpVmErrorHandlervia JIT builtin callext/standard/VmErrorHandler.phplib/JIT/Builtin/ErrorHandlerOutput.phplib/AOT/runtime/phpc_error_handler.cForbidden: re-implementing handler stack logic in new
runtime/*.c.Done when
handled:boom)ErrorHandlerJitRuntime.phpreduced to thinensureLinked()/ trampoline (target: >400 LLVM lines removed)./script/ci-fast.sh --filter ErrorHandlergreen (VM + JIT smoke)Related