Skip to content

php-in-php: JIT StringHttpBuildQuery — route http_build_query() through VmHttpBuildQuery PHP not ~380-line LLVM (#1492) #9443

Description

@PurHur

Category

php-in-php · php-src-strict

Problem

http_build_query() VM handler (ext/standard/http_build_query.php) already builds query strings via VmHttpBuildQuery. JIT/AOT still emit a separate lib/JIT/Builtin/StringHttpBuildQuery.php LLVM walker (__compiler_http_build_query, ~381 lines) that re-implements nesting, PHP_QUERY_RFC1738/RFC3986, and bracket encoding.

Enum encoding parity is tracked in #8733; this issue is the LLVM duplication migration so JIT fixes land once in PHP.

php-src reference

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php -r "
\$data = [\"a\" => 1, \"b\" => [\"c\" => 2, \"d\" => 3]];
echo http_build_query(\$data), PHP_EOL;
echo http_build_query(\$data, \"\", \"&\", PHP_QUERY_RFC3986), PHP_EOL;
"'

# Inspect JIT still uses LLVM today:
rg "__compiler_http_build_query" lib/JIT/Builtin/StringHttpBuildQuery.php

Scope (this repo)

Path Work
lib/JIT/Builtin/StringHttpBuildQuery.php Remove hashtable LLVM; call VmHttpBuildQuery via JIT builtin bridge
ext/standard/http_build_query.php Shared lower() entry for JIT/AOT
ext/standard/VmHttpBuildQuery.php SSOT (enum/object encoding with #8733)
Tests test/compliance/cases/stdlib/http_build_query*.phpt JIT section

Done when

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

    area:compilerCompiler / CFG / JITenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-0:FoundationPhase 0 – foundation & DevExphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions