Skip to content

JIT Stdlib: implode, explode, and str_replace for templates and routing #82

@PurHur

Description

@PurHur

Problem

Several high-frequency string/array builtins throw at JIT compile time:

  • ext/standard/implode.phpimplode() is not implemented for JIT
  • ext/standard/explode.phpexplode() is not implemented for JIT
  • ext/standard/str_replace.phpstr_replace() is not implemented for JIT

VM mode already runs these (compliance/real tests exist for many stdlib functions). AOT/JIT web apps that build HTML from arrays or split paths cannot compile until these are lowered.

Goal

Implement LLVM lowering (or VM fallback shim) for implode, explode, and str_replace with parity to VM semantics for the common web subset.

Tasks

  • Audit VM implementations in ext/standard/ for each function
  • Add JitImplode, JitExplode, JitStrReplace helpers mirroring existing patterns (JitStrpos, JitStrPad)
  • Support glue/separator as string; reject unsupported types with clear errors
  • explode: limit argument, empty-string edge cases per PHP
  • Compliance PHPT cases under test/compliance/cases/stdlib/ marked for JIT
  • AOT fixture: simple template loop building HTML via implode

Acceptance criteria

$parts = ['<li>', 'a', '</li>'];
echo implode('', $parts);
$segments = explode('/', trim($_SERVER['REQUEST_URI'], '/'));

…compiles and runs identically in VM, JIT, and AOT.

Key files

  • ext/standard/implode.php, explode.php, str_replace.php
  • lib/JIT/Call/Native.php, lib/JIT/Builtin/

Blocks

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions