Skip to content

Stdlib: parse_url() JIT and AOT (routing in compiled binaries) #313

@PurHur

Description

@PurHur

Problem

parse_url() works in the VM (ext/standard/parse_url.php, compliance PHPT) and is used internally by lib/Web/DevServer.php and Superglobals::derivePathInfo(). JIT throws LogicException; AOT is unsupported (docs/capabilities.md: VM only).

Front-controller routing (#210, #276) in compiled binaries needs URL parsing without calling host PHP:

$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);

Goal

JIT and AOT fast paths for the existing VM subset:

  • One- and two-argument forms
  • Components: PHP_URL_PATH, PHP_URL_QUERY, PHP_URL_HOST, PHP_URL_PORT, PHP_URL_SCHEME
  • Full array return for http:// / https:// URLs and path-only strings like /app?q=1

Implementation hints

  1. Reuse logic from ext/standard/VmString.php (parseUrlPath, host/port split) — avoid duplicating RFC 3986; match VM outputs exactly.
  2. ext/standard/parse_url.php — implement compileJIT() / wire through Internal base like strlen.
  3. Add JIT compliance case if not already covered; AOT PHPT under test/fixtures/aot/cases/parse_url.phpt.
  4. Register in docs/capabilities.md with --check gate in script/ci-local.sh.

Acceptance criteria

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

JIT compliance and AOT PHPT pass; capability matrix shows JIT/AOT yes.

Verification (local / Docker only)

make test-docker
# or:
./script/docker-ci-local.sh

Dependencies

Links

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions