Skip to content

php-in-php: JIT NullsafeHelper — route ?-> LLVM through VmNullsafe PHP not ~96-line monolith (#1492) #10154

Description

@PurHur

Category

php-in-php · runtime

Problem

Nullsafe property/method access ($obj?->prop, $obj?->m()) lowers through lib/JIT/NullsafeHelper.php (~96 lines LLVM) duplicating short-circuit semantics already expressible in VM PHP. Per #1492 PHP-in-PHP strategy, JIT should compileUnit() a PHP helper and keep LLVM as a thin trampoline — shrink parallel LLVM maintenance.

php-src reference

  • php/php-src Zend/zend_compile.c — nullsafe opcodes (ZEND_JMP_NULL chain)
  • VM SSOT: lib/VM/Nullsafe.php (or equivalent nullsafe dispatch used by bin/vm.php)

Repro (migration metric)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
wc -l lib/JIT/NullsafeHelper.php
grep -c "function " lib/JIT/NullsafeHelper.php
php bin/jit.php -r "
class C { public function f(): int { return 42; } }
\$c = null;
var_dump(\$c?->f());
\$c = new C();
var_dump(\$c?->f());
" 2>/dev/null
'

Today: LLVM bodies in NullsafeHelper.php; post-migration should delegate to compiled PHP like #10078 InstanceOfHelper bridge pattern.

Scope (this repo)

Path Work
lib/JIT/NullsafeHelper.php Replace LLVM short-circuit with compileUnit() of PHP helper
lib/VM/Nullsafe.php (or new NullsafeJitHelper.php) SSOT semantics shared with VM
lib/JIT/Builtin/Type.php Trampoline registration
Tests Existing nullsafe JIT compliance PHPTs stay green

Forbidden: growing runtime/*.c for nullsafe — PHP lowering only.

Done when

  • NullsafeHelper.php LLVM line count drops to trampolines + ABI glue (target ≥50% reduction)
  • JIT nullsafe repro matches VM on property + method chains
  • ./script/ci-fast.sh green; no new C symbols in runtime/

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