Skip to content

php-in-php: JIT calendar builtins — route mktime/strftime/strptime/gmmktime through VmDateTimeNative not libc LLVM (#1492) #9132

Description

@PurHur

Category

php-in-php · php-src-strict

Problem

VM date builtins (mktime, gmmktime, strftime, strptime, gmstrftime, …) are implemented in ext/standard/ PHP (VmDate.php, VmDateTimeNative.php, per-function wrappers). JIT/AOT still register LLVM helpers in:

  • lib/JIT/Builtin/StringMktime.php — __compiler_mktime via libc mktime(3) + struct tm offsets
  • lib/JIT/Builtin/StringStrftime.php — __compiler_strftime via libc strftime
  • lib/JIT/Builtin/StringStrptime.php — __compiler_strptime via libc strptime
  • lib/JIT/Builtin/Type.php — __compiler_gmmktime, __compiler_gmgetdate, …

This duplicates calendar math, timezone/DST handling, and enum operand guards already centralized in PHP (#8770 umbrella for mutation helpers — this issue covers formatting/parsing LLVM builtins).

php-src reference

  • php/php-src ext/date/php_date.c — PHP_FUNCTION(mktime), strftime, strptime
  • VM mirror: ext/standard/VmDate.php, ext/standard/VmDateTimeNative.php, ext/standard/mktime.php, strftime.php, strptime.php

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php -r "var_export(mktime(0,0,0,6,17,2026)); echo PHP_EOL;"
php bin/jit.php -r "var_export(mktime(0,0,0,6,17,2026)); echo PHP_EOL;"
# JIT lowers via __compiler_mktime (StringMktime.php libc layout constants)'

Scope

Layer Path
JIT lib/JIT/Builtin/StringMktime.php, StringStrftime.php, StringStrptime.php
Wiring lib/JIT/Builtin/Type.php calendar __compiler_* symbols
PHP helpers ext/standard/VmDateTimeNative.php (extend if needed)
No new C runtime — shrink glibc struct tm offset tables in JIT sources

Done when

Ref: #1492, #6706 (gmmktime presence), #3692/#3694

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 apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions