JIT: stub external Class::method for self-host bundle (Fixes #579) - #583
Merged
Conversation
Option A: lazily register ExternalMethod proxies that return null instead of failing JIT on vendor APIs (PhpParser NodeTraverser::addVisitor, etc.). Register unknown class names for `new` and static dispatch; add lint smoke test and bootstrap-selfhost-link progress gate script. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements Option A from #579: at JIT compile time, undefined
Class::methodand staticClass::methoddispatches are bound toJIT\Call\ExternalMethodstubs instead of aborting.Context::resolveFunctionProxy()lazily registersExternalMethod, which records the proxy name inContext::$externalMethodStubsand emits LLVM that returns null (__value__writeNull). No Zend/vendor code runs in the native binary.Object_::lookup()registers unknown class names (e.g.ReflectionClass,PhpParser\NodeTraverser) sonewandinstanceoflowering can proceed.TYPE_STATICCALL_INITnow uses the same proxy path as instance calls (master already calledresolveFunctionProxyfor instance calls but the implementation was missing).Progress (Docker
php-compiler:22.04-dev)Call to undefined method phpparser\nodetraverser::addvisitor(and similar)IteratorHelper/__value__literals (separate issues)php bin/compile.php -l test/bootstrap-aot/external_method_stub.phppasses.Stubbed vs implemented
Class::methodwithout a compiledTYPE_DECLARE_METHODbodyphpcompiler\…methods with CFG in the bundleCall\Nativeproxies)is_string, VM context, …)Runtime introspection: after a successful link,
JIT\Context::$externalMethodStubslists proxy names touched during codegen (e.g.phpparser\nodetraverser::addvisitor).Test plan
phpunit test/unit/JitExternalMethodStubTest.php(Docker)php bin/compile.php -l test/bootstrap-aot/external_method_stub.php./script/bootstrap-selfhost-link.sh(still fails past IteratorHelper; progress gate only)Fixes #579
Made with Cursor