Skip to content

php-in-php: JIT CoalesceHelper — route ?? operator LLVM through VmCoalesce PHP not inline LLVM (#1492) #10171

Description

@PurHur

Category

php-in-php · compile/runtime shared

Problem

lib/JIT/CoalesceHelper.php lowers the ?? null coalescing operator in LLVM with inline null/unset probes. VM path implements full php-src semantics in PHP (lib/VM.php). Duplicated logic drifts on edge cases (undefined variables, property hooks, ArrayAccess offsets).

Per #1492, coalesce behavior belongs in lib/VM/ with JIT as thin trampoline — same pattern as #10046 (CastHelper) and #10154 (NullsafeHelper).

php-src reference

Repro (architectural)

<?php
$x = null;
echo $x ?? 5, "\n";
echo ($undefined ?? 'd'), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php'
wc -l lib/JIT/CoalesceHelper.php

Scope (this repo)

Layer Path
Extract VM lib/VM/VmCoalesce.php (new) — shared ?? semantics
JIT shrink lib/JIT/CoalesceHelper.php → trampoline
Tests test/compliance/cases/language/coalesce*.phpt

Done when

  • CoalesceHelper.php shrinks to trampoline + types (target ≥50% line reduction vs current ~46 LLVM body + call sites)
  • VM/JIT/AOT agree on repro + existing coalesce compliance tests (php-src-strict)
  • ./script/ci-fast.sh --filter coalesce green

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