Skip to content

php-in-php: JIT StringHashCrypto — route hash()/hash_hmac() through VmHash PHP not __compiler_hash_* LLVM (#1492) #9164

Description

@PurHur

Category

php-in-php · php-src-strict

Problem

hash(), hash_hmac(), hash_pbkdf2(), and related builtins have VM implementations in ext/standard/VmHash.php, but JIT/AOT link StringHashCryptoJit which lowers to native __compiler_hash_* LLVM helpers (OpenSSL/libcrypto paths in lib/JIT/Builtin/StringHashCrypto.php / StringHashCryptoJit.php).

This duplicates crypto semantics in C/LLVM, blocks M5 self-host shrink (#1492), and risks algorithm/encoding drift vs VM.

php-src reference

Repro

<?php
echo hash('sha256', 'abc'), "\n";
echo hash_hmac('sha256', 'data', 'key'), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php repro.php
php bin/jit.php repro.php
# Compare; JIT today uses __compiler_hash_* not VmHash PHP
'

Scope (this repo)

Layer Work
JIT Route StringHashCrypto / StringHashCryptoJit through compiled VmHash helpers (mirror StringFormatJit → VmSprintf pattern)
AOT Same
C shrink Remove unused __compiler_hash_* LLVM emitters when PHP path covers all algorithms in matrix
Tests JIT rows on existing test/compliance/cases/stdlib/hash*.phpt

Done when

  • JIT/AOT hash() / hash_hmac() match VM on compliance PHPTs (incl. invalid algo ValueError)
  • PR body cites php-src paths + PHP implementation location; notes C symbols deleted
  • No regression on hash_equals() / hash_hmac_algos() (may share helper module)

Ref: #1492 · #7189

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 apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions