Skip to content

php-in-php: route hash()/hash_hmac() JIT through VmHash PHP (#9164) - #10972

Merged
PurHur merged 1 commit into
masterfrom
agent/runtime-php-hash-crypto-9164
Jun 23, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/runtime-php-hash-crypto-9164

Conversation

@PurHur

@PurHur PurHur commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add HashCryptoJitHelper delegating to VmHash for hash(), hash_hmac(), hash_pbkdf2(), hash_hkdf()
  • Replace StringHashCryptoNativeJit (~2857 lines LLVM digest monolith) with thin StringHashCryptoPhp bridges (mirrors StringHashEquals / HashEqualsJitHelper pattern from php-in-php: route JIT hash_equals through HashEqualsJitHelper PHP (#9164) #10922)
  • LLVM shrink: deleted lib/JIT/Builtin/StringHashCryptoNativeJit.php (2857 lines)

php-src reference

  • ext/standard/hash.c — PHP_FUNCTION(hash)
  • ext/standard/hash_hmac.c — hash_hmac
  • PHP SSOT: ext/standard/VmHash.php, ext/standard/HashCryptoJitHelper.php

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php vendor/bin/phpunit test/unit/StringHashCryptoRuntimeShrinkTest.php
php vendor/bin/phpunit test/unit/JIT/StringHashCryptoRuntimeStandaloneTest.php
php vendor/bin/phpunit test/unit/RuntimeShrinkCloseoutTest.php
php vendor/bin/phpunit --filter "hash_hmac_jit|hash_pbkdf2_jit|hash_hkdf_jit|hash_equals_jit|hash_raw_output_jit" test/compliance/JITTest.php
php script/check-selfhost-spine-coverage-sync.php
printf "%s\n" "<?php" "echo hash(\"sha256\", \"abc\"), \"\\n\";" "echo hash_hmac(\"sha256\", \"data\", \"key\"), \"\\n\";" > /tmp/repro.php
php bin/vm.php /tmp/repro.php
php bin/jit.php /tmp/repro.php
'

Output:

OK (4 tests, 15 assertions)          # StringHashCryptoRuntimeShrinkTest
OK (2 tests, 30 assertions)        # StringHashCryptoRuntimeStandaloneTest
OK (3 tests, 62 assertions)        # RuntimeShrinkCloseoutTest
OK (5 tests, 5 assertions)         # JIT compliance hash PHPTs
check-selfhost-spine-coverage-sync: OK (spine covers all 2959 inventory files)
VM/JIT repro:
ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
5031fe3d989c6d1537a013fa6e739da23463fdaec3b70137d828e36ace221bd0

Closes #9164

Made with Cursor

Replace ~2857-line StringHashCryptoNativeJit LLVM monolith with thin
HashCryptoJitHelper → VmHash bridges; hash_equals already migrated in #10922.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant