Skip to content

Hash AOT: defer nested hash_algos/hash_equals on user-script standalone (#3357)#18717

Closed
PurHur wants to merge 1 commit into
masterfrom
agent/issue-3357-hash-aot-standalone
Closed

Hash AOT: defer nested hash_algos/hash_equals on user-script standalone (#3357)#18717
PurHur wants to merge 1 commit into
masterfrom
agent/issue-3357-hash-aot-standalone

Conversation

@PurHur

@PurHur PurHur commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

Prepare user-script standalone AOT hash init for #3357 by avoiding nested PHP JIT helpers that emit invalid __hashtable__ bridge IR during minimal standalone init.

  • StringHashAlgos: when UserScriptAotDeferNestedJit → inline HashAlgosRegistry LLVM (same pattern as StringHashHmacAlgos)
  • StringHashCryptoJit: when deferring → StringHashCryptoLlvm EVP path + stub __compiler_hash_equals (skip nested HashEqualsJitHelper)

php-src ref: ext/hash/hash.c

Blocker (master)

User-script AOT compile currently fails LLVM module verify for all scripts (including echo "hi";), not only hash:

Module verification failed: Call parameter type does not match function signature!
call void @__value__writeHashtable(%__value__* %18, %__value__* %1)  ; expects __hashtable__*

Disabling StringHashCrypto::ensureStandaloneBodies in Context::ensureMinimalUserStandaloneBodies does not unblock — separate master regression needs bisect before merge.

Verification

# VM — green
./script/phpunit.sh --filter 'HashModuleTest|hash_context_incremental'

# AOT — red (master regression)
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/compile.php -o /tmp/h -r "echo hash(\"sha256\",\"hello\"),\"\n\";"'
./script/phpunit.sh --filter 'AotTest.*hash_context_incremental'

Closes #3357 when master AOT verify is green and hash fixtures pass.

Made with Cursor

…ne (#3357)

Use inline HashAlgosRegistry LLVM and stub __compiler_hash_equals during
user-script standalone init instead of nested HashAlgosJitHelper / HashEquals
lowering that emits invalid __hashtable__ bridge IR.

php-src: ext/hash/hash.c
Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur

PurHur commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

Maintainer verify (2026-07-13): not merge-ready on current branch.

Master now has #18726 — standalone hash AOT compile+run is green (hash('sha256','hello')2cf24dba…). This branch still hits LLVM module verify (__value__writeHashtable / writeNull type mismatch) on the same one-liner, likely because it predates the GC regression fix.

Next: rebase onto current master, re-run hash AOT fixtures + HashModuleTest, then request re-review.

@PurHur

PurHur commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

claim: PHP Runtime → PHP — continuing hash standalone defer on fresh branch from master (PR #18717 branch is stale vs master).

PurHur added a commit that referenced this pull request Jul 13, 2026
…s JIT (#18717) (#18770)

* Hash AOT: defer nested hash_algos/hash_equals on user-script standalone (#3357)

Use inline HashAlgosRegistry LLVM and stub __compiler_hash_equals during
user-script standalone init instead of nested HashAlgosJitHelper / HashEquals
lowering that emits invalid __hashtable__ bridge IR.

php-src: ext/hash/hash.c
Co-authored-by: Cursor <cursoragent@cursor.com>

* php-in-php: hash standalone defer — skip nested hash_algos/hash_equals JIT (#18717)

User-script standalone AOT uses inline HashAlgosRegistry LLVM and a thin
hash_equals stub instead of nested helpers that emit invalid __hashtable__
bridge IR during minimal init. Embed path still routes through
HashAlgosJitHelper / HashEqualsJitHelper PHP.

Verification:
- vendor/bin/phpunit test/unit/StringHashAlgosRuntimeShrinkTest.php
- vendor/bin/phpunit test/unit/StringHashCryptoRuntimeShrinkTest.php
- vendor/bin/phpunit test/unit/JIT/StringHashCryptoRuntimeStandaloneTest.php
- make bootstrap-selfhost-vm-driver-execute-probe

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: PurHur <PurHur@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur

PurHur commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

Merged via #18770 (fresh branch agent/runtime-php-hash-aot-defer rebased on master — stale #18717 branch had 185-file drift).

PHP-in-PHP / LLVM shrink:

  • StringHashCryptoJit::implementDeferred() — standalone user-script init uses StringHashCryptoLlvm + inline hash_algos registry + hash_equals stub; skips nested HashAlgosJitHelper / HashEqualsJitHelper that emitted invalid __hashtable__ bridge IR.
  • Embed path unchanged: HashAlgosJitHelper / HashEqualsJitHelper / HashCryptoJitHelper PHP.

Verification:

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit test/unit/StringHashAlgosRuntimeShrinkTest.php test/unit/StringHashCryptoRuntimeShrinkTest.php test/unit/JIT/StringHashCryptoRuntimeStandaloneTest.php'
# OK (6 tests)
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter "HashModuleTest|hash_context_incremental"'
# OK (12 tests)
make bootstrap-selfhost-vm-driver-execute-probe
# OK

Follow-up: separate master __value__writeHashtable module-verify regression for generic user-script AOT (echo "hi") remains — file fresh issue if still red after this merge.

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.

Stdlib: hash_init() / hash_update() / hash_final() / hash_copy() — incremental ext/hash API

1 participant