Skip to content

php-in-php: JIT StringPasswordCryptoJit — route password_hash/verify through VmPassword PHP not ~917-line LLVM (#1492) #9908

Description

@PurHur

Category

php-in-php · stdlib · php-src-strict

Problem

password_hash() / password_verify() / password_get_info() VM semantics live in PHP (ext/standard/VmPassword.php, VmPasswordNative.php libcrypt FFI), but JIT/AOT still emit a ~917-line LLVM module via lib/JIT/Builtin/StringPasswordCryptoJit.php (lib/JIT/Builtin/StringPasswordCrypto.php).

This duplicates bcrypt/argon2 option parsing, salt generation, and verify loops in LLVM — blocks self-host M5 (#1492) and risks VM/JIT drift on PASSWORD_* constants, invalid algo ValueError, and enum-case operands (#6267).

php-src reference

Repro

<?php
$hash = password_hash('secret', PASSWORD_BCRYPT, ['cost' => 4]);
var_export(password_verify('secret', $hash));
echo "\n";
var_export(password_get_info($hash)['algoName'] ?? null);
echo "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro-maintainer/password_hash_smoke.php 2>&1 || php bin/vm.php -r "
\$h = password_hash(\"secret\", PASSWORD_BCRYPT, [\"cost\" => 4]);
var_export(password_verify(\"secret\", \$h)); echo PHP_EOL;
"
php bin/jit.php -r "
\$h = password_hash(\"secret\", PASSWORD_BCRYPT, [\"cost\" => 4]);
var_export(password_verify(\"secret\", \$h)); echo PHP_EOL;
" 2>&1 | head -5
'
Check VM (VmPassword) JIT (StringPasswordCryptoJit)
password_verify true expected must match after migration
Invalid algo ValueError same message (not LogicException)

Scope (PHP-in-PHP first)

Layer Path
PHP SSOT ext/standard/VmPassword.php, PasswordJitHelper.php (extend)
LLVM to shrink lib/JIT/Builtin/StringPasswordCryptoJit.php, StringPasswordCrypto.php
Thin ABI Keep libcrypt FFI in VmPasswordNative.php only — no new runtime/*.c
Tests test/compliance/cases/stdlib/password_hash*.phpt

Done when

  • JIT/AOT password_hash / password_verify / password_get_info call compiled PHP helpers (same as VM)
  • StringPasswordCryptoJit.php LLVM removed or reduced to trampoline; PR cites lines deleted
  • Enum-case / array algo operands TypeError under php-src-strict on VM and JIT
  • ./script/ci-fast.sh --filter password_hash green

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && ./script/ci-fast.sh --filter password_hash'

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-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions