Skip to content

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

@PurHur

Description

@PurHur

Problem

#54 closed with AOT literal-path bundling via LiteralIncludeDiscovery + SourceBundler in bin/compile.php. JIT still throws on OpCode::TYPE_INCLUDE:

// lib/JIT.php — TYPE_INCLUDE
throw new \LogicException('include/require must be resolved before AOT compile …');

examples/003-MiniWebApp/ needs multi-file execution in all three modes (VM ✅, AOT bundle ✅, JIT ❌). phpc serve JIT mode (#207) and compliance JIT tests for two-file apps remain blocked.

Goal

include / require with static path expressions (__DIR__ . '/file.php', string literal) compile in JIT the same way AOT bundles them today — no runtime TYPE_INCLUDE in generated LLVM for v1.

Dynamic include $path stays out of scope (document in docs/capabilities.md).

Implementation hints

Approach Files Notes
Reuse bundler lib/AOT/LiteralIncludeDiscovery.php, SourceBundler Share discovery from entry / current function
JIT compile lib/JIT.php Lower bundled units as nested functions or inlined blocks
Compiler lib/Compiler.php Optionally replace TYPE_INCLUDE with bundled symbol refs at compile time
Once #120 Dedup table at JIT module scope
Tests test/compliance/cases/include_two_file_jit.phpt Mirror VM two-file fixture

Acceptance criteria

docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \
  php bin/jit.php examples/003-MiniWebApp/public/index.php

Does not throw on TYPE_INCLUDE (may still fail on #58/#145 until OOP lands).

docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \
  ./script/ci-local.sh --filter include_two_file

Verification (local / Docker only)

make test-docker

No GitHub Actions required.

Dependencies

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions