Skip to content

JIT: Dynamic hashtable read/write for $_GET[$key] and $_POST[$key] #86

Description

@PurHur

Problem

JIT/AOT already fold literal superglobal access:

  • $_GET['name'] → compile-time string (SuperglobalInit::compileTimeReadString)
  • isset($_GET['name']) → constant fold when key is literal

Real apps use dynamic keys:

$key = 'page';
$page = $_GET[$key];
if (isset($_POST[$field])) { ... }

IssetHelper and array-dim lowering must call __hashtable__ runtime lookups when the offset is not a compile-time literal.

Goal

Runtime hashtable get/set/isset for superglobals (and general __hashtable__) with non-constant keys in JIT/AOT.

Tasks

  • Extend HashTableHelper with dynamic string key load/store
  • Wire ArrayDimFetch in lib/JIT.php for TYPE_HASHTABLE containers
  • IssetHelper::compileHashTableOffsetIsSet — dynamic key path (not only compileTimeOffsetIsSet)
  • Depends on Web: Runtime-populated superglobals for JIT and AOT (per-request $_GET/$_POST) #49: tables must be populated per request before reads
  • PHPT: $_GET[$k] with $k from variable; two requests, different output
  • Type errors for non-string keys (match PHP subset documented)

Acceptance criteria

foreach (['a', 'b'] as $k) {
    if (isset($_GET[$k])) echo $_GET[$k];
}

Compiles in JIT; correct output when superglobals refreshed per request.

Key files

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

Related

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