Skip to content

Language: class const object expressions JIT/AOT — shared identity (phase 2 of #3196) #4021

Description

@PurHur

Category

language

Problem

#3196 closed VM support for class constants initialized with new (PHP 8.3 object constants). Capability row class_const_object remains JIT=no / AOT=no. JIT/AOT must materialize immortal object constants at class init and return shared identity on Class::CONST fetch — same as Zend compile-time constant folding.

php-src reference

Repro

<?php
class C {
    public const X = new stdClass();
}
echo (C::X === C::X) ? "1\n" : "0\n";
echo (C::X instanceof stdClass) ? "1\n" : "0\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php repro.php
php bin/jit.php repro.php 2>&1
'

Expected (Zend): two lines of 1 (same object identity). VM (#3196): ✅. JIT/AOT: gap — compile or runtime error / wrong identity.

Scope

Layer Files
VM reference lib/VM/ClassConstMaterializer.php, lib/Compiler.php const-init
JIT Emit immortal object handle in class metadata; TYPE_CLASS_CONST_FETCH loads shared slot
AOT Link constant object section / preinit in VMContext
Tests test/compliance/cases/language/class_const_object_jit.phpt

Done when

  • JIT + AOT repro prints 1 / 1 matching VM
  • class_const_object row: jit/aot true in capability syntax matrix
  • No per-fetch new — identity stable across fetches

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 / 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