Skip to content

Language: User __destruct() — JIT/AOT invoke on object release (phase 2 of #3144) #4013

Description

@PurHur

Category

language | runtime

Problem

#3144 closed VM __destruct() — refcount drop and shutdown pass call user destructors. Capability matrix: JIT = no, AOT = no.

Native-compiled apps that rely on destructors for resource cleanup (locks, handles, flush buffers) still need VM execution or miss destructor calls in JIT/AOT paths.

php-src reference

Repro (today)

<?php
class D {
    public function __destruct() {
        echo "bye\n";
    }
}
new D();
echo "end\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro_destruct.php'
# VM: bye before end

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/jit.php repro_destruct.php'
# JIT: verify __destruct runs at end of script / scope (may differ today)
Runtime Expected (Zend order) end then bye on scope end / request shutdown
VM #3144 behavior
JIT/AOT Match VM ordering

Scope (this repo)

Area Files
VM lib/VM.php — destructor queue / invokeDestructors (reference)
JIT/AOT runtime Register destructor callbacks at TYPE_NEW sites; run at function return / script end
Tests test/compliance/cases/language/destruct_user.phpt (+ jit)
Matrix class_destruct row in script/capability-syntax-lib.php

Done when

  • Repro prints end then bye under bin/jit.php (same as VM)
  • AOT binary prints same sequence at process exit
  • Circular references still require gc_collect_cycles() for cycle destructors (document if VM-only)

Verification

./script/ci-fast.sh --filter destruct_user

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-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions