Skip to content

Stdlib: highlight_string/highlight_file/show_source — JIT/AOT lowering (phase 2 of #3164) #4366

Description

@PurHur

Category

stdlib

Problem

#3164 / #3447 delivered VM highlight_string(), highlight_file(), and show_source() by delegating to the host Zend tokenizer (ext/standard/VmHighlight.php). docs/capabilities.md marks them JIT = yes at register level, but highlight_string.php call() throws highlight_string() is VM only in this compiler build — bin/jit.php / AOT cannot run debug/highlight snippets without VM fallback.

php-src reference

Repro

<?php
$html = highlight_string('<?php echo 1; ?>', true);
echo str_contains($html, '<code') ? "ok\n" : "fail\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php repro.php          # ok today
php bin/jit.php repro.php         # LogicException VM-only (or fallback)
'

Existing compliance: test/compliance/cases/stdlib/highlight_string.phpt (VM); extend with _jit.phpt / AOT fixture.

Scope (this repo)

Layer Files
VM ext/standard/VmHighlight.php — keep host delegate for phase 1
JIT/AOT ext/standard/highlight_string.php, highlight_file.php, show_source.php — call() lowering OR link runtime C port of php_highlight.h subset
Runtime lib/AOT/runtime/ — optional phpc_highlight_string helper (no full Zend link)
Tests test/compliance/cases/stdlib/highlight_string_jit.phpt, test/fixtures/aot/cases/highlight_string.phpt
Matrix script/capability-matrix.php — align JIT notes with reality

Done when

  • bin/jit.php repro prints ok without VM-only LogicException
  • AOT binary runs repro with HTML output containing <code
  • Capability matrix: consistent JIT/AOT notes (no "yes" while call() throws)
  • ./script/ci-fast.sh --filter highlight green

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

    area:compilerCompiler / CFG / JITarea:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions