Skip to content

Language: JIT include/require compile-time lowering (#54 follow-up) #475

Description

@PurHur

Category

language

Problem

#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.php on multi-file / __DIR__ graphs can segfault or fall back to runtime TYPE_INCLUDE where IncludeHelper is not wired for the entry script (#1770, #207).

examples/003-MiniWebApp/ needs phpc serve --jit with the same include graph as VM/AOT.

php-src reference

Repro (failure today)

Two-file JIT (create helper then include):

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
  echo "<?php function answer(): int { return 42; }" > /tmp/helper.php
  php bin/jit.php -r "include \"/tmp/helper.php\"; echo answer();"'

Expected (Zend JIT equivalent / VM): 42
Actual (May 2026): segmentation fault in bin/jit.php MCJIT execute path, or LogicException on unresolved TYPE_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)

Area Files
Shared discovery lib/AOT/LiteralIncludeDiscovery.php, lib/Web/LiteralIncludeDiscovery.php
JIT lowering lib/JIT/IncludeHelper.php, lib/JIT.php TYPE_INCLUDE
Compiler lib/Compiler.php — inline literal includes at compile time
Entry bin/jit.php, bin/serve.php — pass project root / deploy path
Tests test/compliance/cases/include_two_file_jit.phpt, #587 gate
Docs docs/capabilities-syntax.md row #475 — set JIT column yes

Dynamic include $variable remains out of scope (document in capabilities).

Done when

Implementation slices

  1. Single literal require 'helper.php' JIT PHPT
  2. __DIR__ paths + IncludeHelper::compileLiteral
  3. phpc serve --jit entry discovery (Web: JIT/AOT mode for bin/serve.php (compile per script on first request) #207)

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter include_two_file'
make test-harness  # optional; prefer targeted filter

Use ./script/docker-exec.sh — bind-mount docker run -v "$(pwd):/compiler" is often empty on Runforge.

Dependencies

Links

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITarea:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions