forked from ircmaxell/php-compiler
-
Notifications
You must be signed in to change notification settings - Fork 1
Language: JIT include/require compile-time lowering (#54 follow-up) #475
Copy link
Copy link
Closed
Labels
area:compilerCompiler / CFG / JITCompiler / CFG / JITarea:vmVirtual machineVirtual machineenhancementNew feature or requestNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimSpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language featuresPhase 2 – language features
Description
Activity
Metadata
Metadata
Assignees
Labels
area:compilerCompiler / CFG / JITCompiler / CFG / JITarea:vmVirtual machineVirtual machineenhancementNew feature or requestNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimSpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language featuresPhase 2 – language features
Category
languageProblem
#54 closed with AOT literal-path bundling (
lib/AOT/LiteralIncludeDiscovery.php,lib/AOT/SourceBundler.php). VM and AOT compile static includes. JIT execute path remains fragile:bin/jit.phpon multi-file /__DIR__graphs can segfault or fall back to runtimeTYPE_INCLUDEwhereIncludeHelperis not wired for the entry script (#1770, #207).examples/003-MiniWebApp/needsphpc serve --jitwith the same include graph as VM/AOT.php-src reference
Zend/zend_compile.c—zend_compile_include_or_eval,zend_compile_requireZend/zend_execute.c—zend_include_or_eval,zend_execute_scriptsZend/zend_builtin_functions.c—compile_filehook forinclude/require_oncededup (Language: require_once and include_once deduplication #120)Repro (failure today)
Two-file JIT (create helper then include):
Expected (Zend JIT equivalent / VM):
42Actual (May 2026): segmentation fault in
bin/jit.phpMCJIT execute path, orLogicExceptionon unresolvedTYPE_INCLUDE.MiniWebApp gate (when OOP green):
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/jit.php examples/003-MiniWebApp/public/index.php'Scope (this repo)
lib/AOT/LiteralIncludeDiscovery.php,lib/Web/LiteralIncludeDiscovery.phplib/JIT/IncludeHelper.php,lib/JIT.phpTYPE_INCLUDElib/Compiler.php— inline literal includes at compile timebin/jit.php,bin/serve.php— pass project root / deploy pathtest/compliance/cases/include_two_file_jit.phpt, #587 gatedocs/capabilities-syntax.mdrow #475 — set JIT column yesDynamic
include $variableremains out of scope (document in capabilities).Done when
42underbin/jit.phpwithout segfault__DIR__ . '/file.php'concat paths work (pairs Language: VM/JIT runtime __DIR__/__FILE__ on include stack (#85) #707)require_oncededup matches VM (Language: require_once and include_once deduplication #120)MINIWEBAPP_JIT_PROJECT_GATE/ Testing: JIT smoke for phpc build --project on 003-MiniWebApp #587 opt-in green on harnessthrow new LogicException('include/require must be resolved before AOT compile')for static paths in JITImplementation slices
require 'helper.php'JIT PHPT__DIR__paths +IncludeHelper::compileLiteralphpc serve --jitentry discovery (Web: JIT/AOT mode for bin/serve.php (compile per script on first request) #207)Verification
Use
./script/docker-exec.sh— bind-mountdocker run -v "$(pwd):/compiler"is often empty on Runforge.Dependencies
__DIR__require_oncetableLinks