Skip to content

php-in-php: JIT StringGetrusage — route getrusage() through VmGetrusageNative PHP not struct rusage LLVM (#1492) #9184

Description

@PurHur

Category

php-in-php · stdlib

Problem

getrusage() VM reads process stats via ext/standard/VmGetrusageNative.php (libc getrusage(2) FFI) with VmGetrusagePure.php fallback, but JIT reimplements Linux struct rusage layout in lib/JIT/Builtin/StringGetrusage.php (__compiler_getrusage, hard-coded x86_64 offsets). Layout duplication is fragile and blocks PHP-in-PHP (#1492).

php-src reference

Repro

<?php
$ru = getrusage();
var_export(is_array($ru));
echo "\n";
var_export(isset($ru['ru_utime.tv_sec'], $ru['ru_maxrss']));
echo "\n";
$ru1 = getrusage(1); // RUSAGE_CHILDREN — may be false on some platforms
var_export($ru1 === false || is_array($ru1));
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php repro_getrusage.php
php bin/jit.php repro_getrusage.php
php -r "var_export(isset(getrusage()[\"ru_maxrss\"]));"
'
Runtime Associative keys match php-src
VM yes
JIT must match VM after fix

Scope

Layer Path
VM SSOT ext/standard/getrusage.php, VmGetrusageNative.php, VmGetrusagePure.php
JIT ext/standard/JitGetrusageArg.php + route to PHP helper
Shrink lib/JIT/Builtin/StringGetrusage.php offset table
Tests test/compliance/cases/stdlib/getrusage_jit_vm.phpt

Done when (php-src-strict)

  • Repro array keys identical VM vs JIT
  • __compiler_getrusage LLVM implementation removed
  • ./script/ci-fast.sh --filter getrusage_jit green

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 apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions