Skip to content

JIT: Per-run superglobal refresh for bin/jit.php (-q/-p between invocations) #642

@PurHur

Description

@PurHur

Problem

#201 ✅ closed AOT per-request superglobal refresh via lib/AOT/runtime/superglobals_refresh.c. #49 remains open for the JIT path: lib/JIT/SuperglobalInit.php still bakes sg_GET / sg_POST at compile/init time when env changes between runs of the same JIT artifact.

bin/jit.php with different -q / -p on back-to-back invocations can return stale $_GET / $_POST unless the VM pre-populates and JIT re-reads.

Goal

JIT standalone runs match VM behavior: each process invocation refreshes superglobals from QUERY_STRING, REQUEST_BODY, and related CGI env before user code.

Implementation hints

Area Files
Init hook lib/JIT/SuperglobalInit.php — call refresh before main
Env parse Reuse lib/Web/Superglobals.php from VM (port or FFI)
CLI bin/jit.php — pass -q/-p into env map each run
Tests Extend test/unit/RuntimeSuperglobalRefreshTest.php or new @group llvm JIT PHPT

Acceptance criteria

php bin/jit.php -q 'name=Alice' examples/001-SimpleWeb/example.php | grep Alice
php bin/jit.php -q 'name=Bob' examples/001-SimpleWeb/example.php | grep Bob

No recompile between runs; outputs differ.

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

Dependencies

Verification

Local/Docker only — do not require .github/workflows/*.

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