Category
php-in-php | bootstrap
Problem
hrtime() and DNS hostname builtins (gethostbyname(), gethostbynamel(), …) use host ext/ffi in ext/standard/VmHrtime.php and VmDns.php. Self-host / AOT bundles that omit Zend FFI cannot provide monotonic timing or libc resolver calls — breaking perf probes (hrtime) and any compile-time / runtime path that resolves hostnames.
JIT already exposes __compiler_hrtime_* in lib/JIT/Builtin/StringHrtime.php; VM should share the same native path without instantiating FFI::cdef in PHP.
php-src reference
Repro
A — hrtime
<?php
var_export(is_array(hrtime()));
var_export(hrtime(true) > 0);
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php repro.php
php repro.php
'
B — DNS
<?php
var_export(gethostbyname('localhost'));
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php'
Bootstrap gap: grep extension_loaded('ffi') in VmHrtime.php / VmDns.php — when false, behavior is degraded or absent; document in PR.
Scope (this repo)
| Module |
Path |
| VM |
ext/standard/VmHrtime.php, VmDns.php — route through existing JIT/native symbols or new thin __compiler_* in linked runtime |
| JIT/AOT |
lib/JIT/Builtin/StringHrtime.php (reuse) |
| Builtins |
ext/standard/hrtime.php, DNS wrappers in Module.php |
| Tests |
test/compliance/cases/stdlib/hrtime_native.phpt, gethostbyname_native.phpt |
PHP-in-PHP first: port resolver logic to ext/standard/ PHP where possible; keep C as syscall trampoline only.
Done when
Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter hrtime'
make bootstrap-selfhost-link
Related
Category
php-in-php|bootstrapProblem
hrtime()and DNS hostname builtins (gethostbyname(),gethostbynamel(), …) use hostext/ffiinext/standard/VmHrtime.phpandVmDns.php. Self-host / AOT bundles that omit Zend FFI cannot provide monotonic timing or libc resolver calls — breaking perf probes (hrtime) and any compile-time / runtime path that resolves hostnames.JIT already exposes
__compiler_hrtime_*inlib/JIT/Builtin/StringHrtime.php; VM should share the same native path without instantiatingFFI::cdefin PHP.php-src reference
ext/standard/hrtime.c—clock_gettime(CLOCK_MONOTONIC)ext/standard/dns.c—php_dns_*/getaddrinfoclock_gettime,getaddrinfo— thin AOT syscall ABI only if PHP lowering cannot reach themRepro
A — hrtime
B — DNS
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php'Bootstrap gap: grep
extension_loaded('ffi')inVmHrtime.php/VmDns.php— when false, behavior is degraded or absent; document in PR.Scope (this repo)
ext/standard/VmHrtime.php,VmDns.php— route through existing JIT/native symbols or new thin__compiler_*in linked runtimelib/JIT/Builtin/StringHrtime.php(reuse)ext/standard/hrtime.php, DNS wrappers inModule.phptest/compliance/cases/stdlib/hrtime_native.phpt,gethostbyname_native.phptPHP-in-PHP first: port resolver logic to
ext/standard/PHP where possible; keep C as syscall trampoline only.Done when
ext/ffi(monotonic array + positive int ns)gethostbyname('localhost')returns127.0.0.1or::1without FFIVmHrtime.php/VmDns.phpFFI blocks./script/ci-fast.sh --filter hrtimegreenVerification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter hrtime' make bootstrap-selfhost-linkRelated