Skip to content

php-in-php: JIT InstanceOfHelper routes dynamic RHS through InstanceOfJitHelper (#10078) - #10609

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-10078-instanceof-jit-helper
Jun 22, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-10078-instanceof-jit-helper

Conversation

@PurHur

@PurHur PurHur commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add lib/VM/InstanceOfJitHelper.php as SSOT for dynamic instanceof RHS guards (jitRhsTypeIsInvalidClass, valueBoxRhsKind).
  • Refactor lib/JIT/InstanceOfHelper.php to call the PHP helper at compile time and route value-box RHS dispatch through JitVmHelperLink (__instanceof__valueBoxRhsKind bridge).
  • Share error message with InstanceOfClassName; add spine + InstanceOfRuntimeShrinkTest guard.

php-src reference

  • Zend/zend_execute.c — ZEND_INSTANCEOF class operand must be string or object

PHP implementation

  • lib/VM/InstanceOfJitHelper.php — type guard SSOT
  • lib/JIT/InstanceOfHelper.php — thin LLVM trampoline + class-id/name matching loops

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && ./vendor/bin/phpunit --filter InstanceOfRuntimeShrinkTest'
# OK (4 tests, 15 assertions)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && ./vendor/bin/phpunit --filter "JITTest::testCases.*instanceof_class_jit|JITTest::testCases.*instanceof_enum"'
# OK (5 tests, 16 assertions)

./script/docker-exec.sh -- bash -lc 'make bootstrap-selfhost-vm-driver-execute-probe'
# bootstrap-selfhost-vm-driver-execute-probe: OK

Closes #10078

Made with Cursor

…HP (#10078).

Move native-type and value-box RHS dispatch from inline LLVM to shared VM PHP helpers with JitVmHelperLink bridges, matching the Coalesce/InOperator shrink pattern.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit c4cff94 into master Jun 22, 2026
@PurHur
PurHur deleted the agent/issue-10078-instanceof-jit-helper branch June 22, 2026 19:59
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 InstanceOfHelper — route instanceof through VmTypeCheck PHP not ~217-line LLVM (#1492)

1 participant