Skip to content

php-in-php: JIT ScalarDimFetchHelper — route scalar dim fetch warnings through Vm PHP not LLVM (#1492) #10271

Description

@PurHur

Category

php-in-php · php-src-strict · compile/runtime shared

Problem

lib/JIT/ScalarDimFetchHelper.php (~44 lines) emits inline LLVM that calls __compiler_trigger_error with hard-coded warning strings for ZEND_FETCH_DIM_R on scalar containers (int/float/string/bool/null). VM implements the same guard in PHP with shared message text (#4867).

Duplicated LLVM warning paths drift from php-src and block shrinking the JIT error layer toward compiled PHP helpers (#9778, #9679).

php-src reference

Repro (LLVM path today)

<?php
$x = 42;
var_export($x[0]);
echo "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php -r "\$x=42; var_export(\$x[0]); echo \"\\n\";" 2>&1 | head -3
php bin/vm.php -r "\$x=42; var_export(\$x[0]); echo \"\\n\";" 2>&1 | head -3
php bin/jit.php -r "\$x=42; var_export(\$x[0]); echo \"\\n\";" 2>&1 | head -5
wc -l lib/JIT/ScalarDimFetchHelper.php
'

Expected: Warning Trying to access array offset on value of type int + NULL on VM/JIT/AOT (php-src-strict).

Scope (this repo)

Shrink LLVM Grow PHP
lib/JIT/ScalarDimFetchHelper.php emitArrayOffsetWarning() IR Shared VM helper (e.g. extend lib/VM/ErrorReporter.php or dim-fetch module)
__compiler_trigger_error calls from dim fetch Thin JIT trampoline calling compiled PHP warning+null helper
Call sites in lib/JIT.php scalar dim read lowering VM/JIT/AOT message text SSOT

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

Done when

  • Scalar dim fetch on int/float/string/bool/null uses compiled PHP helper on JIT and AOT standalone
  • Warning message text matches Zend for representative types (php-src-strict)
  • ScalarDimFetchHelper.php shrinks to thin trampoline; PR cites lines removed
  • ./script/ci-fast.sh --filter ScalarDim or existing dim-fetch compliance subset green

Verification

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

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