Skip to content

Hash: scaffold standalone AOT __compiler_hash bridges (#3357)#17897

Open
PurHur wants to merge 3 commits into
masterfrom
agent/issue-3357-hash-aot-digest
Open

Hash: scaffold standalone AOT __compiler_hash bridges (#3357)#17897
PurHur wants to merge 3 commits into
masterfrom
agent/issue-3357-hash-aot-digest

Conversation

@PurHur

@PurHur PurHur commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

Scaffolds the missing standalone-AOT path for hash() / hash_hmac() / incremental hash_final() digest emission (#3357).

Root cause (diagnosed): __compiler_hash ABI stubs from lib/JIT/Builtin/Type.php never received bodies during PHP_COMPILER_AOT_USER_SCRIPT=1 init because StringHashCrypto was absent from ensureMinimalUserStandaloneBodies() and nested HashCryptoJitHelper JIT is deferred for user-script AOT (#16734).

Changes

  • StringHashCryptoLlvm — thin JitVmHelperLink::ensureBridge wrappers for __compiler_hash* ABIs
  • StringHashCryptoJitUserScriptAotDeferNestedJit gate → LLVM bridges vs PHP helper path
  • Context::ensureMinimalUserStandaloneBodies() — link hash crypto during user-script standalone init
  • StringHashCryptoPhp::callHelperBridgeextractStringPtrFromHelperResult for non-defer builds

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

Verification (2026-07-11)

# VM/JIT — green (unchanged)
php bin/vm.php test/repro/hash_context_incremental.php
php bin/jit.php test/repro/hash_context_incremental.php
./script/phpunit.sh --filter HashModuleTest

# AOT — still red (empty digest stdout; no longer segfaults on hash_context)
tmpdir=$(mktemp -d)
php bin/compile.php -o "$tmpdir/h" -r 'echo hash("sha256","hello"),"\n";'
"$tmpdir/h"   # prints blank line (expected 2cf24dba…)
./script/phpunit.sh --filter 'AotTest.*hash_raw_output'   # FAIL: bin2hex(hash(...)) empty
./script/phpunit.sh --filter 'AotTest.*hash_context_incremental'  # FAIL: empty stdout (exit 0)

Next step: JitVmHelperLink bridge calls cached HashCryptoJitHelper unit but coerceBridgeResult / helper link returns null __string__* at execute. Bisect helper .o link + bridge return coercion (restored pre-#9164 StringHashCryptoNativeJit emits wrong digests and segfaults on hash_context).

Partial progress toward #3357 — not merge-ready.

Closes #3357 when hash_raw_output + hash_context_incremental AOT fixtures green.

Made with Cursor

Wire StringHashCrypto into user-script minimal standalone init and route
PHP_COMPILER_AOT_USER_SCRIPT builds through JitVmHelperLink bridges instead
of nested HashCryptoJitHelper JIT during user compile.

Remaining: helper bridge returns null digest at AOT execute — hash_raw_output
and hash_context_incremental fixtures still empty (VM/JIT green).

Co-authored-by: Cursor <cursoragent@cursor.com>
…ers (#3357)

Stop using JitVmHelperLink cached-unit bridges for user-script AOT (unit __init__
skipped under #16075). Detect PHP bridge entry blocks by name so stale LLVM
bridge stubs are not treated as complete.

AOT hash_raw_output still red — __compiler_hash returns null at execute; next step
is replacing orphan LLVM entry blocks or a thin libc digest path.

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

PurHur commented Jul 11, 2026

Copy link
Copy Markdown
Owner Author

Progress update (2026-07-11):

Still red:

./script/phpunit.sh --filter 'hash_raw_output|hash_context_incremental'
# hash_raw_output: 0/0 (hash returns false)
# hash_context_incremental: empty stdout

Likely next step: when a stale hash_crypto_llvm_* block remains as LLVM function entry, appendBasicBlock() does not replace it — need entry-block reuse (cf. JitVmHelperLink::bridgeEntryForEmit) or a StringHashCryptoLibc-style thin digest path for user AOT like StringFileGetContentsLibc (#15309).

Delegate digest helpers to VmHashNative directly (php-src ext/hash parity).
Document AOT blocker: nested JIT of HashCryptoJitHelper emits null digest
because VmHashNative::hash is not lowered; VmHashNative precompile segfaults LLVM.

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

PurHur commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Maintainer triage 2026-07-12: not merge-ready — PR body documents AOT digest still empty (hash_raw_output / hash_context_incremental red). Bootstrap gates green on main (bootstrap-selfhost-link + helloworld). Please rebase (mergeable: CONFLICTING) and keep WIP until AOT fixtures green per Closes #3357 criteria.

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