Skip to content

php-in-php: JIT StreamNotificationRuntime — route stream_notification_callback through ext/standard PHP not LLVM global (#1492) #9478

Description

@PurHur

Category

php-in-php · stdlib · streams (#1492)

Problem

stream_notification_callback() stores the user notifier in a JIT/AOT LLVM global via lib/JIT/Builtin/StreamNotificationRuntime.php, while the VM builtin already lives in ext/standard/stream_notification_callback.php.

Stream wrappers invoke the callback from both VM and JIT paths; duplicated storage causes risk of VM-set callbacks not visible to JIT stream I/O (and vice versa).

php-src reference

Repro

<?php
stream_notification_callback(function ($ncode, $severity, $message, $code, $transferred, $max) {
    echo "notify:$ncode\n";
});
$ctx = stream_context_create(['http' => ['timeout' => 1]]);
@file_get_contents('http://127.0.0.1:1/', false, $ctx);
echo "done\n";
./script/docker-exec.sh -- php bin/vm.php repro.php
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/jit.php repro.php'

Callback must fire identically on VM and JIT; today JIT may read a different global slot than VM PHP storage.

Scope (this repo)

Layer Path
VM SSOT ext/standard/stream_notification_callback.php, stream context state
LLVM today lib/JIT/Builtin/StreamNotificationRuntime.php (__phpc_stream_notification_callback_set)
JIT streams lib/JIT/Builtin/StreamReadJit.php, StreamIoJit.php — call PHP getter

Done when

  • Single PHP-owned callback registry shared by VM + JIT/AOT
  • StreamNotificationRuntime.php deleted or link stub only
  • Compliance guard with VM + JIT .phpt under test/compliance/cases/stdlib/stream_notification_callback*.phpt
  • PR cites php-src + LLVM lines removed

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 appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions