Skip to content

php-in-php: JIT Builtin\Type.php — shrink ~1.4k-line zval type LLVM monolith via VmValue PHP helpers (#1492) #9976

Closed

Description

@PurHur

Category

php-in-php · JIT lowering migration

Problem

lib/JIT/Builtin/Type.php (~1.4k lines) is the root LLVM type registry for zval/string/object/hashtable lowering. It fans out to Type/Object_.php (~5.8k lines, #9938) and embeds substantial refcount/boxing logic duplicated from VM paths.

Per #1492 PHP-in-PHP strategy: zval type tests, boxing, and coercion should route through shared PHP helpers (VmValue, Variable JIT bridges) with LLVM emitting thin trampolines only.

php-src reference (semantics)

  • php/php-src Zend/zend_types.h — zval layout (reference only)
  • Behavior source of truth: lib/VM.php, lib/Variable.php, existing lib/JIT/Builtin/Type/*.php

Repro (migration metric)

wc -l lib/JIT/Builtin/Type.php lib/JIT/Builtin/Type/*.php
# Before: Type.php ~1419 lines + Object_.php monolith
# After: Type.php <400 lines; heavy paths delegate to PHP helpers

JIT smoke: compile a script using mixed scalar/object compares, property fetches, and array ops — bin/jit.php output matches bin/vm.php.

Scope

Path Work
lib/JIT/Builtin/Type.php Delete inlined zval logic; call VmValue/TypeCheck PHP helpers
lib/JIT/Builtin/Type/Value.php, String_.php, HashTable.php Shrink or merge into PHP
lib/JIT/Builtin/Refcount.php Coordinate with #9570 refcount migration
test/unit/SpaceshipCompareJitHelperTest.php Guard helper routing

Forbidden: growing runtime/*.c with new type tables.

Done when

  • Type.php LLVM surface reduced ≥60% lines (net delete across lib/JIT/Builtin/Type*)
  • VM/JIT/AOT agree on boxed compare + property fetch smoke tests
  • make bootstrap-selfhost-vm-driver-execute-probe green after spine require_once updates
  • PR body lists C symbols / LLVM helpers removed

Related

Activity

  1. added
    enhancementNew feature or request
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 19, 2026
  2. PurHur commented on Jun 25, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Runtime → PHP — batch slice: JitFloatCompare/JitResourceIdString/JitPowNumericOperandGuard → lib/VM/ SSOT (compare operand helpers; Type.php monolith deferred).

  3. PurHur commented on Jun 25, 2026

    @PurHur
    OwnerAuthor

    Merged operand-helper slice via #11663.

    LLVM shrink: JitFloatCompare 88→30, JitResourceIdString 82→21, JitPowNumericOperandGuard 135→20 (trampolines); SSOT in lib/VM/VmFloatCompare.php, VmResourceIdString.php, VmPowNumericOperandGuard.php.

    Verification: JitOperandHelpersRuntimeShrinkTest + nan_relational_compare compliance OK; spine sync + bootstrap-selfhost-vm-driver-execute-probe OK.

    Remaining on #9976: lib/JIT/Builtin/Type.php (~1.4k lines) + Type/* monolith shrink (≥60% target).

  4. PurHur commented on Jun 25, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Runtime → PHP — batch (issues #9976, #9570): VmNumericDivisionGuard, VmEnumNumericOperandGuard, VmUnaryPlus/Minus operand LLVM shrink

  5. PurHur commented on Jun 25, 2026

    @PurHur
    OwnerAuthor

    Merged #11671 — VmNumericDivisionGuard, VmEnumNumericOperandGuard, VmUnaryPlus/Minus + JIT trampolines. Verification: JitOperandHelpersRuntimeShrinkTest (14), division/unary/enum filter (28), bootstrap-selfhost-vm-driver-execute-probe OK.

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 & DevEx

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions