Skip to content

php-in-php: JIT ErrorRaise + TypeErrorRaise — route catchable Error/TypeError through VmException PHP not ~920-line LLVM (#1492) #9778

Description

@PurHur

Category

php-in-php · #1492 self-host / shrink C+LLVM runtime

Problem

Catchable Error and TypeError throw paths in JIT/AOT are implemented as large LLVM modules:

  • lib/JIT/Builtin/ErrorRaise.php (~389 lines)
  • lib/JIT/Builtin/TypeErrorRaise.php (~531 lines)

lib/JIT/ErrorBridge.php and lib/JIT/ExceptionBridge.php note these replaced deleted lib/AOT/runtime/phpc_error_raise.c / phpc_type_error_raise.c, but the replacement is still LLVM-first, not compiled PHP semantics.

VM already materializes Error / TypeError in lib/VM/ — JIT should call the same helpers as ExceptionThrowRuntime migration (#9679) and TryCatchHelper (#9663).

php-src reference

Repro (LLVM bodies present)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
wc -l lib/JIT/Builtin/ErrorRaise.php lib/JIT/Builtin/TypeErrorRaise.php
php bin/jit.php -r "
class C { public readonly int \$x; }
try { (new C(1))->x = 2; } catch (Error \$e) { echo get_class(\$e), \"\\n\"; }
" 2>&1 | head -5
'

Readonly guard currently routes through ReadonlyBridge / ErrorRaise::emitRaise LLVM, not VmException PHP.

Scope (this repo)

Shrink LLVM Grow PHP
ErrorRaise.php, TypeErrorRaise.php message/unwind IR lib/VM/VmException.php or shared VmErrorThrow.php helper
lib/JIT/ErrorBridge.php, lib/JIT/ExceptionBridge.php indirection lib/JIT/Builtin/ExceptionThrowRuntime.php pattern — compiled throw helper
Call sites: ListUnpackHelper, PropertyHookDispatch, StringFormatJit, … Single SSOT for pending-error buffer semantics (#5373)

Do not grow runtime/*.c. Delete LLVM table branches when PHP path is linked.

Done when

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter ReadonlyPropertyWrite'
make bootstrap-selfhost-vm-driver-execute-probe

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-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions