Skip to content

Web: Dynamic isset/empty on $_GET and $_POST keys in JIT #70

Description

@PurHur

Problem

IssetHelper optimizes isset($_GET['key']) via SuperglobalInit::compileTimeOffsetIsSet when the key is a string literal. Non-literal keys and runtime-populated superglobals need LLVM hashtable offsetIsSet calls.

Errors today:

  • isset() on superglobals only supports a string literal key in this compiler build

VM tests (web_isset_get.phpt) pass; JIT compliance may differ.

Goal

isset($_GET[$param]) and empty($_GET['missing']) work when superglobals are runtime-filled.

Tasks

  • JIT: __hashtable__offsetIsSet for sg_GET / sg_POST globals
  • empty() lowering consistent with isset
  • Remove or gate compile-time-only fast path behind optimization flag
  • PHPT under test/compliance for JIT mode

Depends on

Files

  • lib/JIT/IssetHelper.php
  • lib/JIT/SuperglobalInit.php

Implementation hints (May 2026)

JIT slice is tracked in #1901 — implement dynamic-key isset there; keep #70 as the literal-key / VM compliance umbrella or close when #1901 lands.

Layer Files Notes
Literal fast path lib/JIT/SuperglobalInit.php compileTimeOffsetIsSet when key is string literal
Dynamic JIT lib/JIT/Builtin/IssetHelper.php Non-literal → __hashtable__offsetIsSet on sg_GET / sg_POST (#1901)
Empty lib/JIT.php empty() must match isset semantics for runtime-filled tables
VM test/compliance/cases/web/web_isset_get.phpt Already green
AOT test/aot/JitSuperglobalRefreshTest.php Extend for dynamic key after JIT fix

Suggested PHPT (JIT)

Verification (local / Docker only)

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

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions