Skip to content

php-in-php: JIT SpaceshipCompareJit — route <=> through CompareJitHelper PHP not ~1.2k-line LLVM (#1492) #9476

Description

@PurHur

Category

php-in-php · language · compile-pipeline migration (#1492)

Problem

<=> (spaceship) lowering for JIT/AOT lives in lib/JIT/Builtin/SpaceshipCompareJit.php (~1,190 lines of LLVM type dispatch, hashtable walks, object compares). Scalar semantics already have a PHP SSOT in lib/VM/CompareJitHelper.php via SpaceshipRuntime, but object/hashtable paths remain duplicated in LLVM.

This blocks shrinking the JIT emit surface and keeps compare edge cases (enum objects, NAN, arrays) divergent from VM — see #9288 (enum <=> order regression).

php-src reference

Repro (behavior anchor — enum order)

test/repro/enum_relational.php:

<?php
enum E: int { case A = 1; case B = 2; }
var_export(E::A <=> E::B);
./script/docker-exec.sh -- php bin/vm.php test/repro/enum_relational.php   # today: -1 (wrong)
./script/docker-exec.sh -- php test/repro/enum_relational.php                # Zend: 1

Migration done-when is JIT calls PHP helper; enum ordering fix may land here or via #9288 — both must be green before close.

Scope (this repo)

Layer Path
LLVM today lib/JIT/Builtin/SpaceshipCompareJit.php, lib/JIT/Builtin/SpaceshipRuntime.php
PHP SSOT lib/VM/CompareJitHelper.php, shared with VM <=>
Delete/shrink Remove scalar/object compare LLVM once MCJIT/AOT route through PHP trampoline
Tests Existing spaceship compliance + enum_relational.php guard

Done when

  • JIT/AOT <=> on scalars/enums/arrays/objects calls CompareJitHelper (or thin LLVM trampoline only)
  • SpaceshipCompareJit.php reduced to link stubs or deleted; no duplicated compare tables in LLVM
  • ./script/ci-fast.sh --filter Spaceship green; enum relational repro matches Zend
  • PR notes lines removed from SpaceshipCompareJit.php (target: majority of ~1.2k LLVM)

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